From 32937a842d8e4714b316eee0b79077320a6e6d27 Mon Sep 17 00:00:00 2001 From: ByteHamster Date: Fri, 30 Aug 2019 14:53:43 +0200 Subject: [PATCH] Moved options menu handling to child classes --- .../antennapod/fragment/AllEpisodesFragment.java | 1 + .../antennapod/fragment/EpisodesListFragment.java | 13 ------------- .../antennapod/fragment/NewEpisodesFragment.java | 7 +++++++ app/src/main/res/menu/episodes.xml | 2 ++ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java index 2aa57e3c7..bb52b26b7 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/AllEpisodesFragment.java @@ -112,6 +112,7 @@ public class AllEpisodesFragment extends EpisodesListFragment { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); menu.findItem(R.id.filter_items).setVisible(true); + menu.findItem(R.id.mark_all_read_item).setVisible(!episodes.isEmpty()); } @Override diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java index 1059cfa26..1cedb5a91 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/EpisodesListFragment.java @@ -197,19 +197,6 @@ public abstract class EpisodesListFragment extends Fragment { isUpdatingFeeds = MenuItemUtils.updateRefreshMenuItem(menu, R.id.refresh_item, updateRefreshMenuItemChecker); } - @Override - public void onPrepareOptionsMenu(Menu menu) { - super.onPrepareOptionsMenu(menu); - MenuItem markAllRead = menu.findItem(R.id.mark_all_read_item); - if (markAllRead != null) { - markAllRead.setVisible(!showOnlyNewEpisodes() && !episodes.isEmpty()); - } - MenuItem removeAllNewFlags = menu.findItem(R.id.remove_all_new_flags_item); - if (removeAllNewFlags != null) { - removeAllNewFlags.setVisible(showOnlyNewEpisodes() && !episodes.isEmpty()); - } - } - @Override public boolean onOptionsItemSelected(MenuItem item) { if (!super.onOptionsItemSelected(item)) { diff --git a/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java b/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java index b7de65ffb..adae4f2a5 100644 --- a/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java +++ b/app/src/main/java/de/danoeh/antennapod/fragment/NewEpisodesFragment.java @@ -6,6 +6,7 @@ import android.support.v7.widget.RecyclerView; import android.support.v7.widget.helper.ItemTouchHelper; import android.view.LayoutInflater; import android.view.Menu; +import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; @@ -40,6 +41,12 @@ public class NewEpisodesFragment extends EpisodesListFragment { return item.isNew(); } + @Override + public void onPrepareOptionsMenu(Menu menu) { + super.onPrepareOptionsMenu(menu); + menu.findItem(R.id.remove_all_new_flags_item).setVisible(!episodes.isEmpty()); + } + @NonNull @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { diff --git a/app/src/main/res/menu/episodes.xml b/app/src/main/res/menu/episodes.xml index 2bb7d1d06..1e1aa8f56 100644 --- a/app/src/main/res/menu/episodes.xml +++ b/app/src/main/res/menu/episodes.xml @@ -30,6 +30,7 @@ android:title="@string/mark_all_read_label" android:menuCategory="container" custom:showAsAction="collapseActionView" + android:visible="false" android:icon="?attr/navigation_accept"/>