forked from organicmaps/organicmaps
Merge pull request #3328 from trashkalmar/timepicker-hack-master
[android] fix: Hack TimePicker to force set Hours mode.
This commit is contained in:
commit
1700891292
1 changed files with 15 additions and 2 deletions
|
@ -38,6 +38,8 @@ public class HoursMinutesPickerFragment extends BaseMwmDialogFragment
|
|||
private HoursMinutes mTo;
|
||||
|
||||
private TimePicker mPicker;
|
||||
private View mPickerHoursLabel;
|
||||
|
||||
@IntRange(from = 0, to = 1) private int mSelectedTab;
|
||||
private TabLayout mTabs;
|
||||
|
||||
|
@ -124,6 +126,17 @@ public class HoursMinutesPickerFragment extends BaseMwmDialogFragment
|
|||
@SuppressLint("InflateParams")
|
||||
final View root = inflater.inflate(R.layout.fragment_timetable_picker, null);
|
||||
|
||||
mPicker = (TimePicker) root.findViewById(R.id.picker);
|
||||
mPicker.setIs24HourView(DateFormat.is24HourFormat(getActivity()));
|
||||
|
||||
int id = getResources().getIdentifier("hours", "id", "android");
|
||||
if (id != 0)
|
||||
{
|
||||
mPickerHoursLabel = mPicker.findViewById(id);
|
||||
if (!(mPickerHoursLabel instanceof TextView))
|
||||
mPickerHoursLabel = null;
|
||||
}
|
||||
|
||||
mTabs = (TabLayout) root.findViewById(R.id.tabs);
|
||||
TextView tabView = (TextView) inflater.inflate(R.layout.tab_timepicker, mTabs, false);
|
||||
// TODO @yunik add translations
|
||||
|
@ -147,6 +160,8 @@ public class HoursMinutesPickerFragment extends BaseMwmDialogFragment
|
|||
saveHoursMinutes();
|
||||
mSelectedTab = tab.getPosition();
|
||||
refreshPicker();
|
||||
if (mPickerHoursLabel != null)
|
||||
mPickerHoursLabel.performClick();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -156,8 +171,6 @@ public class HoursMinutesPickerFragment extends BaseMwmDialogFragment
|
|||
public void onTabReselected(TabLayout.Tab tab) {}
|
||||
});
|
||||
|
||||
mPicker = (TimePicker) root.findViewById(R.id.picker);
|
||||
mPicker.setIs24HourView(DateFormat.is24HourFormat(getActivity()));
|
||||
return root;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue