From 78998ef733936bc3382b9637b0d03691383f9829 Mon Sep 17 00:00:00 2001 From: daneren2005 Date: Thu, 30 May 2013 14:57:15 -0600 Subject: Return to front of the app on network exception instead of exiting all the way --- .../src/github/daneren2005/dsub/util/ErrorDialog.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'subsonic-android/src/github/daneren2005') diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ErrorDialog.java b/subsonic-android/src/github/daneren2005/dsub/util/ErrorDialog.java index 2928e93f..ab9b4fa3 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/ErrorDialog.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/ErrorDialog.java @@ -21,6 +21,8 @@ package github.daneren2005.dsub.util; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; +import android.content.Intent; +import github.daneren2005.dsub.activity.MainActivity; import github.daneren2005.dsub.R; /** @@ -43,7 +45,7 @@ public class ErrorDialog { @Override public void onCancel(DialogInterface dialogInterface) { if (finishActivityOnClose) { - activity.finish(); + restart(activity); } } }); @@ -51,11 +53,17 @@ public class ErrorDialog { @Override public void onClick(DialogInterface dialogInterface, int i) { if (finishActivityOnClose) { - activity.finish(); + restart(activity); } } }); builder.create().show(); } + + private void restart(Activity context) { + Intent intent = new Intent(context, MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + Util.startActivityWithoutTransition(context, intent); + } } -- cgit v1.2.3