diff options
author | Martin Fietz <Martin.Fietz@gmail.com> | 2016-01-26 18:50:42 +0100 |
---|---|---|
committer | Martin Fietz <Martin.Fietz@gmail.com> | 2016-01-26 18:50:42 +0100 |
commit | 527ff45229dc4f9238d4eedc18753954238e1555 (patch) | |
tree | 360d4e1355a1af4f85d364ba597b2a5a182edb5d /app/src/main/java/de/danoeh/antennapod/dialog | |
parent | b5457efedda9360276d843e8b7b73b9cd20ff91c (diff) | |
download | AntennaPod-527ff45229dc4f9238d4eedc18753954238e1555.zip |
Make actions selectable
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/dialog')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java | 75 |
1 files changed, 57 insertions, 18 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java index a323b868f..c2917a758 100644 --- a/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/dialog/EpisodesApplyActionFragment.java @@ -34,6 +34,14 @@ public class EpisodesApplyActionFragment extends Fragment { public String TAG = "EpisodeActionFragment"; + public static final int ACTION_QUEUE = 0; + public static final int ACTION_MARK_PLAYED = 1; + public static final int ACTION_MARK_UNPLAYED = 2; + public static final int ACTION_DOWNLOAD = 4; + public static final int ACTION_REMOVE = 8; + public static final int ACTION_ALL = ACTION_QUEUE | ACTION_MARK_PLAYED | ACTION_MARK_UNPLAYED + | ACTION_DOWNLOAD | ACTION_REMOVE; + private ListView mListView; private ArrayAdapter<String> mAdapter; @@ -43,27 +51,26 @@ public class EpisodesApplyActionFragment extends Fragment { private Button btnDownload; private Button btnDelete; - private final Map<Long,FeedItem> idMap; - private final List<FeedItem> episodes; + private final Map<Long,FeedItem> idMap = new ArrayMap<>(); + private final List<FeedItem> episodes = new ArrayList<>(); + private int actions; private final List<String> titles = new ArrayList(); private final LongList checkedIds = new LongList(); private MenuItem mSelectToggle; - private int textColor; - - public EpisodesApplyActionFragment() { - this.episodes = new ArrayList<>(); - this.idMap = new ArrayMap<>(); + public static EpisodesApplyActionFragment newInstance(List<FeedItem> items) { + return newInstance(items, ACTION_ALL); } - public void setEpisodes(List<FeedItem> episodes) { - this.episodes.clear(); - this.episodes.addAll(episodes); - this.idMap.clear(); - for(FeedItem episode : episodes) { - this.idMap.put(episode.getId(), episode); + public static EpisodesApplyActionFragment newInstance(List<FeedItem> items, int actions) { + EpisodesApplyActionFragment f = new EpisodesApplyActionFragment(); + f.episodes.addAll(items); + for(FeedItem episode : items) { + f.idMap.put(episode.getId(), episode); } + f.actions = actions; + return f; } @Override @@ -98,16 +105,48 @@ public class EpisodesApplyActionFragment extends Fragment { mListView.setAdapter(mAdapter); checkAll(); + int lastVisibleDiv = 0; btnAddToQueue = (Button) view.findViewById(R.id.btnAddToQueue); - btnAddToQueue.setOnClickListener(v -> queueChecked()); + if((actions & ACTION_QUEUE) != 0) { + btnAddToQueue.setOnClickListener(v -> queueChecked()); + lastVisibleDiv = R.id.divider1; + } else { + btnAddToQueue.setVisibility(View.GONE); + view.findViewById(R.id.divider1).setVisibility(View.GONE); + } btnMarkAsPlayed = (Button) view.findViewById(R.id.btnMarkAsPlayed); - btnMarkAsPlayed.setOnClickListener(v -> markedCheckedPlayed()); + if((actions & ACTION_MARK_PLAYED) != 0) { + btnMarkAsPlayed.setOnClickListener(v -> markedCheckedPlayed()); + lastVisibleDiv = R.id.divider2; + } else { + btnMarkAsPlayed.setVisibility(View.GONE); + view.findViewById(R.id.divider2).setVisibility(View.GONE); + } btnMarkAsUnplayed = (Button) view.findViewById(R.id.btnMarkAsUnplayed); - btnMarkAsUnplayed.setOnClickListener(v -> markedCheckedUnplayed()); + if((actions & ACTION_MARK_UNPLAYED) != 0) { + btnMarkAsUnplayed.setOnClickListener(v -> markedCheckedUnplayed()); + lastVisibleDiv = R.id.divider3; + } else { + btnMarkAsUnplayed.setVisibility(View.GONE); + view.findViewById(R.id.divider3).setVisibility(View.GONE); + } btnDownload = (Button) view.findViewById(R.id.btnDownload); - btnDownload.setOnClickListener(v -> downloadChecked()); + if((actions & ACTION_DOWNLOAD) != 0) { + btnDownload.setOnClickListener(v -> downloadChecked()); + lastVisibleDiv = R.id.divider4; + } else { + btnDownload.setVisibility(View.GONE); + view.findViewById(R.id.divider4).setVisibility(View.GONE); + } btnDelete = (Button) view.findViewById(R.id.btnDelete); - btnDelete.setOnClickListener(v -> deleteChecked()); + if((actions & ACTION_REMOVE) != 0) { + btnDelete.setOnClickListener(v -> deleteChecked()); + } else { + btnDelete.setVisibility(View.GONE); + if(lastVisibleDiv > 0) { + view.findViewById(lastVisibleDiv).setVisibility(View.GONE); + } + } return view; } |