summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/AppCompat
diff options
context:
space:
mode:
authorPaul DiPietro <pauldipietro@users.noreply.github.com>2016-07-18 18:20:20 -0500
committerJason Smith <jason.smith@xamarin.com>2016-07-18 16:20:20 -0700
commit9c36f133ad1017b7126330768a8b6c986a051a95 (patch)
treeabd29bbc316b5e1ce6a83dc4e81bd58a9910bbac /Xamarin.Forms.Platform.Android/AppCompat
parent5268d609fafc142886700bd4b0d8bcb4f465a801 (diff)
downloadxamarin-forms-9c36f133ad1017b7126330768a8b6c986a051a95.tar.gz
xamarin-forms-9c36f133ad1017b7126330768a8b6c986a051a95.tar.bz2
xamarin-forms-9c36f133ad1017b7126330768a8b6c986a051a95.zip
[Android] Add dialog null check for AppCompat Picker OnClick (#257)
Multiple, rapid taps on the Picker in AppCompat could potentially open more than one dialog, causing a crash upon their being closed. Adding a null check for the dialog prevents more than one from being created.
Diffstat (limited to 'Xamarin.Forms.Platform.Android/AppCompat')
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/PickerRenderer.cs32
1 files changed, 17 insertions, 15 deletions
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/PickerRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/PickerRenderer.cs
index 492b553b..9e81cf2d 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/PickerRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/PickerRenderer.cs
@@ -93,25 +93,27 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
void OnClick()
{
Picker model = Element;
- using (var builder = new AlertDialog.Builder(Context))
+ if (_dialog == null)
{
- builder.SetTitle(model.Title ?? "");
- string[] items = model.Items.ToArray();
- builder.SetItems(items, (s, e) => ((IElementController)model).SetValueFromRenderer(Picker.SelectedIndexProperty, e.Which));
-
- builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => { });
+ using (var builder = new AlertDialog.Builder(Context))
+ {
+ builder.SetTitle(model.Title ?? "");
+ string[] items = model.Items.ToArray();
+ builder.SetItems(items, (s, e) => ((IElementController)model).SetValueFromRenderer(Picker.SelectedIndexProperty, e.Which));
- _dialog = builder.Create();
- }
+ builder.SetNegativeButton(global::Android.Resource.String.Cancel, (o, args) => { });
- _dialog.SetCanceledOnTouchOutside(true);
- _dialog.DismissEvent += (sender, args) =>
- {
- _dialog.Dispose();
- _dialog = null;
- };
+ _dialog = builder.Create();
+ }
+ _dialog.SetCanceledOnTouchOutside(true);
+ _dialog.DismissEvent += (sender, args) =>
+ {
+ _dialog.Dispose();
+ _dialog = null;
+ };
- _dialog.Show();
+ _dialog.Show();
+ }
}
void RowsCollectionChanged(object sender, EventArgs e)