blob: 9687ab643e2023fab5225e30d077148a3f01c88e (
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
51
52
53
54
55
56
57
|
package de.danoeh.antennapod.fragment.swipeactions;
import android.content.Context;
import androidx.fragment.app.Fragment;
import com.google.android.material.snackbar.Snackbar;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.activity.MainActivity;
import de.danoeh.antennapod.core.storage.DBReader;
import de.danoeh.antennapod.core.storage.DBWriter;
import de.danoeh.antennapod.model.feed.FeedItem;
import de.danoeh.antennapod.model.feed.FeedItemFilter;
public class RemoveFromQueueSwipeAction implements SwipeAction {
@Override
public String getId() {
return REMOVE_FROM_QUEUE;
}
@Override
public int getActionIcon() {
return R.drawable.ic_playlist_remove;
}
@Override
public int getActionColor() {
return R.attr.colorAccent;
}
@Override
public String getTitle(Context context) {
return context.getString(R.string.remove_from_queue_label);
}
@Override
public void performAction(FeedItem item, Fragment fragment, FeedItemFilter filter) {
int position = DBReader.getQueueIDList().indexOf(item.getId());
DBWriter.removeQueueItem(fragment.requireActivity(), true, item);
if (willRemove(filter, item)) {
((MainActivity) fragment.requireActivity()).showSnackbarAbovePlayer(
fragment.getResources().getQuantityString(R.plurals.removed_from_queue_batch_label, 1, 1),
Snackbar.LENGTH_LONG)
.setAction(fragment.getString(R.string.undo), v ->
DBWriter.addQueueItemAt(fragment.requireActivity(), item.getId(), position, false));
}
}
@Override
public boolean willRemove(FeedItemFilter filter, FeedItem item) {
return filter.showQueued || filter.showNotQueued;
}
}
|