diff options
author | Paul DiPietro <pauldipietro@users.noreply.github.com> | 2016-07-12 09:59:32 -0500 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2016-07-12 15:59:32 +0100 |
commit | 39b12a48647bc528fadf423af591658a893d0b9a (patch) | |
tree | f1af129b1872f9ff7f8542fc734c9963d0073e4e /Xamarin.Forms.Platform.Android | |
parent | c08027804e7ed3d0475e5816cbd51dc25e9be666 (diff) | |
download | xamarin-forms-39b12a48647bc528fadf423af591658a893d0b9a.tar.gz xamarin-forms-39b12a48647bc528fadf423af591658a893d0b9a.tar.bz2 xamarin-forms-39b12a48647bc528fadf423af591658a893d0b9a.zip |
[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')
-rw-r--r-- | Xamarin.Forms.Platform.Android/Renderers/TimePickerRenderer.cs | 17 |
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 4cb5d2d4..2b33acc6 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); |