예제 #1
0
        public override void OnDestroy(Action baseOnDestroy)
        {
            if (Tracer.TraceInformation)
            {
                Tracer.Info("OnDestroy activity({0})", Target);
            }
            ServiceProvider.EventAggregator.Unsubscribe(this);
            var handler = Destroyed;

            if (handler != null)
            {
                handler(Target, EventArgs.Empty);
            }
            _view.RemoveFromParent();
            if (_attachedViews == null)
            {
                _view.ClearBindingsRecursively(true, true);
            }
            else
            {
                CleanupItems();
            }
            _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;
            }
            base.OnDestroy(baseOnDestroy);
            PlatformExtensions.SetCurrentActivity(Target, true);
            Target.ClearBindings(false, true);
            OptionsItemSelected  = null;
            ConfigurationChanged = null;
            PostCreate           = null;
            BackPressing         = null;
            Created           = null;
            Started           = null;
            Paused            = null;
            SaveInstanceState = null;
            Stoped            = null;
            Restarted         = null;
            Resume            = null;
            Destroyed         = null;
        }
 public virtual MenuInflater GetMenuInflater(MenuInflater baseMenuInflater)
 {
     if (_menuInflater == null)
     {
         _menuInflater = PlatformExtensions.MenuInflaterFactory(Target, MugenMvvmToolkit.Models.DataContext.Empty);
     }
     if (_menuInflater != null)
     {
         _menuInflater.NestedMenuInflater = baseMenuInflater;
     }
     return(_menuInflater ?? baseMenuInflater);
 }
        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, PlatformExtensions.AggressiveViewCleanup);
            _view.RemoveFromParent();
            _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;
            }
            base.OnDestroy(baseOnDestroy);
            ThreadPool.QueueUserWorkItem(state => PlatformExtensions.CleanupWeakReferences(true));
            PlatformExtensions.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;
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:System.Object" /> class.
 /// </summary>
 public MvvmActivityMediator([NotNull] Activity target)
     : base(target)
 {
     _menuInflater = new BindableMenuInflater(target);
 }