blob: e196b96b4762bd9dc6f769322c7e6371a6bc4ddc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
package de.danoeh.antennapod.fragment.swipeactions;
import android.content.Context;
import androidx.fragment.app.Fragment;
import java.util.Collections;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedItemFilter;
import de.danoeh.antennapod.view.LocalDeleteModal;
public class DeleteSwipeAction implements SwipeAction {
@Override
public String getId() {
return DELETE;
}
@Override
public int getActionIcon() {
return R.drawable.ic_delete;
}
@Override
public int getActionColor() {
return R.attr.icon_red;
}
@Override
public String getTitle(Context context) {
return context.getString(R.string.delete_episode_label);
}
@Override
public void performAction(FeedItem item, Fragment fragment, FeedItemFilter filter) {
if (!item.isDownloaded() && !item.getFeed().isLocalFeed()) {
return;
}
LocalDeleteModal.showLocalFeedDeleteWarningIfNecessary(
fragment.requireContext(), Collections.singletonList(item),
() -> DBWriter.deleteFeedMediaOfItem(fragment.requireContext(), item.getMedia().getId()));
}
@Override
public boolean willRemove(FeedItemFilter filter, FeedItem item) {
return filter.showDownloaded && (item.isDownloaded() || item.getFeed().isLocalFeed());
}
}
|