Esempio n. 1
0
 @Override
 public void onBackPressed() {
   if (drawerLayout.isDrawerOpen(GravityCompat.START)) {
     drawerLayout.closeDrawer(GravityCompat.START);
   } else {
     super.onBackPressed();
   }
 }
Esempio n. 2
0
  @SuppressWarnings("StatementWithEmptyBody")
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    if (item.isChecked()) return true;

    int id = item.getItemId();
    final ForecastFragment fragment;

    switch (id) {
      case R.id.review:
        fragment = new CurrentlyFragment();
        break;
      case R.id.daily:
        fragment = new DailyFragment();
        break;
      case R.id.hourly:
        fragment = new HourlyForecast();
        break;
      default:
        devDialog.show();
        return true;
    }

    new Handler()
        .postDelayed(
            new Runnable() {
              @Override
              public void run() {
                getFragmentManager()
                    .beginTransaction()
                    // .setCustomAnimations(R.animator.slide_in_up, R.animator.slide_out_up)
                    .replace(R.id.frame, fragment, FRAGMENT_TAG)
                    .commit();
              }
            },
            300);
    drawerLayout.closeDrawer(GravityCompat.START);
    return true;
  }