Slight improvement for the navigation drawer

This commit is contained in:
tonymanou 2017-01-19 23:05:42 +01:00 committed by topjohnwu
parent 61abe5b948
commit 84c8ecb372

View File

@ -13,7 +13,6 @@ import android.preference.PreferenceManager;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.app.ActivityCompat;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
@ -121,8 +120,8 @@ public class MainActivity extends AppCompatActivity
@Override
public void onBackPressed() {
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
if (drawer.isDrawerOpen(navigationView)) {
drawer.closeDrawer(navigationView);
} else {
finish();
}
@ -133,7 +132,7 @@ public class MainActivity extends AppCompatActivity
mSelectedId = menuItem.getItemId();
mDrawerHandler.removeCallbacksAndMessages(null);
mDrawerHandler.postDelayed(() -> navigate(menuItem.getItemId(), false), 250);
drawer.closeDrawer(GravityCompat.START);
drawer.closeDrawer(navigationView);
return true;
}