protected virtual bool CloseFragments()
 {
     try
     {
         CurrentFragmentManager.PopBackStackImmediate();
     }
     catch (System.Exception ex)
     {
         MvxLog.Instance.Trace("Cannot close any fragments", ex);
     }
     return(true);
 }
        public override Task <bool> ChangePresentation(MvxPresentationHint hint)
        {
            if (hint is MvxPagePresentationHint pagePresentationHint)
            {
                var request   = new MvxViewModelRequest(pagePresentationHint.ViewModel);
                var attribute = GetPresentationAttribute(request);
                if (attribute is MvxBottomNavigationViewPresentationAttribute bottomNavigationAttribute)
                {
                    MvxBottomNavigationView bottomNavigationView = FindMvxBottomNavigationViewInFragmentPresentation(bottomNavigationAttribute);
                    if (bottomNavigationView != null)
                    {
                        var menuItem = bottomNavigationView.FindItemByViewModel(pagePresentationHint.ViewModel);

                        if (menuItem == null)
                        {
                            //MvvmCross.MvxAndroidLog.Instance.Trace("Did not find a menu item which corresponds to {0}, skipping presentation change...",                                 pagePresentationHint.ViewModel);

                            return(Task.FromResult(false));
                        }

                        // If we are deeper in our back stack, we want to make sure that we remove the stack
                        if (CurrentFragmentManager.BackStackEntryCount > 0)
                        {
                            var name = CurrentFragmentManager.GetBackStackEntryAt(0).Name;
                            CurrentFragmentManager.PopBackStackImmediate(name, 1);
                        }

                        PerformShowFragmentTransaction(CurrentFragmentManager, bottomNavigationAttribute, new MvxViewModelRequest(pagePresentationHint.ViewModel));

                        var item = bottomNavigationView.FindItemByViewModel(pagePresentationHint.ViewModel);

                        item.SetChecked(true);

                        return(Task.FromResult(true));
                    }
                }
            }
            return(base.ChangePresentation(hint));
        }