Browse Source

Fix for AlertDialog window leak error

pull/63/head
Ezerous 5 years ago
parent
commit
73f30f5686
  1. 9
      app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java
  2. 2
      app/src/main/java/gr/thmmy/mthmmy/base/BaseActivity.java

9
app/src/main/java/gr/thmmy/mthmmy/activities/topic/TopicActivity.java

@ -123,6 +123,7 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo
private Snackbar snackbar; private Snackbar snackbar;
private TopicViewModel viewModel; private TopicViewModel viewModel;
private EmojiKeyboard emojiKeyboard; private EmojiKeyboard emojiKeyboard;
private AlertDialog topicInfoDialog;
//Fix for vector drawables on android <21 //Fix for vector drawables on android <21
static { static {
@ -253,8 +254,8 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo
usersViewing.setText(HTMLUtils.getSpannableFromHtml(this, topicViewers)); usersViewing.setText(HTMLUtils.getSpannableFromHtml(this, topicViewers));
}); });
builder.setView(infoDialog); builder.setView(infoDialog);
AlertDialog dialog = builder.create(); topicInfoDialog = builder.create();
dialog.show(); topicInfoDialog.show();
return true; return true;
case R.id.menu_share: case R.id.menu_share:
Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
@ -312,6 +313,10 @@ public class TopicActivity extends BaseActivity implements TopicAdapter.OnPostFo
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
if(topicInfoDialog!=null){
topicInfoDialog.dismiss();
topicInfoDialog=null;
}
recyclerView.setAdapter(null); recyclerView.setAdapter(null);
viewModel.stopLoading(); viewModel.stopLoading();
} }

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

@ -548,7 +548,7 @@ public abstract class BaseActivity extends AppCompatActivity {
AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle); AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
builder.setTitle("Logout"); builder.setTitle("Logout");
builder.setMessage("Are you sure that you want to logout?"); builder.setMessage("Are you sure that you want to logout?");
builder.setPositiveButton("Yes", (dialogInterface, i) -> { builder.setPositiveButton("Yep", (dialogInterface, i) -> {
new LogoutTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); //Avoid delays between onPreExecute() and doInBackground() new LogoutTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); //Avoid delays between onPreExecute() and doInBackground()
}); });
builder.setNegativeButton("Nope", (dialogInterface, i) -> {}); builder.setNegativeButton("Nope", (dialogInterface, i) -> {});

Loading…
Cancel
Save