@Test public void should_go_back_when_pressing_back_while_navigation_drawer_is_already_closed_and_category_is_schedule() { presenter.toolbarTitle = R.string.drawer_nav_schedule; when(view.isNavigationDrawerOpen()).thenReturn(false); boolean result = presenter.onBackPressed(); assertThat(result).isFalse(); verify(view, never()).selectDrawerMenuItem(R.id.drawer_nav_schedule); verify(view, never()).closeNavigationDrawer(); }
@Override public boolean onBackPressed() { if (view.isNavigationDrawerOpen()) { view.closeNavigationDrawer(); return true; } else if (toolbarTitle != R.string.drawer_nav_schedule) { int firstItem = R.id.drawer_nav_schedule; onNavigationItemSelected(firstItem); view.selectDrawerMenuItem(firstItem); return true; } return false; }
DrawerPresenter extends BaseActivityPresenter<DrawerMvp.View> implements DrawerMvp.Presenter { @Override public boolean onBackPressed() { if (view.isNavigationDrawerOpen()) { view.closeNavigationDrawer(); return true; } else if (toolbarTitle != R.string.drawer_nav_schedule) { int firstItem = R.id.drawer_nav_schedule; onNavigationItemSelected(firstItem); view.selectDrawerMenuItem(firstItem); return true; } return false; } }
DrawerPresenter extends BaseActivityPresenter<DrawerMvp.View> implements DrawerMvp.Presenter { @Override public boolean onBackPressed() { if (view.isNavigationDrawerOpen()) { view.closeNavigationDrawer(); return true; } else if (toolbarTitle != R.string.drawer_nav_schedule) { int firstItem = R.id.drawer_nav_schedule; onNavigationItemSelected(firstItem); view.selectDrawerMenuItem(firstItem); return true; } return false; } DrawerPresenter(DrawerMvp.View view); }
DrawerPresenter extends BaseActivityPresenter<DrawerMvp.View> implements DrawerMvp.Presenter { @Override public boolean onBackPressed() { if (view.isNavigationDrawerOpen()) { view.closeNavigationDrawer(); return true; } else if (toolbarTitle != R.string.drawer_nav_schedule) { int firstItem = R.id.drawer_nav_schedule; onNavigationItemSelected(firstItem); view.selectDrawerMenuItem(firstItem); return true; } return false; } DrawerPresenter(DrawerMvp.View view); @Override void onPostCreate(Bundle savedInstanceState); @Override void onRestoreInstanceState(Bundle savedInstanceState); @Override void onNavigationItemSelected(@IdRes int itemId); @Override boolean onBackPressed(); }
DrawerPresenter extends BaseActivityPresenter<DrawerMvp.View> implements DrawerMvp.Presenter { @Override public boolean onBackPressed() { if (view.isNavigationDrawerOpen()) { view.closeNavigationDrawer(); return true; } else if (toolbarTitle != R.string.drawer_nav_schedule) { int firstItem = R.id.drawer_nav_schedule; onNavigationItemSelected(firstItem); view.selectDrawerMenuItem(firstItem); return true; } return false; } DrawerPresenter(DrawerMvp.View view); @Override void onPostCreate(Bundle savedInstanceState); @Override void onRestoreInstanceState(Bundle savedInstanceState); @Override void onNavigationItemSelected(@IdRes int itemId); @Override boolean onBackPressed();  }