Commit 15839804 authored by Willard's avatar Willard

Add confirm dialog to logout when pressing back would lead to the LoginActivity

parent 70855ed8
...@@ -155,10 +155,24 @@ public class NavDrawerActivity extends AppCompatActivity implements NavigationVi ...@@ -155,10 +155,24 @@ public class NavDrawerActivity extends AppCompatActivity implements NavigationVi
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) { if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START); drawer.closeDrawer(GravityCompat.START);
} else {
if(AppUtils.isLoggedIn()) {
new AlertDialog.Builder(this)
.setTitle("Logout")
.setMessage("Are you sure you want to log out?")
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
NavDrawerActivity.super.onBackPressed();
}
})
.setNegativeButton(R.string.no, null)
.show();
} else { } else {
super.onBackPressed(); super.onBackPressed();
} }
} }
}
@Override @Override
public boolean onCreateOptionsMenu(Menu menu) { public boolean onCreateOptionsMenu(Menu menu) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment