Example #1
0
 private void ClearView()
 {
     if (_view != null)
     {
         _view.ClearBindingsRecursively(true, true, AndroidToolkitExtensions.AggressiveViewCleanup);
         _view = null;
         AndroidToolkitExtensions.CleanupWeakReferences(false);
     }
 }
Example #2
0
        public override void OnDestroy(Action baseOnDestroy)
        {
            if (Tracer.TraceInformation)
            {
                Tracer.Info($"OnDestroy activity({Target})");
            }
            ServiceProvider.EventAggregator.Unsubscribe(this);
            Destroyed?.Invoke(Target, EventArgs.Empty);
            _view.ClearBindingsRecursively(true, true, AndroidToolkitExtensions.AggressiveViewCleanup);
            _view = null;

            if (_metadata != null)
            {
                _metadata.Clear();
                _metadata = null;
            }

            MenuTemplate.Clear(_menu);
            _menu = null;

            if (_menuInflater != null)
            {
                _menuInflater.Dispose();
                _menuInflater = null;
            }
            if (_layoutInflater != null)
            {
                _layoutInflater.Dispose();
                _layoutInflater = null;
            }
            ServiceProvider.Get <INavigationService>().OnDestroyActivity(Target, NavigationContext);
            base.OnDestroy(baseOnDestroy);
            ThreadPool.QueueUserWorkItem(state => AndroidToolkitExtensions.CleanupWeakReferences(true));
            AndroidToolkitExtensions.SetCurrentActivity(Target, true);
            Target.ClearBindings(false, true);
            OptionsItemSelected  = null;
            ActivityResult       = null;
            ConfigurationChanged = null;
            PostCreate           = null;
            BackPressing         = null;
            Created           = null;
            Started           = null;
            Paused            = null;
            SaveInstanceState = null;
            Stoped            = null;
            Restarted         = null;
            Resume            = null;
            Destroyed         = null;
        }