diff options
author | adrianknight89 <adrianknight89@outlook.com> | 2016-12-06 06:14:38 -0600 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2016-12-06 12:14:38 +0000 |
commit | 10c65d035869fdc587f6ddddc0d472033af61ee6 (patch) | |
tree | 27a0c6fe105daaef87bc7b9120335301d97de828 /Xamarin.Forms.Platform.Android | |
parent | 5a2cb89775e4de1fe8b8e1d4b673612e5f41f94a (diff) | |
download | xamarin-forms-10c65d035869fdc587f6ddddc0d472033af61ee6.tar.gz xamarin-forms-10c65d035869fdc587f6ddddc0d472033af61ee6.tar.bz2 xamarin-forms-10c65d035869fdc587f6ddddc0d472033af61ee6.zip |
[Android] Dismiss context menu when view cell is removed (#568)
* close context action when cell is no longer available
* rename method
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r-- | Xamarin.Forms.Platform.Android/CellAdapter.cs | 11 | ||||
-rw-r--r-- | Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs | 9 |
2 files changed, 10 insertions, 10 deletions
diff --git a/Xamarin.Forms.Platform.Android/CellAdapter.cs b/Xamarin.Forms.Platform.Android/CellAdapter.cs index 03957d37..7664834b 100644 --- a/Xamarin.Forms.Platform.Android/CellAdapter.cs +++ b/Xamarin.Forms.Platform.Android/CellAdapter.cs @@ -174,12 +174,10 @@ namespace Xamarin.Forms.Platform.Android view.SetBackgroundResource(0); } - internal void CloseContextAction() + internal void CloseContextActions() { - if (_actionMode != null) - _actionMode.Finish(); - if (_supportActionMode != null) - _supportActionMode.Finish(); + _actionMode?.Finish(); + _supportActionMode?.Finish(); } void CreateContextMenu(IMenu menu) @@ -226,8 +224,7 @@ namespace Xamarin.Forms.Platform.Android { if (!cell.HasContextActions) { - _actionMode?.Finish(); - _supportActionMode?.Finish(); + CloseContextActions(); return false; } diff --git a/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs b/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs index 51c603c4..245c3d74 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs @@ -54,9 +54,9 @@ namespace Xamarin.Forms.Platform.Android var platform = _listView.Platform; if (platform.GetType() == typeof(AppCompat.Platform)) - MessagingCenter.Subscribe<AppCompat.Platform>(this, AppCompat.Platform.CloseContextActionsSignalName, p => CloseContextAction()); + MessagingCenter.Subscribe<AppCompat.Platform>(this, AppCompat.Platform.CloseContextActionsSignalName, p => CloseContextActions()); else - MessagingCenter.Subscribe<Platform>(this, Platform.CloseContextActionsSignalName, p => CloseContextAction()); + MessagingCenter.Subscribe<Platform>(this, Platform.CloseContextActionsSignalName, p => CloseContextActions()); } public override int Count @@ -321,7 +321,7 @@ namespace Xamarin.Forms.Platform.Android { if (disposing) { - CloseContextAction(); + CloseContextActions(); var platform = _listView.Platform; if (platform.GetType() == typeof(AppCompat.Platform)) @@ -445,6 +445,9 @@ namespace Xamarin.Forms.Platform.Android void OnDataChanged() { + if (ActionModeContext != null && !TemplatedItemsView.TemplatedItems.Contains(ActionModeContext)) + CloseContextActions(); + if (IsAttachedToWindow) NotifyDataSetChanged(); else |