diff options
Diffstat (limited to 'src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java')
-rw-r--r-- | src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java b/src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java deleted file mode 100644 index 0c4cbe685..000000000 --- a/src/de/danoeh/antennapod/adapter/DefaultActionButtonCallback.java +++ /dev/null @@ -1,57 +0,0 @@ -package de.danoeh.antennapod.adapter; - -import android.content.Context; -import android.widget.Toast; - -import org.apache.commons.lang3.Validate; - -import de.danoeh.antennapod.R; -import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator; -import de.danoeh.antennapod.feed.FeedItem; -import de.danoeh.antennapod.feed.FeedMedia; -import de.danoeh.antennapod.storage.DBTasks; -import de.danoeh.antennapod.storage.DBWriter; -import de.danoeh.antennapod.storage.DownloadRequestException; -import de.danoeh.antennapod.storage.DownloadRequester; - -/** - * Default implementation of an ActionButtonCallback - */ -public class DefaultActionButtonCallback implements ActionButtonCallback { - private static final String TAG = "DefaultActionButtonCallback"; - - private final Context context; - - public DefaultActionButtonCallback(Context context) { - Validate.notNull(context); - this.context = context; - } - - @Override - public void onActionButtonPressed(final FeedItem item) { - - - if (item.hasMedia()) { - final FeedMedia media = item.getMedia(); - boolean isDownloading = DownloadRequester.getInstance().isDownloadingFile(media); - if (!isDownloading && !media.isDownloaded()) { - 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()); - } - } else if (isDownloading) { - DownloadRequester.getInstance().cancelDownload(context, media); - Toast.makeText(context, R.string.download_cancelled_msg, Toast.LENGTH_SHORT).show(); - } else { // media is downloaded - DBTasks.playMedia(context, media, true, true, false); - } - } else { - if (!item.isRead()) { - DBWriter.markItemRead(context, item, true, true); - } - } - } -} |