summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
diff options
context:
space:
mode:
authorPaul DiPietro <pauldipietro@users.noreply.github.com>2016-07-12 14:59:32 (GMT)
committerRui Marinho <me@ruimarinho.net>2016-07-12 14:59:32 (GMT)
commit39b12a48647bc528fadf423af591658a893d0b9a (patch)
treef1af129b1872f9ff7f8542fc734c9963d0073e4e /Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
parentc08027804e7ed3d0475e5816cbd51dc25e9be666 (diff)
downloadxamarin-forms-39b12a48647bc528fadf423af591658a893d0b9a.zip
xamarin-forms-39b12a48647bc528fadf423af591658a893d0b9a.tar.gz
xamarin-forms-39b12a48647bc528fadf423af591658a893d0b9a.tar.bz2
[Android] TimePicker unfocuses on cancel (#238)
Related to the prior fix of the DatePicker not unfocusing on the cancel button being pressed, the TimePicker was not unfocusing, as well. A similar fix has been applied.
Diffstat (limited to 'Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs')
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs b/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
index 4cb5d2d..2b33acc 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs
@@ -27,6 +27,10 @@ namespace Xamarin.Forms.Platform.Android
ElementController.SetValueFromRenderer(TimePicker.TimeProperty, new TimeSpan(hourOfDay, minute, 0));
Control.ClearFocus();
+
+ if (Forms.IsLollipopOrNewer)
+ _dialog.CancelEvent -= OnCancelButtonClicked;
+
_dialog = null;
}
@@ -70,6 +74,10 @@ namespace Xamarin.Forms.Platform.Android
_dialog.Hide();
ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
Control.ClearFocus();
+
+ if (Forms.IsLollipopOrNewer)
+ _dialog.CancelEvent -= OnCancelButtonClicked;
+
_dialog = null;
}
}
@@ -80,9 +88,18 @@ namespace Xamarin.Forms.Platform.Android
ElementController.SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, true);
_dialog = new TimePickerDialog(Context, this, view.Time.Hours, view.Time.Minutes, false);
+
+ if (Forms.IsLollipopOrNewer)
+ _dialog.CancelEvent += OnCancelButtonClicked;
+
_dialog.Show();
}
+ void OnCancelButtonClicked(object sender, EventArgs e)
+ {
+ Element.Unfocus();
+ }
+
void SetTime(TimeSpan time)
{
Control.Text = DateTime.Today.Add(time).ToString(Element.Format);