-Fixed bookmark fragment in main pager not showing hamburger menu.

This commit is contained in:
John Zhen Mo 2018-02-08 10:13:29 -08:00
parent c3941d5bec
commit 0630423c8e
2 changed files with 29 additions and 9 deletions

View File

@ -86,19 +86,30 @@ public abstract class BaseLocalListFragment<I, N> extends BaseStateFragment<I>
// Lifecycle - Menu // Lifecycle - Menu
//////////////////////////////////////////////////////////////////////////*/ //////////////////////////////////////////////////////////////////////////*/
/** Determines if the fragment is part of the main fragment view pager.
* If so, then this method must be overriden to return true
* in order to show the hamburger menu. */
protected boolean isPartOfFrontPager() {
return false;
}
@Override @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (DEBUG) Log.d(TAG, "onCreateOptionsMenu() called with: menu = [" + menu + if (DEBUG) Log.d(TAG, "onCreateOptionsMenu() called with: menu = [" + menu +
"], inflater = [" + inflater + "]"); "], inflater = [" + inflater + "]");
super.onCreateOptionsMenu(menu, inflater);
ActionBar supportActionBar = activity.getSupportActionBar(); final ActionBar supportActionBar = activity.getSupportActionBar();
if (supportActionBar != null) { if (supportActionBar == null) return;
supportActionBar.setDisplayShowTitleEnabled(true);
if(useAsFrontPage) { supportActionBar.setDisplayShowTitleEnabled(true);
supportActionBar.setDisplayHomeAsUpEnabled(false);
} else { // Show up arrow icon if the fragment is not used as front page or part of the front pager
supportActionBar.setDisplayHomeAsUpEnabled(true); if (!useAsFrontPage && !isPartOfFrontPager()) {
} // If set true, an up arrow icon will be displayed.
// If set false, no icon will be shown.
// If unset, show hamburger menu
supportActionBar.setDisplayHomeAsUpEnabled(true);
} }
} }

View File

@ -148,6 +148,15 @@ public final class BookmarkFragment
}); });
} }
/*//////////////////////////////////////////////////////////////////////////
// Fragment Lifecycle - Menu
//////////////////////////////////////////////////////////////////////////*/
@Override
protected boolean isPartOfFrontPager() {
return true;
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Fragment LifeCycle - Loading // Fragment LifeCycle - Loading
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////