protected override void Dispose(bool disposing) { if (disposing && !_disposed) { _disposed = true; if (Element != null) { PageController.InternalChildren.CollectionChanged -= OnChildrenCollectionChanged; } if (_viewPager != null) { RemoveView(_viewPager); _viewPager.ClearOnPageChangeListeners(); _viewPager.Adapter.Dispose(); _viewPager.Dispose(); _viewPager = null; } RemoveAllViews(); _previousPage = null; _fragmentManager = null; if (Element?.Children != null) { foreach (ContentPage pageToRemove in Element.Children) { IVisualElementRenderer pageRenderer = Platform.GetRenderer(pageToRemove); if (pageRenderer != null) { pageRenderer.View.RemoveFromParent(); pageRenderer.Dispose(); } pageToRemove.ClearValue(Platform.RendererProperty); } } } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing && !_disposed) { _disposed = true; if (Element != null) { PageController.InternalChildren.CollectionChanged -= OnChildrenCollectionChanged; foreach (Page pageToRemove in Element.Children) { TeardownPage(pageToRemove); } } RemoveAllViews(); if (_viewPager != null) { _viewPager.ClearOnPageChangeListeners(); _viewPager.Adapter.Dispose(); _viewPager.Dispose(); _viewPager = null; } if (_tabLayout != null) { _tabLayout.ClearOnTabSelectedListeners(); _tabLayout.Dispose(); _tabLayout = null; } if (_bottomNavigationView != null) { _bottomNavigationView.SetOnNavigationItemSelectedListener(null); _bottomNavigationView.Dispose(); _bottomNavigationView = null; } if (_relativeLayout != null) { _relativeLayout.Dispose(); _relativeLayout = null; } if (Element != null) { foreach (Page pageToRemove in Element.Children) { IVisualElementRenderer pageRenderer = Android.Platform.GetRenderer(pageToRemove); pageRenderer?.Dispose(); pageToRemove.ClearValue(Android.Platform.RendererProperty); } } _previousPage = null; } base.Dispose(disposing); }