Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Fix DatePicker dialog regression (#249)
Browse files Browse the repository at this point in the history
KitKat doesn't use the cancel button, so it has to be accounted for.
  • Loading branch information
pauldipietro authored and samhouts committed Jul 11, 2016
1 parent eb84f96 commit f167024
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Xamarin.Forms.Platform.Android/Renderers/DatePickerRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ protected override void Dispose(bool disposing)
_disposed = true;
if (_dialog != null)
{
_dialog.CancelEvent -= OnCancelButtonClicked;
if (Forms.IsLollipopOrNewer)
_dialog.CancelEvent -= OnCancelButtonClicked;

_dialog.Hide();
_dialog.Dispose();
_dialog = null;
Expand Down Expand Up @@ -85,7 +87,10 @@ internal override void OnFocusChangeRequested(object sender, VisualElement.Focus
_dialog.Hide();
((IElementController)Element).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
Control.ClearFocus();
_dialog.CancelEvent -= OnCancelButtonClicked;

if (Forms.IsLollipopOrNewer)
_dialog.CancelEvent -= OnCancelButtonClicked;

_dialog = null;
}
}
Expand All @@ -99,7 +104,9 @@ void CreateDatePickerDialog(int year, int month, int day)
((IElementController)view).SetValueFromRenderer(VisualElement.IsFocusedPropertyKey, false);
Control.ClearFocus();
_dialog.CancelEvent -= OnCancelButtonClicked;
if (Forms.IsLollipopOrNewer)
_dialog.CancelEvent -= OnCancelButtonClicked;
_dialog = null;
}, year, month, day);
}
Expand Down Expand Up @@ -128,7 +135,9 @@ void OnTextFieldClicked()
UpdateMinimumDate();
UpdateMaximumDate();

_dialog.CancelEvent += OnCancelButtonClicked;
if (Forms.IsLollipopOrNewer)
_dialog.CancelEvent += OnCancelButtonClicked;

_dialog.Show();
}

Expand Down

0 comments on commit f167024

Please sign in to comment.