diff options
author | ByteHamster <ByteHamster@users.noreply.github.com> | 2022-03-13 11:17:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-13 11:17:54 +0100 |
commit | 723fbff076506a4925c95183e80b939aa84788e2 (patch) | |
tree | b017f75ca74fc9f8286467ab3efc5038c40c69c7 /app/src/main | |
parent | bedfdcfe90413d2c2e0911952d66c389366f5817 (diff) | |
parent | 09e25620ee7661df520a8c04e935b6bb85f01213 (diff) | |
download | AntennaPod-723fbff076506a4925c95183e80b939aa84788e2.zip |
Merge pull request #5778 from ByteHamster/dont-cancel-download
Don't cancel download on click
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java | 13 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java | 15 |
2 files changed, 12 insertions, 16 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java index 8f1cfb374..e46073457 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/DownloadLogAdapter.java @@ -17,12 +17,14 @@ import de.danoeh.antennapod.core.service.download.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadRequestCreator; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.core.service.download.Downloader; +import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.model.download.DownloadStatus; import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBTasks; import de.danoeh.antennapod.model.download.DownloadError; import de.danoeh.antennapod.core.util.DownloadErrorLabel; import de.danoeh.antennapod.model.feed.Feed; +import de.danoeh.antennapod.model.feed.FeedItem; import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.ui.common.ThemeUtils; import de.danoeh.antennapod.view.viewholder.DownloadLogItemViewHolder; @@ -157,8 +159,15 @@ public class DownloadLogAdapter extends BaseAdapter { holder.secondaryActionButton.setContentDescription(context.getString(R.string.cancel_download_label)); holder.secondaryActionButton.setVisibility(View.VISIBLE); holder.secondaryActionButton.setTag(downloader); - holder.secondaryActionButton.setOnClickListener(v -> - listFragment.onListItemClick(null, holder.itemView, position, 0)); + holder.secondaryActionButton.setOnClickListener(v -> { + DownloadService.cancel(context, request.getSource()); + if (request.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) { + FeedMedia media = DBReader.getFeedMedia(request.getFeedfileId()); + FeedItem feedItem = media.getItem(); + feedItem.disableAutoDownload(); + DBWriter.setFeedItem(feedItem); + } + }); holder.reason.setVisibility(View.GONE); holder.tapForDetails.setVisibility(View.GONE); holder.icon.setTextColor(ThemeUtils.getColorFromAttr(context, R.attr.colorPrimary)); diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java index 804e8dde3..9f0995f38 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/DownloadLogFragment.java @@ -15,7 +15,6 @@ import de.danoeh.antennapod.core.event.DownloadEvent; import de.danoeh.antennapod.core.event.DownloadLogEvent; import de.danoeh.antennapod.core.event.DownloaderUpdate; import de.danoeh.antennapod.core.menuhandler.MenuItemUtils; -import de.danoeh.antennapod.core.service.download.DownloadRequest; import de.danoeh.antennapod.core.service.download.DownloadService; import de.danoeh.antennapod.model.download.DownloadStatus; import de.danoeh.antennapod.core.service.download.Downloader; @@ -23,8 +22,6 @@ import de.danoeh.antennapod.core.storage.DBReader; import de.danoeh.antennapod.core.storage.DBWriter; import de.danoeh.antennapod.core.util.download.AutoUpdateManager; import de.danoeh.antennapod.dialog.DownloadLogDetailsDialog; -import de.danoeh.antennapod.model.feed.FeedItem; -import de.danoeh.antennapod.model.feed.FeedMedia; import de.danoeh.antennapod.ui.common.PagedToolbarFragment; import de.danoeh.antennapod.view.EmptyViewHandler; import io.reactivex.Observable; @@ -98,17 +95,7 @@ public class DownloadLogFragment extends ListFragment { super.onListItemClick(l, v, position, id); Object item = adapter.getItem(position); - if (item instanceof Downloader) { - DownloadRequest downloadRequest = ((Downloader) item).getDownloadRequest(); - DownloadService.cancel(getContext(), downloadRequest.getSource()); - - if (downloadRequest.getFeedfileType() == FeedMedia.FEEDFILETYPE_FEEDMEDIA) { - FeedMedia media = DBReader.getFeedMedia(downloadRequest.getFeedfileId()); - FeedItem feedItem = media.getItem(); - feedItem.disableAutoDownload(); - DBWriter.setFeedItem(feedItem); - } - } else if (item instanceof DownloadStatus) { + if (item instanceof DownloadStatus) { new DownloadLogDetailsDialog(getContext(), (DownloadStatus) item).show(); } } |