Ejemplo n.º 1
0
        /// <summary>
        /// Extensibility point to allow augmentation when showing a child view
        /// </summary>
        protected virtual void OnFragmentViewShown(BaseFragment fragment, int viewIdOrIndex)
        {
            base.ExecuteMethod("OnFragmentViewShown", delegate()
            {
                if (fragment != null)
                {
                    switch (fragment.LayoutZone)
                    {
                    case LayoutZone.PrimaryMenu:
                    case LayoutZone.SecondaryMenu:
                        break;

                    default:
                        this.PrimaryTitle = fragment.Title;
                        break;
                    }
                    if (this.VisibleFragments.ContainsKey(viewIdOrIndex))
                    {
                        BaseFragment existing = this.VisibleFragments[viewIdOrIndex];
                        if (existing != fragment)
                        {
                            this.OnFragmentViewRemoved(fragment, viewIdOrIndex);
                        }
                    }
                    this.VisibleFragments[viewIdOrIndex] = fragment;
                    this.RaiseLayoutZoneChanged(fragment.LayoutZone, fragment);
                    fragment.OnAddedToMultiHost(this, fragment.LayoutZone);
                }
                if (!SyncTitleWithFragmentTitleDisabled)
                {
                    this.SupportActionBar.Title = OnActivityTitleUpdating(this.PrimaryTitle, fragment);
                }
                this.Drawer.CloseDrawers();
            });
        }
Ejemplo n.º 2
0
        protected virtual bool FragmentAllowsBackButton(BaseFragment fragment, string tag)
        {
            return(base.ExecuteFunction("FragmentAllowsBackButton", delegate()
            {
                if (!this.HasOnCreateCompleted)
                {
                    return false;
                }
                else
                {
                    if (fragment != null)
                    {
                        switch (fragment.LayoutZone)
                        {
                        case LayoutZone.PrimaryContent:
                            return true;

                        case LayoutZone.PrimaryMenu:
                        case LayoutZone.SecondaryMenu:
                        default:
                            return false;
                        }
                    }
                    return false;
                }
            }));
        }
Ejemplo n.º 3
0
        protected void RaiseLayoutZoneChanged(LayoutZone zone, BaseFragment fragment)
        {
            var handler = this.LayoutZoneChanged;

            if (handler != null)
            {
                handler(this, new LayoutZoneChangedArgs()
                {
                    Zone = zone, Host = this, Fragment = fragment
                });
            }
        }
Ejemplo n.º 4
0
        public static void StartActivity <TActivity, TRoute>(this BaseFragment fragment, TRoute route, bool animate = true, int enterAnimation = Resource.Animation.slide_in_from_right, int exitAnimation = Resource.Animation.slide_out_to_left)
        {
            Intent intent = new Intent(fragment.Activity.ApplicationContext, typeof(TActivity));

            if ((object)route != null)
            {
                intent.PutExtra(AndroidAssumptions.ROUTE_KEY, JsonConvert.SerializeObject(route));
            }

            fragment.StartActivity(intent);

            if (animate)
            {
                fragment.Activity.OverridePendingTransition(enterAnimation, exitAnimation);
            }
        }
Ejemplo n.º 5
0
        public virtual bool Show(BaseFragment fragment, string tag = "")
        {
            return(base.ExecuteFunction("Show", delegate()
            {
                int viewID = GetContainerViewId(fragment, tag);
                if (viewID == 0)
                {
                    throw new Exception(string.Format("View type did not return a proper view id for {0}", tag));
                }

                var transaction = this.SupportFragmentManager.BeginTransaction();
                transaction.Replace(viewID, fragment, tag);
                if (FragmentAllowsBackButton(fragment, tag))
                {
                    transaction.AddToBackStack(null);
                }
                transaction.Commit();
                this.OnFragmentViewShown(fragment, viewID);
                return true;
            }));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Gets the target view id from the requested data
        /// </summary>
        protected virtual int GetContainerViewId(BaseFragment fragment, string tag)
        {
            return(base.ExecuteFunction("GetContainerViewId", delegate()
            {
                if (fragment != null)
                {
                    switch (fragment.LayoutZone)
                    {
                    case LayoutZone.PrimaryContent:
                        return _viewIDCenter;

                    case LayoutZone.PrimaryMenu:
                        return _viewIDLeft;

                    case LayoutZone.SecondaryMenu:
                        return _viewIDRight;

                    default:
                        break;
                    }
                }
                return _viewIDCenter;
            }));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Extensibility point
 /// </summary>
 protected virtual string OnActivityTitleUpdating(string newTitle, BaseFragment fragment)
 {
     return(newTitle);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Extensibility point to allow augmentation when showing a child view
 /// </summary>
 protected virtual void OnFragmentViewRemoved(BaseFragment fragment, int viewIdOrIndex)
 {
 }