Moved options menu handling to child classes

This commit is contained in:
ByteHamster 2019-08-30 14:53:43 +02:00
parent 862e86850f
commit 32937a842d
4 changed files with 10 additions and 13 deletions

View File

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

View File

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

View File

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

View File

@ -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"/>
<item
@ -37,6 +38,7 @@
android:title="@string/remove_all_new_flags_label"
android:menuCategory="container"
custom:showAsAction="collapseActionView"
android:visible="false"
android:icon="?attr/navigation_accept"/>
</menu>