fixed openDialogs call when poping back stack

Daniel Gultsch created

Change summary

src/main/java/eu/siacs/conversations/ui/ConversationActivity.java |  8 
src/main/java/eu/siacs/conversations/utils/ExceptionHelper.java   | 10 
2 files changed, 13 insertions(+), 5 deletions(-)

Detailed changes

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);
 	}

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;