Commit 15839804 authored by Willard's avatar Willard

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

parent 70855ed8
......@@ -156,7 +156,21 @@ public class NavDrawerActivity extends AppCompatActivity implements NavigationVi
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
super.onBackPressed();
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 {
super.onBackPressed();
}
}
}
......
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