Esempio n. 1
0
        void Destroy()
        {
            if (ShellItem != null)
            {
                UnhookEvents(ShellItem);
            }

            ((IShellController)ShellContext?.Shell)?.RemoveAppearanceObserver(this);

            if (_bottomSheetDialog != null)
            {
                _bottomSheetDialog.DismissEvent -= OnMoreSheetDismissed;
                _bottomSheetDialog?.Dispose();
                _bottomSheetDialog = null;
            }

            _navigationArea?.Dispose();
            _appearanceTracker?.Dispose();
            _outerLayout?.Dispose();

            if (_bottomView != null)
            {
                _bottomView?.SetOnNavigationItemSelectedListener(null);
                _bottomView?.Background?.Dispose();
                _bottomView?.Dispose();
            }

            _bottomView        = null;
            _navigationArea    = null;
            _appearanceTracker = null;
            _outerLayout       = null;
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing && !_disposed)
            {
                _disposed = true;
                RemoveAllViews();
                foreach (Page pageToRemove in Element.Children)
                {
                    IVisualElementRenderer pageRenderer = Android.Platform.GetRenderer(pageToRemove);
                    if (pageRenderer != null)
                    {
                        pageRenderer.View.RemoveFromParent();
                        pageRenderer.Dispose();
                    }
                    pageToRemove.PropertyChanged -= OnPagePropertyChanged;
                    pageToRemove.ClearValue(Android.Platform.RendererProperty);
                }

                if (_viewPager != null)
                {
                    _viewPager.Adapter.Dispose();
                    _viewPager.Dispose();
                    _viewPager = null;
                }

                if (_tabLayout != null)
                {
                    _tabLayout.AddOnTabSelectedListener(null);
                    _tabLayout.Dispose();
                    _tabLayout = null;
                }

                if (_bottomNavigationView != null)
                {
                    _bottomNavigationView.SetOnNavigationItemSelectedListener(null);
                    _bottomNavigationView.SetOnNavigationItemReselectedListener(null);
                    _bottomNavigationView.Dispose();
                    _bottomNavigationView = null;
                }

                if (_relativeLayout != null)
                {
                    _relativeLayout.Dispose();
                    _relativeLayout = null;
                }

                if (Element != null)
                {
                    PageController.InternalChildren.CollectionChanged -= OnChildrenCollectionChanged;
                }

                _previousPage = null;
            }

            base.Dispose(disposing);
        }
Esempio n. 3
0
        protected override void Dispose(bool disposing)
        {
            if (_tabbar != null)
            {
                _tabbar.Dispose();
                _tabbar = null;
            }

            base.Dispose(disposing);
        }
Esempio n. 4
0
        // Use OnDestory become OnDestroyView may fire before events are completed.
        public override void OnDestroy()
        {
            UnhookEvents(ShellItem);
            if (_bottomView != null)
            {
                _bottomView?.SetOnNavigationItemSelectedListener(null);
                _bottomView?.Background?.Dispose();
                _bottomView?.Dispose();
                _bottomView = null;

                _navigationArea?.Dispose();
                _navigationArea = null;

                _appearanceTracker?.Dispose();
                _appearanceTracker = null;

                _outerLayout?.Dispose();
                _outerLayout = null;
            }

            ((IShellController)ShellContext.Shell).RemoveAppearanceObserver(this);

            base.OnDestroy();
        }