use of com.owncloud.android.ui.events.MenuItemClickEvent in project android by nextcloud.
the class DisplayUtils method setupBottomBar.
public static void setupBottomBar(BottomNavigationView view, Resources resources, final Activity activity, int checkedMenuItem) {
Menu menu = view.getMenu();
Account account = AccountUtils.getCurrentOwnCloudAccount(MainApp.getAppContext());
boolean searchSupported = AccountUtils.hasSearchSupport(account);
if (!searchSupported) {
menu.removeItem(R.id.nav_bar_favorites);
menu.removeItem(R.id.nav_bar_photos);
}
if (resources.getBoolean(R.bool.use_home)) {
menu.findItem(R.id.nav_bar_files).setTitle(resources.getString(R.string.drawer_item_home));
menu.findItem(R.id.nav_bar_files).setIcon(R.drawable.ic_home);
}
setBottomBarItem(view, checkedMenuItem);
view.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch(item.getItemId()) {
case R.id.nav_bar_files:
EventBus.getDefault().post(new MenuItemClickEvent(item));
if (activity != null) {
activity.invalidateOptionsMenu();
}
break;
case R.id.nav_bar_favorites:
SearchEvent favoritesEvent = new SearchEvent("", SearchOperation.SearchType.FAVORITE_SEARCH, SearchEvent.UnsetType.UNSET_DRAWER);
switchToSearchFragment(activity, favoritesEvent);
break;
case R.id.nav_bar_photos:
SearchEvent photosEvent = new SearchEvent("image/%", SearchOperation.SearchType.CONTENT_TYPE_SEARCH, SearchEvent.UnsetType.UNSET_DRAWER);
switchToSearchFragment(activity, photosEvent);
break;
case R.id.nav_bar_settings:
EventBus.getDefault().post(new MenuItemClickEvent(item));
break;
default:
break;
}
return true;
}
});
}
Aggregations