From 67c2d3412f322b6c681a7dd04d4399080aa28b17 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 10 Jun 2013 08:40:07 -0700 Subject: Fix inconsistencies. Make dialog more like others --- .../daneren2005/dsub/fragments/MainFragment.java | 51 +++++++++++----------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'subsonic-android/src') diff --git a/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java b/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java index 9a0f512a..645f2ae2 100644 --- a/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java +++ b/subsonic-android/src/github/daneren2005/dsub/fragments/MainFragment.java @@ -27,6 +27,7 @@ import com.actionbarsherlock.view.MenuInflater; import github.daneren2005.dsub.service.MusicService; import github.daneren2005.dsub.service.MusicServiceFactory; import github.daneren2005.dsub.util.ModalBackgroundTask; +import github.daneren2005.dsub.util.SilentBackgroundTask; import github.daneren2005.dsub.view.ChangeLog; import java.io.File; import java.util.ArrayList; @@ -228,44 +229,42 @@ public class MainFragment extends SubsonicFragment { private void showOfflineScrobblesDialog() { AlertDialog.Builder builder = new AlertDialog.Builder(context); - builder.setIcon(android.R.drawable.ic_dialog_info); - - builder.setTitle(R.string.select_album_offline_scrobbles_dialog_title); - builder.setMessage(R.string.select_album_offline_scrobbles_dialog_message); - - //want this on the left and delete on the right hence the backwards button types - builder.setNegativeButton(R.string.select_album_offline_scrobbles_dialog_yes, - new DialogInterface.OnClickListener() { + builder.setIcon(android.R.drawable.ic_dialog_info) + .setTitle(R.string.offline_scrobbles_dialog_title) + .setMessage(R.string.offline_scrobbles_dialog_message) + .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { - new Thread("Scrobble offline") { + new SilentBackgroundTask(context) { @Override - public void run() { - try { - MusicService musicService = MusicServiceFactory.getMusicService(context); - musicService.processOfflineScrobbles(context, null); - } catch (Exception x) { - Log.i(TAG, "Failed to process offline sc/robbles"); - } + protected Void doInBackground() throws Throwable { + MusicService musicService = MusicServiceFactory.getMusicService(context); + musicService.processOfflineScrobbles(context, null); + return null; + } + + @Override + protected void done(Void result) { + Util.toast(context, R.string.offline_scrobbles_success); } - }.start(); - } - }); - builder.setPositiveButton(R.string.select_album_offline_scrobbles_dialog_delete, - new DialogInterface.OnClickListener() { + @Override + protected void error(Throwable error) { + String msg = context.getResources().getString(R.string.offline_scrobbles_error) + " " + getErrorMessage(error); + Util.toast(context, msg); + } + }.execute(); + } + }).setNeutralButton(R.string.common_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); - FileUtil.getOfflineScrobblesFile().delete(); } - }); - - builder.setNeutralButton(R.string.select_album_offline_scrobbles_dialog_no, - new DialogInterface.OnClickListener() { + }).setNegativeButton(R.string.common_delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); + FileUtil.getOfflineScrobblesFile().delete(); } }); -- cgit v1.2.3