From bd2417e7924ba79d4bb52097932d57b86778f32d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Mon, 26 Feb 2018 10:27:30 +0100 Subject: [PATCH] fixed openDialogs call when poping back stack --- .../siacs/conversations/ui/ConversationActivity.java | 8 ++++++-- .../eu/siacs/conversations/utils/ExceptionHelper.java | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 045d9af4c..26b41b759 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -184,9 +184,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(); @@ -343,6 +346,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/eu/siacs/conversations/utils/ExceptionHelper.java b/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java index 0bbbb7e37..bf5cdbedb 100644 --- a/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java +++ b/src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java @@ -28,6 +28,7 @@ import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.ui.ConversationActivity; +import eu.siacs.conversations.ui.XmppActivity; import eu.siacs.conversations.xmpp.jid.InvalidJidException; import eu.siacs.conversations.xmpp.jid.Jid; @@ -43,10 +44,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 neverSend = preferences.getBoolean("never_send", false); if (neverSend || Config.BUG_REPORTS == null) { return false;