use of com.google.samples.apps.iosched.navigation.NavigationModel.NavigationItemEnum in project iosched by google.
the class AppNavigationViewAsBottomNavImpl method displayNavigationItems.
@Override
public void displayNavigationItems(final NavigationItemEnum[] items) {
final Menu menu = mNavigationView.getMenu();
for (NavigationItemEnum item : items) {
final MenuItem menuItem = menu.findItem(item.getId());
if (menuItem != null) {
menuItem.setVisible(true);
menuItem.setIcon(item.getIconResource());
menuItem.setTitle(item.getTitleResource());
if (item == mSelfItem) {
menuItem.setChecked(true);
}
} else {
LOGE(TAG, "Menu Item for navigation item with title " + (item.getTitleResource() != 0 ? mActivity.getResources().getString(item.getTitleResource()) : "") + "not found");
}
}
}
use of com.google.samples.apps.iosched.navigation.NavigationModel.NavigationItemEnum in project iosched by google.
the class AppNavigationViewAsBottomNavImpl method onNavigationItemSelected.
@Override
public boolean onNavigationItemSelected(@NonNull final MenuItem item) {
final NavigationItemEnum navItem = NavigationItemEnum.getById(item.getItemId());
if (navItem != null && navItem != mSelfItem) {
itemSelected(navItem);
AnalyticsHelper.sendEvent("primary nav", "click", item.getTitle().toString());
// Return true so that BottomNavigationView updates itself to show the new item
return true;
}
return false;
}
use of com.google.samples.apps.iosched.navigation.NavigationModel.NavigationItemEnum in project iosched by google.
the class AppNavigationViewAsDrawerImpl method onNavigationItemSelected.
@Override
public boolean onNavigationItemSelected(final MenuItem menuItem) {
NavigationItemEnum item = NavigationItemEnum.getById(menuItem.getItemId());
onNavDrawerItemClicked(item);
return true;
}
use of com.google.samples.apps.iosched.navigation.NavigationModel.NavigationItemEnum in project iosched by google.
the class NavigationUtils method checkNavigationItemIsSelected.
// DISABLED: Broken
// public static void cleanUpActivityStack(ActivityTestRule rule) {
// // Selecting Explore activity will clean up the activity stack, leaving only the explore
// // activity, which can then be finished
// onView(getNavigationItemMatcher(R.id.explore_nav_item)).perform(click());
// rule.getActivity().finish();
// }
/**
* Checks that the {@code expectedSelectedItem} is checked in the navigation drawer, and that no
* other items in the drawer are checked.
*/
public static void checkNavigationItemIsSelected(NavigationItemEnum expected) {
boolean selectedFound = false;
for (int i = 0; i < NavigationItemEnum.values().length; i++) {
NavigationItemEnum item = NavigationItemEnum.values()[i];
try {
// Check item is displayed
onView(getNavigationItemMatcher(item.getId())).check(matches(isDisplayed()));
// If item is shown, check item is not activated, unless it is the requested one
if (item.getId() == expected.getId()) {
onView(getSelectedItem(item)).check(matches(isDisplayed()));
selectedFound = true;
} else {
onView(getSelectedItem(item)).check(matches(not(isDisplayed())));
}
} catch (NoMatchingViewException e) {
// Not all navigation items in the enum are shown. This test doesn't aim to
// check that the correct items are shown, but that only the selected one among
// those shown is shown as selected. Tests in the navigation package check
// correct items are shown.
}
}
// Sanity check to ensure the tests in the try/catch block weren't all skipped
assertTrue(selectedFound);
}
Aggregations