summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2016-10-04 17:47:02 (GMT)
committerRui Marinho <me@ruimarinho.net>2016-10-04 17:47:02 (GMT)
commitd178a458ee1cdae63e1ffaf6f5445000f7b9cd0e (patch)
treeadee2c88cec80075e405220305de1a6618202c3a /Xamarin.Forms.Platform.Android
parentc83c19f106162ca55ab57dfea3693246ec6155fa (diff)
downloadxamarin-forms-d178a458ee1cdae63e1ffaf6f5445000f7b9cd0e.zip
xamarin-forms-d178a458ee1cdae63e1ffaf6f5445000f7b9cd0e.tar.gz
xamarin-forms-d178a458ee1cdae63e1ffaf6f5445000f7b9cd0e.tar.bz2
Unhook drawer listeners so MDP renderer and pages can be collected (#412)
Null out page in custom MDP renderer in Control Gallery so it can be collected Checkpoint Checkpoint Checkpoint Checkpoint Checkpoint Checkpoint
Diffstat (limited to 'Xamarin.Forms.Platform.Android')
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/MasterDetailContainer.cs34
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs5
-rw-r--r--Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs1
3 files changed, 39 insertions, 1 deletions
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailContainer.cs b/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailContainer.cs
index 102bac5..1b85b42 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailContainer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailContainer.cs
@@ -11,8 +11,9 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
PageContainer _pageContainer;
FragmentManager _fragmentManager;
readonly bool _isMaster;
- readonly MasterDetailPage _parent;
+ MasterDetailPage _parent;
Fragment _currentFragment;
+ bool _disposed;
public MasterDetailContainer(MasterDetailPage parent, bool isMaster, Context context) : base(parent, isMaster, context)
{
@@ -106,6 +107,37 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
}
}
+ protected override void Dispose(bool disposing)
+ {
+ if (_disposed)
+ {
+ return;
+ }
+
+ _disposed = true;
+
+ if (disposing)
+ {
+ if (_currentFragment != null)
+ {
+ FragmentTransaction transaction = FragmentManager.BeginTransaction();
+ transaction.DisallowAddToBackStack();
+ transaction.Remove(_currentFragment);
+ transaction.SetTransition((int)FragmentTransit.None);
+ transaction.CommitAllowingStateLoss();
+ FragmentManager.ExecutePendingTransactions();
+
+ _currentFragment = null;
+ }
+
+ _parent = null;
+ _pageContainer = null;
+ _fragmentManager = null;
+ }
+
+ base.Dispose(disposing);
+ }
+
public void SetFragmentManager(FragmentManager fragmentManager)
{
if (_fragmentManager == null)
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs
index 6740285..ccf01f2 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/MasterDetailPageRenderer.cs
@@ -188,24 +188,29 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
if (_detailLayout != null)
{
+ RemoveView(_detailLayout);
_detailLayout.Dispose();
_detailLayout = null;
}
if (_masterLayout != null)
{
+ RemoveView(_masterLayout);
_masterLayout.Dispose();
_masterLayout = null;
}
Device.Info.PropertyChanged -= DeviceInfoPropertyChanged;
+ RemoveDrawerListener(this);
+
if (Element != null)
{
MasterDetailPageController.BackButtonPressed -= OnBackButtonPressed;
Element.PropertyChanged -= HandlePropertyChanged;
Element.Appearing -= MasterDetailPageAppearing;
Element.Disappearing -= MasterDetailPageDisappearing;
+
Element.ClearValue(Android.Platform.RendererProperty);
Element = null;
}
diff --git a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
index 97b2029..b77063e 100644
--- a/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
+++ b/Xamarin.Forms.Platform.Android/AppCompat/NavigationPageRenderer.cs
@@ -173,6 +173,7 @@ namespace Xamarin.Forms.Platform.Android.AppCompat
if (_drawerLayout != null && _drawerListener != null)
{
_drawerLayout.RemoveDrawerListener(_drawerListener);
+ _drawerListener = null;
}
_drawerToggle = null;