diff options
author | Paul DiPietro <pauldipietro@users.noreply.github.com> | 2016-08-03 03:50:31 -0500 |
---|---|---|
committer | Rui Marinho <me@ruimarinho.net> | 2016-08-03 09:50:31 +0100 |
commit | 23614ca8c6cc78cb2b1df91977fd539a9fa159df (patch) | |
tree | 15b7712a80444ac76c19d8802d1b9cd32065d056 /Xamarin.Forms.Platform.Android | |
parent | a0611515e4bf9bb98b149047202ab27a032f259b (diff) | |
download | xamarin-forms-23614ca8c6cc78cb2b1df91977fd539a9fa159df.tar.gz xamarin-forms-23614ca8c6cc78cb2b1df91977fd539a9fa159df.tar.bz2 xamarin-forms-23614ca8c6cc78cb2b1df91977fd539a9fa159df.zip |
[Android] Fix ListView contextual actions not closing in AppCompat's NavigationPage/TabbedPage (#272)
* [Android] Fix ListView contextual actions not closing upon navigation in AppCompat
The Platform type in the ListViewAdapter was being treated as the
non-AppCompat type, and the NavAnimationInProgress value was not
being set as necessary in the NavigationPageRenderer.
* [Android] Add fix for TabbedPage swipes not closing contextual actions
Similar fix where swiping to another tab with the context menu open would
not close it. Relies on the prior commit.
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
3 files changed, 19 insertions, 3 deletions
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs index 2bc182da..f591f057 100644 --- a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs +++ b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs @@ -573,6 +573,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat Current = view; + ((Platform)Element.Platform).NavAnimationInProgress = true; FragmentTransaction transaction = fm.BeginTransaction(); if (animated) @@ -606,6 +607,8 @@ namespace Xamarin.Forms.Platform.Android.AppCompat transaction.Show(toShow); else transaction.Add(Id, toShow); + + ((Platform)Element.Platform).NavAnimationInProgress = false; } else { @@ -614,13 +617,14 @@ namespace Xamarin.Forms.Platform.Android.AppCompat transaction.Hide(currentToHide); transaction.Add(Id, fragment); fragments.Add(fragment); + ((Platform)Element.Platform).NavAnimationInProgress = false; } } transaction.Commit(); // The fragment transitions don't really SUPPORT telling you when they end // There are some hacks you can do, but they actually are worse than just doing this: - + if (animated) { if (!removed) diff --git a/Xamarin.Forms.Platform.Android/AppCompat/TabbedPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/TabbedPageRenderer.cs index 243e5c14..3c952a9a 100644 --- a/Xamarin.Forms.Platform.Android/AppCompat/TabbedPageRenderer.cs +++ b/Xamarin.Forms.Platform.Android/AppCompat/TabbedPageRenderer.cs @@ -264,7 +264,9 @@ namespace Xamarin.Forms.Platform.Android.AppCompat void ScrollToCurrentPage() { + ((Platform)Element.Platform).NavAnimationInProgress = true; _viewPager.SetCurrentItem(Element.Children.IndexOf(Element.CurrentPage), UseAnimations); + ((Platform)Element.Platform).NavAnimationInProgress = false; } void UpdateIgnoreContainerAreas() diff --git a/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs b/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs index 5dedef6c..a38aea0a 100644 --- a/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs +++ b/Xamarin.Forms.Platform.Android/Renderers/ListViewAdapter.cs @@ -52,7 +52,11 @@ namespace Xamarin.Forms.Platform.Android realListView.OnItemClickListener = this; realListView.OnItemLongClickListener = this; - MessagingCenter.Subscribe<Platform>(this, Platform.CloseContextActionsSignalName, p => CloseContextAction()); + var platform = _listView.Platform; + if (platform.GetType() == typeof(AppCompat.Platform)) + MessagingCenter.Subscribe<AppCompat.Platform>(this, AppCompat.Platform.CloseContextActionsSignalName, p => CloseContextAction()); + else + MessagingCenter.Subscribe<Platform>(this, Platform.CloseContextActionsSignalName, p => CloseContextAction()); } public override int Count @@ -325,7 +329,13 @@ namespace Xamarin.Forms.Platform.Android if (disposing) { CloseContextAction(); - MessagingCenter.Unsubscribe<Platform>(this, Platform.CloseContextActionsSignalName); + + var platform = _listView.Platform; + if (platform.GetType() == typeof(AppCompat.Platform)) + MessagingCenter.Unsubscribe<AppCompat.Platform>(this, Platform.CloseContextActionsSignalName); + else + MessagingCenter.Unsubscribe<Platform>(this, Platform.CloseContextActionsSignalName); + _realListView.OnItemClickListener = null; _realListView.OnItemLongClickListener = null; |