Пример #1
0
        private void ShowLogoutDialog()
        {
            builder     = new Android.App.AlertDialog.Builder(mainActivity);
            alertDialog = builder.Create();
            alertDialog.SetMessage("Do you want to log out?");
            alertDialog.SetButton("Yes", (s1, e1) =>
            {
                var auth = sessionManager.GetFirebaseAuth();
                editor   = preferences.Edit();
                LoginManager.Instance.LogOut();
                auth.SignOut();
                editor.Clear();
                editor.Commit();

                var intent = new Intent(Application.Context, typeof(OnboardingActivity));
                intent.SetFlags(ActivityFlags.ClearTask | ActivityFlags.ClearTop | ActivityFlags.NewTask);
                StartActivity(intent);
                mainActivity.Finish();
            });

            alertDialog.SetButton2("No", (s2, e2) =>
            {
                alertDialog.Dismiss();
            });
            alertDialog.Show();
        }
Пример #2
0
        public void OnThemeChanged(ThemeManager.Themes theme)
        {
            //Some attempts to restart activity without loosing Fragments inside it.
            //currently all options restarts the app from Main DashboardPage.

            /*
             * var f = GetVisibleFragment();
             * f.Activity.Recreate();
             */

            /*
             * Intent intent = new Intent(f.Context, typeof(MainActivity));
             * intent.SetFlags(ActivityFlags.ClearTask);
             * f.Context.StartActivity(intent);
             */

            /*
             * Android.Support.V4.App.FragmentTransaction ft = MainActivity.Instance.SupportFragmentManager.BeginTransaction();
             * ft.Detach(f);
             * ft.Attach(f);
             * ft.Commit();
             */

            MainActivity activity = MainActivity.Instance;
            var          intent   = MainActivity.Instance.Intent;

            activity.Finish();
            activity.StartActivity(intent);


            /*Bundle savedInstanceState = new Bundle();
             * ////this is important to save all your open states/fragment states
             * MainActivity.Instance.OnSaveInstanceState(savedInstanceState);
             * MainActivity.Instance.Recreate();
             * MainActivity.Instance.OnCreate(savedInstanceState, null);
             */

            /*Intent i = MainActivity.Instance.Intent;
             * MainActivity.Instance.OverridePendingTransition(0, 0);
             * i.AddFlags(ActivityFlags.NoAnimation);
             * MainActivity.Instance.Finish();
             * //restart the activity without animation
             * MainActivity.Instance.OverridePendingTransition(0, 0);
             * MainActivity.Instance.StartActivity(i);*/
        }