@Test public void should_close_navigation_drawer_when_pressing_back_if_already_opened() { when(view.isNavigationDrawerOpen()).thenReturn(true); boolean result = presenter.onBackPressed(); assertThat(result).isTrue(); verify(view).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();  }