Merge pull request #5778 from ByteHamster/dont-cancel-download

Don't cancel download on click
This commit is contained in:
ByteHamster 2022-03-13 11:17:54 +01:00 committed by GitHub
commit 723fbff076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 16 deletions

View File

@ -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));

View File

@ -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();
}
}