Browse Source

Added dialog upon logout

pull/63/head
Ezerous 5 years ago
parent
commit
0d8ccd3669
  1. 28
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

28
app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

@ -428,7 +428,7 @@ public abstract class BaseActivity extends AppCompatActivity {
if (!sessionManager.isLoggedIn()) //When logged out or if user is guest if (!sessionManager.isLoggedIn()) //When logged out or if user is guest
startLoginActivity(); startLoginActivity();
else else
new LogoutTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); //Avoid delays between onPreExecute() and doInBackground() showLogoutDialog();
} else if (drawerItem.equals(ABOUT_ID)) { } else if (drawerItem.equals(ABOUT_ID)) {
if (!(BaseActivity.this instanceof AboutActivity)) { if (!(BaseActivity.this instanceof AboutActivity)) {
Intent intent = new Intent(BaseActivity.this, AboutActivity.class); Intent intent = new Intent(BaseActivity.this, AboutActivity.class);
@ -543,6 +543,17 @@ public abstract class BaseActivity extends AppCompatActivity {
//} //}
} }
} }
private void showLogoutDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
builder.setTitle("Logout");
builder.setMessage("Are you sure that you want to logout?");
builder.setPositiveButton("Yes", (dialogInterface, i) -> {
new LogoutTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); //Avoid delays between onPreExecute() and doInBackground()
});
builder.setNegativeButton("Nope", (dialogInterface, i) -> {});
builder.create().show();
}
//-----------------------------------------LOGOUT END----------------------------------------------- //-----------------------------------------LOGOUT END-----------------------------------------------
//---------------------------------------------BOOKMARKS-------------------------------------------- //---------------------------------------------BOOKMARKS--------------------------------------------
@ -557,24 +568,21 @@ public abstract class BaseActivity extends AppCompatActivity {
protected void setTopicBookmark(MenuItem thisPageBookmarkMenuButton) { protected void setTopicBookmark(MenuItem thisPageBookmarkMenuButton) {
this.thisPageBookmarkMenuButton = thisPageBookmarkMenuButton; this.thisPageBookmarkMenuButton = thisPageBookmarkMenuButton;
if (thisPageBookmark.matchExists(topicsBookmarked)) { if (thisPageBookmark.matchExists(topicsBookmarked))
thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_true_accent_24dp); thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_true_accent_24dp);
} else { else
thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_false_accent_24dp); thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_false_accent_24dp);
} }
}
protected void refreshTopicBookmark() { protected void refreshTopicBookmark() {
if (thisPageBookmarkMenuButton == null) { if (thisPageBookmarkMenuButton == null) return;
return;
}
loadSavedBookmarks(); loadSavedBookmarks();
if (thisPageBookmark.matchExists(topicsBookmarked)) { if (thisPageBookmark.matchExists(topicsBookmarked))
thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_true_accent_24dp); thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_true_accent_24dp);
} else { else
thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_false_accent_24dp); thisPageBookmarkMenuButton.setIcon(R.drawable.ic_bookmark_false_accent_24dp);
} }
}
protected void topicMenuBookmarkClick() { protected void topicMenuBookmarkClick() {
if (thisPageBookmark.matchExists(topicsBookmarked)) { if (thisPageBookmark.matchExists(topicsBookmarked)) {

Loading…
Cancel
Save