diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2016-01-05 13:18:14 +0100 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2016-01-08 00:45:08 +0100 |
commit | 69f77d4918127c462f865ddf48170ef88c359322 (patch) | |
tree | d51e42d2fda7a1d09b5c0018408efc0348a3e8f1 | |
parent | a6a7310a387db39c44bd0db53f639c9f843c31df (diff) | |
download | AntennaPod-69f77d4918127c462f865ddf48170ef88c359322.zip |
Mobile Data Dialog: Stack buttons if necessary
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java b/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java index efdf1a3c9..469a807e1 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java @@ -6,6 +6,8 @@ import android.content.Intent; import android.support.v7.app.AlertDialog; import android.widget.Toast; +import com.afollestad.materialdialogs.MaterialDialog; + import org.apache.commons.lang3.Validate; import de.danoeh.antennapod.R; @@ -99,40 +101,33 @@ public class DefaultActionButtonCallback implements ActionButtonCallback { } private void confirmMobileDownload(final Context context, final FeedItem item) { - AlertDialog.Builder builder = new AlertDialog.Builder(context); + MaterialDialog.Builder builder = new MaterialDialog.Builder(context); builder - .setTitle(R.string.confirm_mobile_download_dialog_title) - .setMessage(context.getText(R.string.confirm_mobile_download_dialog_message)) - .setPositiveButton(context.getText(R.string.confirm_mobile_download_dialog_enable_temporarily), - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - allowMobileDownloadsTimestamp = System.currentTimeMillis(); - try { - DBTasks.downloadFeedItems(context, item); - Toast.makeText(context, R.string.status_downloading_label, Toast.LENGTH_SHORT).show(); - } catch (DownloadRequestException e) { - e.printStackTrace(); - DownloadRequestErrorDialogCreator.newRequestErrorDialog(context, e.getMessage()); - } - } - }); + .title(R.string.confirm_mobile_download_dialog_title) + .content(R.string.confirm_mobile_download_dialog_message) + .positiveText(context.getText(R.string.confirm_mobile_download_dialog_enable_temporarily)) + .onPositive((dialog, which) -> { + allowMobileDownloadsTimestamp = System.currentTimeMillis(); + try { + DBTasks.downloadFeedItems(context, item); + Toast.makeText(context, R.string.status_downloading_label, Toast.LENGTH_SHORT).show(); + } catch (DownloadRequestException e) { + e.printStackTrace(); + DownloadRequestErrorDialogCreator.newRequestErrorDialog(context, e.getMessage()); + } + }); LongList queueIds = DBReader.getQueueIDList(); if(!queueIds.contains(item.getId())) { - builder.setNeutralButton(context.getText(R.string.confirm_mobile_download_dialog_only_add_to_queue), - new DialogInterface.OnClickListener() { - @Override - public void onClick(DialogInterface dialog, int which) { - onlyAddToQueueTimeStamp = System.currentTimeMillis(); - DBWriter.addQueueItem(context, item); - Toast.makeText(context, R.string.added_to_queue_label, Toast.LENGTH_SHORT).show(); - } - }) - .setMessage(context.getText(R.string.confirm_mobile_download_dialog_message_not_in_queue)); - } else { - builder.setMessage(context.getText(R.string.confirm_mobile_download_dialog_message)); + builder + .content(R.string.confirm_mobile_download_dialog_message_not_in_queue) + .neutralText(R.string.confirm_mobile_download_dialog_only_add_to_queue) + .onNeutral((dialog, which) -> { + onlyAddToQueueTimeStamp = System.currentTimeMillis(); + DBWriter.addQueueItem(context, item); + Toast.makeText(context, R.string.added_to_queue_label, Toast.LENGTH_SHORT).show(); + }); } - builder.create() - .show(); + builder.show(); } + } |