示例#1
0
 public static void Close()
 {
     if (Instance == null)
     {
         return;
     }
     Instance.Dismiss();
     Instance = null;
 }
示例#2
0
 public override void OnAttach(Context context)
 {
     Instance = this;
     base.OnAttach(context);
 }
示例#3
0
 public override void OnDetach()
 {
     base.OnDetach();
     Instance = null;
 }
示例#4
0
 public override void OnViewCreated(View view, Bundle savedInstanceState)
 {
     base.OnViewCreated(view, savedInstanceState);
     Instance = this;
     _stack.Align(NavigationType.Tab);
 }
示例#5
0
        /// <summary>
        /// Synchronize the rendered stack with the <see cref="Views"/> collection
        /// </summary>
        public void Align(NavigationType navType)
        {
            var view = _views.LastOrDefault();

            if (view == null)
            {
                return;
            }
            _views.RemoveAll(v => Device.Reflector.IsAssignableFrom(typeof(LoginLayer), v.ModelType) && !Equals(v, view));

            var monoView = view as IView;

            if (monoView?.Pair is Fragment)
            {
                view = DroidFactory.GetNativeObject <Fragment>(monoView, "view") as IMXView;
            }

            var fragment = view as Fragment;

            if (fragment == null)
            {
                _views.Remove(view);
            }
            else
            {
                #region Popover initialization

                FragmentManager popoverManager = null;
                if (Context.ActivePane == Pane.Popover)
                {
                    #region Popover teardown

                    if (view is VanityFragment)
                    {
                        DroidFactory.HideKeyboard(false);
                        PopoverActivity.Close(true);
                        PopoverFragment.Close();
                        return;
                    }

                    #endregion

                    if (PopoverFragment.Instance != null)
                    {
                        popoverManager = PopoverFragment.ChildFragmentManager;
                    }
                    else if (PopoverActivity.Instance == null)
                    {
                        IHistoryEntry frag;
                        if (Build.VERSION.SdkInt > BuildVersionCodes.JellyBean && iApp.Factory.LargeFormFactor &&
                            ((frag = view as IHistoryEntry ?? (view as IPairable)?.Pair as IHistoryEntry) == null ||
                             frag.PopoverPresentationStyle != PopoverPresentationStyle.FullScreen))
                        {
                            var name   = Java.Lang.Class.FromType(typeof(PopoverFragment)).Name;
                            var dialog = (DialogFragment)Fragment.Instantiate(DroidFactory.MainActivity, name);
                            dialog.Show(DroidFactory.MainActivity.FragmentManager, null);
                        }
                        else
                        {
                            DroidFactory.MainActivity.StartActivity(MXContainer.Resolve <Type>("Popover"));
                        }
                        return;
                    }
                }

                #endregion

                iApp.CurrentNavContext.ActivePane  = Context.ActivePane;
                iApp.CurrentNavContext.ActiveLayer = view.GetModel() as iLayer;
                (popoverManager ?? DroidFactory.MainActivity.FragmentManager)
                .BeginTransaction()
                .Replace(FragmentId, fragment)
                .CommitAllowingStateLoss();
            }

            #region Update screen titles

            if (Context.ActivePane == Pane.Popover)
            {
                PopoverFragment.UpdateTitle();
                var titleUpdater = PopoverActivity.Instance?.GetType().GetMethod("UpdateTitle", BindingFlags.Static | BindingFlags.NonPublic);
                titleUpdater?.Invoke(null, null);
            }
            else if (DroidFactory.Tabs == null || !DroidFactory.Tabs.TabItems.Any())
            {
                DroidFactory.RefreshTitles();
            }
            else
            {
                DroidFactory.Tabs.Title = monoView?.Title ?? iApp.Instance.Title;
            }

            #endregion
        }