Esempio n. 1
0
 public override void FinishUpdate(ViewGroup container)
 {
     if (_currentTransaction == null || _fragmentManager.IsDestroyed)
     {
         return;
     }
     _currentTransaction.CommitAllowingStateLoss();
     _currentTransaction = null;
     _fragmentManager.ExecutePendingTransactions();
 }
Esempio n. 2
0
        private static void OnTabChanged(Action <TabHostItemsSourceGenerator, object, object, bool, bool> baseAction, TabHostItemsSourceGenerator generator, object oldValue, object newValue, bool clearOldValue, bool setNewValue)
        {
            FragmentManager     fragmentManager = null;
            FragmentTransaction ft = null;

            if (clearOldValue)
            {
                var fragment = oldValue as Fragment;
                if (fragment == null)
                {
                    baseAction(generator, oldValue, newValue, true, false);
                }
                else if (fragment.IsAlive())
                {
                    fragmentManager = generator.TabHost.GetFragmentManager();
                    if (fragmentManager != null)
                    {
                        ft = fragmentManager.BeginTransaction().Detach(fragment);
                    }
                }
            }
            if (setNewValue)
            {
                var fragment = newValue as Fragment;
                if (fragment == null)
                {
                    baseAction(generator, oldValue, newValue, false, true);
                }
                else
                {
                    if (ft == null)
                    {
                        fragmentManager = generator.TabHost.GetFragmentManager();
                        if (fragmentManager != null)
                        {
                            ft = fragmentManager.BeginTransaction();
                        }
                    }
                    if (ft != null)
                    {
                        ft = fragment.IsDetached
                            ? ft.Attach(fragment)
                            : ft.Replace(generator.TabHost.TabContentView.Id, fragment);
                    }
                }
            }
            if (ft != null)
            {
                ft.CommitAllowingStateLoss();
            }
            if (fragmentManager != null)
            {
                fragmentManager.ExecutePendingTransactions();
            }
        }
Esempio n. 3
0
        public override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);

            Android.Support.V4.App.FragmentManager fm = ChildFragmentManager;
            SupportMapFragment mapFragment            = (SupportMapFragment)fm.FindFragmentByTag("mapFragment");

            if (mapFragment == null)
            {
                mapFragment = new SupportMapFragment();
                Android.Support.V4.App.FragmentTransaction ft = fm.BeginTransaction();
                ft.Add(Resource.Id.notam_mapDialog_mapContainer, mapFragment, "mapFragment");
                ft.Commit();
                fm.ExecutePendingTransactions();
            }

            mapFragment.GetMapAsync(this);

            _buttonContainerBottom.AddView(_dismissButton);
        }
Esempio n. 4
0
        public override void CommitPageTransaction(NavigationFragmentBase page)
        {
            try
            {
                var transaction = _fragmentManager.BeginTransaction();
                _interceptTransaction?.Invoke(transaction);
                transaction.Replace(_rootFrame.Id, page)
                .DisallowAddToBackStack();
                transaction.CommitNowAllowingStateLoss();

                _fragmentManager.ExecutePendingTransactions();
            }
            catch (Exception e)
            {
                Console.WriteLine($"There was an issue navigating to idndicated page, please ensure everyhting is set-up correctly. Exception: {e}");
                if (ThrowOnNavigationException)
                {
                    throw e;
                }
            }
        }
        void RemovePage(Page page)
        {
            Fragment fragment = GetPageFragment(page);

            if (fragment == null)
            {
                return;
            }

            // Go ahead and take care of the fragment bookkeeping for the page being removed
            FragmentTransaction transaction = FragmentManager.BeginTransaction();

            transaction.DisallowAddToBackStack();
            transaction.Remove(fragment);
            transaction.CommitAllowingStateLoss();
            FragmentManager.ExecutePendingTransactions();

            // And remove the fragment from our own stack
            _fragmentStack.Remove(fragment);

            // Now handle all the XF removal/cleanup
            IVisualElementRenderer rendererToRemove = Android.Platform.GetRenderer(page);

            if (rendererToRemove != null)
            {
                var containerToRemove = (PageContainer)rendererToRemove.View.Parent;
                rendererToRemove.View?.RemoveFromParent();
                rendererToRemove?.Dispose();
                containerToRemove?.RemoveFromParent();
                containerToRemove?.Dispose();
            }

            Device.StartTimer(TimeSpan.FromMilliseconds(10), () =>
            {
                UpdateToolbar();
                return(false);
            });
        }
Esempio n. 6
0
        protected override void ShowView(IWindowView view, bool isDialog, IDataContext context)
        {
            view.Cancelable = !isDialog;
            FragmentManager fragmentManager = null;
            var             parentViewModel = ViewModel.GetParentViewModel();

            if (parentViewModel != null)
            {
                var fragment = parentViewModel.Settings.Metadata.GetData(ViewModelConstants.View) as Fragment;
                if (fragment != null)
                {
                    fragmentManager = fragment.ChildFragmentManager;
                }
            }
            if (fragmentManager == null)
            {
                var activity = PlatformExtensions.CurrentActivity;
                Should.NotBeNull(activity, "CurrentActivity");
                fragmentManager = activity.GetFragmentManager();
            }
            view.Show(fragmentManager, Guid.NewGuid().ToString("n"));
            fragmentManager.ExecutePendingTransactions();
        }
Esempio n. 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_fragment);

            TextView outputTextView = FindViewById <TextView>(Resource.Id.output);

            mPlayerFragment = JWPlayerSupportFragment.NewInstance(new PlayerConfig.Builder()
                                                                  .File("http://playertest.longtailvideo.com/adaptive/bipbop/gear4/prog_index.m3u8")
                                                                  .Build());

            Android.Support.V4.App.FragmentManager     fm = this.SupportFragmentManager;
            Android.Support.V4.App.FragmentTransaction ft = fm.BeginTransaction();
            ft.Add(Resource.Id.fragment_container, mPlayerFragment);
            ft.Commit();
            fm.ExecutePendingTransactions();

            mPlayerView = mPlayerFragment.Player;

            new KeepScreenOnHandler(mPlayerView, Window);

            mEventHandler = new JWEventHandler(mPlayerView, outputTextView);
        }
Esempio n. 8
0
        Task <bool> SwitchContentAsync(Page view, bool animated, bool removed = false, bool popToRoot = false)
        {
            var             activity  = (FormsAppCompatActivity)Context;
            var             tcs       = new TaskCompletionSource <bool>();
            Fragment        fragment  = FragmentContainer.CreateInstance(view);
            FragmentManager fm        = FragmentManager;
            List <Fragment> fragments = _fragmentStack;

            Current = view;

            FragmentTransaction transaction = fm.BeginTransaction();

            if (animated)
            {
                SetupPageTransition(transaction, !removed);
            }

            transaction.DisallowAddToBackStack();

            if (fragments.Count == 0)
            {
                transaction.Add(Id, fragment);
                fragments.Add(fragment);
            }
            else
            {
                if (removed)
                {
                    // pop only one page, or pop everything to the root
                    var popPage = true;
                    while (fragments.Count > 1 && popPage)
                    {
                        Fragment currentToRemove = fragments.Last();
                        fragments.RemoveAt(fragments.Count - 1);
                        transaction.Remove(currentToRemove);
                        popPage = popToRoot;
                    }

                    Fragment toShow = fragments.Last();
                    // Execute pending transactions so that we can be sure the fragment list is accurate.
                    fm.ExecutePendingTransactions();
                    if (fm.Fragments.Contains(toShow))
                    {
                        transaction.Show(toShow);
                    }
                    else
                    {
                        transaction.Add(Id, toShow);
                    }
                }
                else
                {
                    // push
                    Fragment currentToHide = fragments.Last();
                    transaction.Hide(currentToHide);
                    transaction.Add(Id, fragment);
                    fragments.Add(fragment);
                }
            }
            transaction.Commit();

            // The fragment transitions don't really SUPPORT telling you when they end
            // There are some hacks you can do, but they actually are worse than just doing this:

            if (animated)
            {
                if (!removed)
                {
                    UpdateToolbar();
                    if (_drawerToggle != null && Element.StackDepth == 2)
                    {
                        AnimateArrowIn();
                    }
                }
                else if (_drawerToggle != null && Element.StackDepth == 2)
                {
                    AnimateArrowOut();
                }

                Device.StartTimer(TimeSpan.FromMilliseconds(200), () =>
                {
                    tcs.TrySetResult(true);
                    fragment.UserVisibleHint = true;
                    if (removed)
                    {
                        UpdateToolbar();
                    }
                    return(false);
                });
            }
            else
            {
                Device.StartTimer(TimeSpan.FromMilliseconds(1), () =>
                {
                    tcs.TrySetResult(true);
                    fragment.UserVisibleHint = true;
                    UpdateToolbar();
                    return(false);
                });
            }

            Context.HideKeyboard(this);

            // 200ms is how long the animations are, and they are "reversible" in the sense that starting another one slightly before it's done is fine

            return(tcs.Task);
        }
Esempio n. 9
0
        protected override void Dispose(bool disposing)
        {
            if (disposing && !_disposed)
            {
                _disposed = true;

                var activity = (FormsAppCompatActivity)Context;

                // API only exists on newer android YAY
                if ((int)Build.VERSION.SdkInt >= 17)
                {
                    if (!activity.IsDestroyed)
                    {
                        FragmentManager     fm    = FragmentManager;
                        FragmentTransaction trans = fm.BeginTransaction();
                        foreach (Fragment fragment in _fragmentStack)
                        {
                            trans.Remove(fragment);
                        }
                        trans.CommitAllowingStateLoss();
                        fm.ExecutePendingTransactions();
                    }
                }

                if (Element != null)
                {
                    for (var i = 0; i < Element.InternalChildren.Count; i++)
                    {
                        var child = Element.InternalChildren[i] as VisualElement;
                        if (child == null)
                        {
                            continue;
                        }
                        IVisualElementRenderer renderer = Android.Platform.GetRenderer(child);
                        renderer?.Dispose();
                    }
                    Element.PushRequested             -= OnPushed;
                    Element.PopRequested              -= OnPopped;
                    Element.PopToRootRequested        -= OnPoppedToRoot;
                    Element.InsertPageBeforeRequested -= OnInsertPageBeforeRequested;
                    Element.RemovePageRequested       -= OnRemovePageRequested;
                    Element.SendDisappearing();
                }

                if (_toolbarTracker != null)
                {
                    _toolbarTracker.CollectionChanged -= ToolbarTrackerOnCollectionChanged;
                    _toolbarTracker.Target             = null;
                    _toolbarTracker = null;
                }

                if (_toolbar != null)
                {
                    _toolbar.NavigationClick -= BarOnNavigationClick;
                    _toolbar.Dispose();
                    _toolbar = null;
                }

                Current = null;

                Device.Info.PropertyChanged -= DeviceInfoPropertyChanged;
            }

            base.Dispose(disposing);
        }
        Task <bool> SwitchContentAsync(Page page, bool animated, bool removed = false, bool popToRoot = false)
        {
            var      tcs      = new TaskCompletionSource <bool>();
            Fragment fragment = GetFragment(page, removed, popToRoot);

#if DEBUG
            // Enables logging of moveToState operations to logcat
            FragmentManager.EnableDebugLogging(true);
#endif

            Current = page;

            ((Platform)Element.Platform).NavAnimationInProgress = true;
            FragmentTransaction transaction = FragmentManager.BeginTransaction();

            if (animated)
            {
                SetupPageTransition(transaction, !removed);
            }

            if (_fragmentStack.Count == 0)
            {
                transaction.Add(Id, fragment);
                _fragmentStack.Add(fragment);
            }
            else
            {
                if (removed)
                {
                    // pop only one page, or pop everything to the root
                    var popPage = true;
                    while (_fragmentStack.Count > 1 && popPage)
                    {
                        Fragment currentToRemove = _fragmentStack.Last();
                        _fragmentStack.RemoveAt(_fragmentStack.Count - 1);
                        transaction.Remove(currentToRemove);
                        popPage = popToRoot;
                    }

                    Fragment toShow = _fragmentStack.Last();
                    // Execute pending transactions so that we can be sure the fragment list is accurate.
                    FragmentManager.ExecutePendingTransactions();
                    if (FragmentManager.Fragments.Contains(toShow))
                    {
                        transaction.Show(toShow);
                    }
                    else
                    {
                        transaction.Add(Id, toShow);
                    }
                }
                else
                {
                    // push
                    Fragment currentToHide = _fragmentStack.Last();
                    transaction.Hide(currentToHide);
                    transaction.Add(Id, fragment);
                    _fragmentStack.Add(fragment);
                }
            }

            // We don't currently support fragment restoration, so we don't need to worry about
            // whether the commit loses state
            transaction.CommitAllowingStateLoss();

            // The fragment transitions don't really SUPPORT telling you when they end
            // There are some hacks you can do, but they actually are worse than just doing this:

            if (animated)
            {
                if (!removed)
                {
                    UpdateToolbar();
                    if (_drawerToggle != null && ((INavigationPageController)Element).StackDepth == 2)
                    {
                        AnimateArrowIn();
                    }
                }
                else if (_drawerToggle != null && ((INavigationPageController)Element).StackDepth == 2)
                {
                    AnimateArrowOut();
                }

                Device.StartTimer(TimeSpan.FromMilliseconds(TransitionDuration), () =>
                {
                    tcs.TrySetResult(true);
                    fragment.UserVisibleHint = true;
                    if (removed)
                    {
                        UpdateToolbar();
                    }

                    return(false);
                });
            }
            else
            {
                Device.StartTimer(TimeSpan.FromMilliseconds(1), () =>
                {
                    tcs.TrySetResult(true);
                    fragment.UserVisibleHint = true;
                    UpdateToolbar();

                    return(false);
                });
            }

            Context.HideKeyboard(this);
            ((Platform)Element.Platform).NavAnimationInProgress = false;

            // TransitionDuration is how long the built-in animations are, and they are "reversible" in the sense that starting another one slightly before it's done is fine

            return(tcs.Task);
        }
        protected override void Dispose(bool disposing)
        {
            if (disposing && !_disposed)
            {
                _disposed = true;


                if (_toolbarTracker != null)
                {
                    _toolbarTracker.CollectionChanged -= ToolbarTrackerOnCollectionChanged;
                    _toolbarTracker.Target             = null;
                    _toolbarTracker = null;
                }

                if (_toolbar != null)
                {
                    _toolbar.SetNavigationOnClickListener(null);
                    _toolbar.Dispose();
                    _toolbar = null;
                }

                if (_drawerLayout != null && _drawerListener != null)
                {
                    _drawerLayout.RemoveDrawerListener(_drawerListener);
                }

                if (_drawerListener != null)
                {
                    _drawerListener.Dispose();
                    _drawerListener = null;
                }

                if (_drawerToggle != null)
                {
                    _drawerToggle.Dispose();
                    _drawerToggle = null;
                }

                if (_backgroundDrawable != null)
                {
                    _backgroundDrawable.Dispose();
                    _backgroundDrawable = null;
                }

                Current = null;

                // We dispose the child renderers after cleaning up everything related to DrawerLayout in case
                // one of the children is a MasterDetailPage (which may dispose of the DrawerLayout).
                if (Element != null)
                {
                    foreach (Element element in PageController.InternalChildren)
                    {
                        var child = element as VisualElement;
                        if (child == null)
                        {
                            continue;
                        }

                        IVisualElementRenderer renderer = Android.Platform.GetRenderer(child);
                        renderer?.Dispose();
                    }

                    var navController = (INavigationPageController)Element;

                    navController.PushRequested             -= OnPushed;
                    navController.PopRequested              -= OnPopped;
                    navController.PopToRootRequested        -= OnPoppedToRoot;
                    navController.InsertPageBeforeRequested -= OnInsertPageBeforeRequested;
                    navController.RemovePageRequested       -= OnRemovePageRequested;
                }

                Device.Info.PropertyChanged -= DeviceInfoPropertyChanged;

                // API only exists on newer android YAY
                if ((int)Build.VERSION.SdkInt >= 17)
                {
                    FragmentManager fm = FragmentManager;

                    if (!fm.IsDestroyed)
                    {
                        FragmentTransaction trans = fm.BeginTransaction();
                        foreach (Fragment fragment in _fragmentStack)
                        {
                            trans.Remove(fragment);
                        }
                        trans.CommitAllowingStateLoss();
                        fm.ExecutePendingTransactions();
                    }
                }
            }

            base.Dispose(disposing);
        }
        public bool SetContent(object view, object content)
        {
            var targetView = view as ViewGroup;

            if (targetView == null)
            {
                return(false);
            }
            if (content == null)
            {
                FragmentManager fragmentManager = targetView.GetFragmentManager();
                Fragment        oldFragment     = fragmentManager?.FindFragmentById(targetView.Id);
                if (oldFragment != null && !fragmentManager.IsDestroyed)
                {
                    BeginTransaction(fragmentManager, targetView, null)
                    .Remove(oldFragment)
                    .CommitAllowingStateLoss();
                    fragmentManager.ExecutePendingTransactions();
                    return(true);
                }
                return(false);
            }
            var fragment = content as Fragment;

            if (fragment == null)
            {
                return(false);
            }
            AndroidToolkitExtensions.ValidateViewIdFragment(targetView, fragment);
            FragmentManager manager = targetView.GetFragmentManager();

            if (manager == null)
            {
                return(false);
            }
            FragmentTransaction transaction = BeginTransaction(manager, targetView, fragment);
            var addToBackStack = targetView.GetBindingMemberValue(AttachedMembers.ViewGroup.AddToBackStack);

            if (addToBackStack && fragment.Arguments != null)
            {
                addToBackStack = !fragment.Arguments.GetBoolean(AddedToBackStackKey);
            }

            if (fragment.IsDetached)
            {
                transaction.Attach(fragment);
            }
            else
            {
                if (addToBackStack)
                {
                    if (fragment.Arguments == null)
                    {
                        fragment.Arguments = new Bundle();
                    }
                    fragment.Arguments.PutBoolean(AddedToBackStackKey, true);
                }
                transaction.Replace(targetView.Id, fragment);
            }
            if (addToBackStack)
            {
                transaction.AddToBackStack(null);
            }

            transaction.Commit();
            manager.ExecutePendingTransactions();
            return(true);
        }
Esempio n. 13
0
        Task <bool> SwitchContentAsync(Page page, bool animated, bool removed = false, bool popToRoot = false)
        {
            var      tcs      = new TaskCompletionSource <bool>();
            Fragment fragment = GetFragment(page, removed, popToRoot);

#if DEBUG
            // Enables logging of moveToState operations to logcat
            FragmentManager.EnableDebugLogging(true);
#endif

            Current?.SendDisappearing();
            Current = page;

            ((Platform)Element.Platform).NavAnimationInProgress = true;
            FragmentTransaction transaction = FragmentManager.BeginTransaction();

            if (animated)
            {
                SetupPageTransition(transaction, !removed);
            }

            var fragmentsToRemove = new List <Fragment>();

            if (_fragmentStack.Count == 0)
            {
                transaction.Add(Id, fragment);
                _fragmentStack.Add(fragment);
            }
            else
            {
                if (removed)
                {
                    // pop only one page, or pop everything to the root
                    var popPage = true;
                    while (_fragmentStack.Count > 1 && popPage)
                    {
                        Fragment currentToRemove = _fragmentStack.Last();
                        _fragmentStack.RemoveAt(_fragmentStack.Count - 1);
                        transaction.Hide(currentToRemove);
                        fragmentsToRemove.Add(currentToRemove);
                        popPage = popToRoot;
                    }

                    Fragment toShow = _fragmentStack.Last();
                    // Execute pending transactions so that we can be sure the fragment list is accurate.
                    FragmentManager.ExecutePendingTransactions();
                    if (FragmentManager.Fragments.Contains(toShow))
                    {
                        transaction.Show(toShow);
                    }
                    else
                    {
                        transaction.Add(Id, toShow);
                    }
                }
                else
                {
                    // push
                    Fragment currentToHide = _fragmentStack.Last();
                    transaction.Hide(currentToHide);
                    transaction.Add(Id, fragment);
                    _fragmentStack.Add(fragment);
                }
            }

            // We don't currently support fragment restoration, so we don't need to worry about
            // whether the commit loses state
            transaction.CommitAllowingStateLoss();

            // The fragment transitions don't really SUPPORT telling you when they end
            // There are some hacks you can do, but they actually are worse than just doing this:

            if (animated)
            {
                if (!removed)
                {
                    UpdateToolbar();
                    if (_drawerToggle != null && ((INavigationPageController)Element).StackDepth == 2)
                    {
                        AnimateArrowIn();
                    }
                }
                else if (_drawerToggle != null && ((INavigationPageController)Element).StackDepth == 2)
                {
                    AnimateArrowOut();
                }

                AddTransitionTimer(tcs, fragment, FragmentManager, fragmentsToRemove, TransitionDuration, removed);
            }
            else
            {
                AddTransitionTimer(tcs, fragment, FragmentManager, fragmentsToRemove, 1, true);
            }

            Context.HideKeyboard(this);
            ((Platform)Element.Platform).NavAnimationInProgress = false;

            return(tcs.Task);
        }
Esempio n. 14
0
 public static bool ExecutePendingTransactionsEx(this FragmentManager fragmentManager)
 {
     return(fragmentManager.ExecutePendingTransactions());
 }
Esempio n. 15
0
        private Task <bool> SwitchContentAsync(Page page, bool animated, bool removed = false, bool popToRoot = false)
        {
            var             tcs             = new TaskCompletionSource <bool>();
            Fragment        fragment        = _hepler.GetFragment(page, removed, popToRoot);
            List <Fragment> fragments       = _hepler.FragmentStack;
            FragmentManager fm              = _hepler.FragmentManager;
            var             currentPade     = (removed ? _hepler.CurrentPage : page);
            var             currentAnimPade = currentPade as IAnimationPage;
            var             animation       = AnimationNavigationPage.GetAnimation(currentPade, animated);

            _hepler.CurrentPage = page;
            _hepler.SetNavAnimationInProgress(Element, true);
            FragmentTransaction transaction = fm.BeginTransaction();

            AnimationHelper.SetupTransition(transaction, animation, !removed, animated);
            if (animation.Type != AnimationType.Empty && animation.Duration != AnimationDuration.Zero)
            {
                currentAnimPade?.OnAnimationStarted(removed);
            }
            transaction.DisallowAddToBackStack();
            if (fragments.Count == 0)
            {
                transaction.Add(Id, fragment);
                fragments.Add(fragment);
            }
            else
            {
                if (removed)
                {
                    // pop only one page, or pop everything to the root
                    var popPage           = true;
                    var fragmentsToRemove = new List <Fragment>();
                    while (fragments.Count > 1 && popPage)
                    {
                        var currentToRemove = fragments.Last();
                        fragments.RemoveAt(fragments.Count - 1);
                        fragmentsToRemove.Add(currentToRemove);
                        transaction.Hide(currentToRemove);
                        popPage = popToRoot;
                    }
                    // we need it for poping pages with animation
                    RemoveFragments(fragmentsToRemove);
                    Fragment toShow = fragments.Last();
                    // Execute pending transactions so that we can be sure the fragment list is accurate.
                    fm.ExecutePendingTransactions();
                    if (fm.Fragments.Contains(toShow))
                    {
                        transaction.Show(toShow);
                    }
                    else
                    {
                        transaction.Add(Id, toShow);
                    }
                }
                else
                {
                    // push
                    Fragment currentToHide = fragments.Last();
                    transaction.Hide(currentToHide);
                    transaction.Add(Id, fragment);
                    fragments.Add(fragment);
                }
            }
            // We don't currently support fragment restoration, so we don't need to worry about
            // whether the commit loses state
            transaction.CommitAllowingStateLoss();

            // The fragment transitions don't really SUPPORT telling you when they end
            // There are some hacks you can do, but they actually are worse than just doing this:
            if (animated)
            {
                if (!removed)
                {
                    _hepler.UpdateToolbar();
                    if (_hepler.DrawerToggle != null && ((INavigationPageController)Element).StackDepth == 2)
                    {
                        _hepler.AnimateArrowIn();
                    }
                }
                else if (_hepler.DrawerToggle != null && ((INavigationPageController)Element).StackDepth == 2)
                {
                    _hepler.AnimateArrowOut();
                }
                Device.StartTimer(TimeSpan.FromMilliseconds(TransitionDuration), () =>
                {
                    tcs.TrySetResult(true);
                    fragment.UserVisibleHint = true;
                    if (removed)
                    {
                        _hepler.UpdateToolbar();
                    }
                    return(false);
                });
            }
            else
            {
                Device.StartTimer(TimeSpan.FromMilliseconds(1), () =>
                {
                    tcs.TrySetResult(true);
                    fragment.UserVisibleHint = true;
                    _hepler.UpdateToolbar();
                    return(false);
                });
            }
            Context.HideKeyboard(this);

            if (animation.Type != AnimationType.Empty && animation.Duration != AnimationDuration.Zero && currentAnimPade != null)
            {
                Device.StartTimer(TimeSpan.FromMilliseconds(GetAnimationDuration(currentAnimPade.PageAnimation)), delegate
                {
                    currentAnimPade.OnAnimationFinished(removed);
                    return(false);
                });
            }
            _hepler.SetNavAnimationInProgress(Element, false);
            return(tcs.Task);
        }