Skip to content

Commit

Permalink
[Catalog] Fix timeFormat toggle in TimePickerMainDemoFragment
Browse files Browse the repository at this point in the history
Resolves #2640

GIT_ORIGIN_REV_ID=753e4d8a696593e93594643f6aea18f3ce6cab94
PiperOrigin-RevId: 442591442
  • Loading branch information
pubiqq authored and drchen committed Apr 18, 2022
1 parent 5b9f27a commit db16763
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ public View onCreateDemoView(

timeFormatToggle.addOnButtonCheckedListener(
(group, checkedId, isChecked) -> {
boolean isSystem24Hour = DateFormat.is24HourFormat(getContext());
boolean is24Hour =
checkedId == R.id.time_format_24h
|| (checkedId == R.id.time_format_system && isSystem24Hour);

clockFormat = is24Hour ? TimeFormat.CLOCK_24H : TimeFormat.CLOCK_12H;
if (isChecked) {
boolean isSystem24Hour = DateFormat.is24HourFormat(getContext());
boolean is24Hour =
checkedId == R.id.time_format_24h
|| (checkedId == R.id.time_format_system && isSystem24Hour);

clockFormat = is24Hour ? TimeFormat.CLOCK_24H : TimeFormat.CLOCK_12H;
}
});

SwitchCompat frameworkSwitch = view.findViewById(R.id.framework_switch);
Expand Down

0 comments on commit db16763

Please sign in to comment.