Search in sources :

Example 1 with BaseFragment

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();
}
Also used : Intent(android.content.Intent) BaseFragment(gov.whitehouse.app.BaseFragment) Fragment(android.support.v4.app.Fragment) BaseFragment(gov.whitehouse.app.BaseFragment)

Aggregations

Intent (android.content.Intent)1 Fragment (android.support.v4.app.Fragment)1 BaseFragment (gov.whitehouse.app.BaseFragment)1