summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs17
1 files changed, 7 insertions, 10 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
index 6ded75d8..c2bf10db 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
@@ -14,8 +14,6 @@ namespace Xamarin.Forms.Platform.Android
{
AlertDialog _dialog;
TextColorSwitcher _textColorSwitcher;
- bool _is24HourFormat;
- string _timeFormat;
public TimePickerRenderer()
{
@@ -26,9 +24,9 @@ namespace Xamarin.Forms.Platform.Android
void TimePickerDialog.IOnTimeSetListener.OnTimeSet(ATimePicker view, int hourOfDay, int minute)
{
- ElementController.SetValueFromRenderer(TimePicker.TimeProperty, new TimeSpan(hourOfDay, minute, 0));
-
ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
+
+ ElementController.SetValueFromRenderer(TimePicker.TimeProperty, new TimeSpan(hourOfDay, minute, 0));
Control.ClearFocus();
if (Forms.IsLollipopOrNewer)
@@ -52,9 +50,7 @@ namespace Xamarin.Forms.Platform.Android
textField.SetOnClickListener(TimePickerListener.Instance);
SetNativeControl(textField);
- _textColorSwitcher = new TextColorSwitcher(textField.TextColors);
- _is24HourFormat = DateFormat.Is24HourFormat(Context);
- _timeFormat = _is24HourFormat ? "HH:mm" : Element.Format;
+ _textColorSwitcher = new TextColorSwitcher(textField.TextColors);
}
SetTime(e.NewElement.Time);
@@ -96,8 +92,9 @@ namespace Xamarin.Forms.Platform.Android
{
TimePicker view = Element;
ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
-
- _dialog = new TimePickerDialog(Context, this, view.Time.Hours, view.Time.Minutes, _is24HourFormat);
+
+ bool is24HourFormat = DateFormat.Is24HourFormat(Context);
+ _dialog = new TimePickerDialog(Context, this, view.Time.Hours, view.Time.Minutes, is24HourFormat);
if (Forms.IsLollipopOrNewer)
_dialog.CancelEvent += OnCancelButtonClicked;
@@ -112,7 +109,7 @@ namespace Xamarin.Forms.Platform.Android
void SetTime(TimeSpan time)
{
- Control.Text = DateTime.Today.Add(time).ToString(_timeFormat);
+ Control.Text = DateTime.Today.Add(time).ToString(Element.Format);
}
void UpdateTextColor()