From 3c7dc29eb9ae754ea8060d4bff977badd218d3fd Mon Sep 17 00:00:00 2001 From: Christian Schneppe Date: Sat, 31 Mar 2018 22:20:07 +0200 Subject: fixed openDialogs call when poping back stack --- .../java/de/pixart/messenger/ui/ConversationActivity.java | 8 ++++++-- .../java/de/pixart/messenger/utils/ExceptionHelper.java | 13 ++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java index b119d62ea..36b5de0c0 100644 --- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java @@ -243,9 +243,12 @@ public class ConversationActivity extends XmppActivity implements OnConversation } private void showDialogsIfMainIsOverview() { - Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment); + if (xmppConnectionService == null) { + return; + } + final Fragment fragment = getFragmentManager().findFragmentById(R.id.main_fragment); if (fragment != null && fragment instanceof ConversationsOverviewFragment) { - if (ExceptionHelper.checkForCrash(this, this.xmppConnectionService)) { + if (ExceptionHelper.checkForCrash(this)) { return; } openBatteryOptimizationDialogIfNeeded(); @@ -403,6 +406,7 @@ public class ConversationActivity extends XmppActivity implements OnConversation public void onConversationSelected(Conversation conversation) { if (ConversationFragment.getConversation(this) == conversation) { Log.d(Config.LOGTAG, "ignore onConversationSelected() because conversation is already open"); + return; } openConversation(conversation, null); } diff --git a/src/main/java/de/pixart/messenger/utils/ExceptionHelper.java b/src/main/java/de/pixart/messenger/utils/ExceptionHelper.java index 9aacef24f..b1d4da78b 100644 --- a/src/main/java/de/pixart/messenger/utils/ExceptionHelper.java +++ b/src/main/java/de/pixart/messenger/utils/ExceptionHelper.java @@ -1,6 +1,5 @@ package de.pixart.messenger.utils; -import android.support.v7.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; @@ -9,6 +8,7 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.Signature; import android.preference.PreferenceManager; +import android.support.v7.app.AlertDialog; import android.util.Log; import java.io.BufferedReader; @@ -27,7 +27,7 @@ import de.pixart.messenger.entities.Account; import de.pixart.messenger.entities.Conversation; import de.pixart.messenger.entities.Message; import de.pixart.messenger.services.XmppConnectionService; -import de.pixart.messenger.ui.ConversationActivity; +import de.pixart.messenger.ui.XmppActivity; import de.pixart.messenger.xmpp.jid.InvalidJidException; import de.pixart.messenger.xmpp.jid.Jid; @@ -42,10 +42,13 @@ public class ExceptionHelper { } } - public static boolean checkForCrash(ConversationActivity activity, final XmppConnectionService service) { + public static boolean checkForCrash(XmppActivity activity) { try { - final SharedPreferences preferences = PreferenceManager - .getDefaultSharedPreferences(activity); + final XmppConnectionService service = activity == null ? null : activity.xmppConnectionService; + if (service == null) { + return false; + } + final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity); boolean crashreport = preferences.getBoolean("crashreport", activity.getResources().getBoolean(R.bool.send_crashreport)); if (!crashreport || Config.BUG_REPORTS == null) { return false; -- cgit v1.2.3