コード例 #1
0
        public virtual void MoveBack()
        {
            if (CanPop())
            {
                var cachedFragment = FragmentsBackStack?.LastOrDefault();
                if (cachedFragment != null)
                {
                    var fragmentManager = CurrentFragmentManager;

                    var fragmentTransaction = fragmentManager.BeginTransaction();

                    fragmentTransaction.DisallowAddToBackStack();

                    PopFragment(fragmentManager, fragmentTransaction, DeqeueFragmentAttributeIfExist(cachedFragment.Key), cachedFragment.Key, true);

                    var newLastCachedFragment = FragmentsBackStack?.LastOrDefault();
                    if (newLastCachedFragment != null)
                    {
                        PushFragment(fragmentManager, fragmentTransaction, null, null, newLastCachedFragment.ViewModel, newLastCachedFragment.Key);
                    }

                    fragmentTransaction.CommitNow();
                }
            }
            else
            {
                if ((new Java.Util.Date().Time - LastBackClick.Time) / 1000 < 3)
                {
                    CurrentActivity.FinishAffinity();
                    Process.KillProcess(Process.MyPid());
                }
                else
                {
                    LastBackClick = new Java.Util.Date();
                    (CurrentActivity as ICommonActivity)?.ShowToast("Для выхода из приложения нажмите кнопку повторно");
                }
            }
        }