Ejemplo n.º 1
0
 public override bool OnOptionsItemSelected(IMenuItem item)
 {
     switch (item.ItemId)
     {
     case Resource.Id.home:
     {
         var upIntent = NavUtils.GetParentActivityIntent(this);
         if (NavUtils.ShouldUpRecreateTask(this, upIntent))
         {
             // This activity is NOT part of this app's task, so create a new task
             // when navigating up, with a synthesized back stack.
             Android.Support.V4.App.TaskStackBuilder.Create(this).
             AddNextIntentWithParentStack(upIntent).StartActivities();
         }
         else
         {
             // This activity is part of this app's task, so simply
             // navigate up to the logical parent activity.
             NavUtils.NavigateUpTo(this, upIntent);
         }
     }
         return(true);
     }
     return(base.OnOptionsItemSelected(item));
 }
        public static void NavigateUp(Activity activity, Bundle extras = null)
        {
            Intent upIntent = NavUtils.GetParentActivityIntent(activity);

            if (upIntent != null)
            {
                if (extras != null)
                {
                    upIntent.PutExtras(extras);
                }

                if (NavUtils.ShouldUpRecreateTask(activity, upIntent))
                {
                    TaskStackBuilder.Create(activity)
                    .AddNextIntentWithParentStack(upIntent)
                    .StartActivities();
                }
                else
                {
                    upIntent.AddFlags(ActivityFlags.ClearTop);
                    activity.StartActivity(upIntent);
                }
            }
            activity.Finish();
        }
Ejemplo n.º 3
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                // Some small additions to handle "up" navigation correctly
                var upIntent = NavUtils.GetParentActivityIntent(Activity);
                upIntent.AddFlags(ActivityFlags.ClearTask);


                // Check if up activity needs to be created (usually when
                // detail screen is opened from a notification or from the
                // Wearable app
                if (NavUtils.ShouldUpRecreateTask(Activity, upIntent) ||
                    Activity.IsTaskRoot)
                {
                    // Synthesize parent stack
                    Android.App.TaskStackBuilder.Create(Activity)
                    .AddNextIntentWithParentStack(upIntent)
                    .StartActivities();
                }

                if (Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
                {
                    // On Lollipop+ we finish so to run the nice animation
                    Activity.FinishAfterTransition();
                    return(true);
                }

                // Otherwise let the system handle navigating "up"
                return(false);
            }
            return(base.OnOptionsItemSelected(item));
        }
Ejemplo n.º 4
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item.ItemId != Android.Resource.Id.Home)
            {
                return(base.OnOptionsItemSelected(item));
            }
            cancellationtokenSource?.Cancel();
            var intent = NavUtils.GetParentActivityIntent(this);

            intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
            NavUtils.NavigateUpTo(this, intent);
            return(true);
        }
Ejemplo n.º 5
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item.ItemId != Android.Resource.Id.Home)
            {
                return(base.OnOptionsItemSelected(item));
            }
            var intent = NavUtils.GetParentActivityIntent(this);

            if (goal != null)
            {
                Preferences.HeroImageGoalId = goal.Id.ToString();
            }

            intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
            NavUtils.NavigateUpTo(this, intent);

            OverridePendingTransition(Resource.Animation.abc_fade_in, Resource.Animation.abc_fade_out);
            return(true);
        }
Ejemplo n.º 6
0
 public override bool OnSupportNavigateUp()
 {
     Android.Content.Intent upIntent = NavUtils.GetParentActivityIntent(this);
     if (upIntent == null)
     {
         NavUtils.NavigateUpFromSameTask(this);
         return(true);
     }
     if (NavUtils.ShouldUpRecreateTask(this, upIntent))
     {
         // this activity is not part of this app's task
         global::Android.Support.V4.App.TaskStackBuilder.Create(this).AddNextIntentWithParentStack(upIntent).StartActivities();
     }
     else
     {
         // this activity is part of this app's task
         NavUtils.NavigateUpTo(this, upIntent);
     }
     return(true);
 }
Ejemplo n.º 7
0
        private async void OnSaveGoal(object sender, EventArgs e)
        {
            StartSpinner();

            var saved = await TrySave();

            StopSpinner();

            if (!saved)
            {
                return;
            }

            var intent = NavUtils.GetParentActivityIntent(this);

            intent.PutExtra(IntentExtra.GoalAdded, true);
            intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);
            NavUtils.NavigateUpTo(this, intent);

            OverridePendingTransition(Resource.Animation.abc_fade_in, Resource.Animation.abc_fade_out);
        }
Ejemplo n.º 8
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:

                var intent = NavUtils.GetParentActivityIntent(this);
                if (NavUtils.ShouldUpRecreateTask(this, intent))
                {
                    //This activity is not part of the app's tasks, so create new when navigating
                    Android.Support.V4.App.TaskStackBuilder.Create(this).
                    AddNextIntentWithParentStack(intent)
                    .StartActivities();
                }
                else
                {
                    NavUtils.NavigateUpTo(this, intent);
                }
                break;
            }

            return(base.OnOptionsItemSelected(item));
        }