use of gov.whitehouse.app.BaseFragment in project wh-app-android by WhiteHouse.
the class MainActivity method createToolbarMenu.
private void createToolbarMenu() {
if (mToolbar.getMenu() != null) {
mToolbar.getMenu().clear();
}
mToolbar.inflateMenu(R.menu.main);
dispatchCreateToolbarToFragments();
mToolbar.setOnMenuItemClickListener(menuItem -> {
List<Fragment> fragments = getSupportFragmentManager().getFragments();
if (fragments != null) {
for (Fragment f : getSupportFragmentManager().getFragments()) {
if (f != null && f.isAdded() && f instanceof BaseFragment) {
if (((BaseFragment) f).onToolbarMenuItemClicked(menuItem)) {
return true;
}
}
}
}
if (mActionBarDrawerToggle.onOptionsItemSelected(menuItem)) {
return true;
}
return onToolbarMenuItemSelected(menuItem);
});
mSearchItem = mToolbar.getMenu().findItem(R.id.action_search);
mSearchFragment = findOrCreateSearchFragment();
mSearchFragment.setSearchResultClickedListener((result, position) -> {
Intent goIntent = new Intent(Intent.ACTION_VIEW);
goIntent.setData(Uri.parse(result.unescapedUrl()));
startActivity(goIntent);
});
configureSearchView();
}
Aggregations