fixed openDialogs call when poping back stack

This commit is contained in:
Daniel Gultsch 2018-02-26 10:27:30 +01:00
parent 74336fa165
commit bd2417e792
2 changed files with 13 additions and 5 deletions

View file

@ -184,9 +184,12 @@ public class ConversationActivity extends XmppActivity implements OnConversation
} }
private void showDialogsIfMainIsOverview() { 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 (fragment != null && fragment instanceof ConversationsOverviewFragment) {
if (ExceptionHelper.checkForCrash(this, this.xmppConnectionService)) { if (ExceptionHelper.checkForCrash(this)) {
return; return;
} }
openBatteryOptimizationDialogIfNeeded(); openBatteryOptimizationDialogIfNeeded();
@ -343,6 +346,7 @@ public class ConversationActivity extends XmppActivity implements OnConversation
public void onConversationSelected(Conversation conversation) { public void onConversationSelected(Conversation conversation) {
if (ConversationFragment.getConversation(this) == conversation) { if (ConversationFragment.getConversation(this) == conversation) {
Log.d(Config.LOGTAG,"ignore onConversationSelected() because conversation is already open"); Log.d(Config.LOGTAG,"ignore onConversationSelected() because conversation is already open");
return;
} }
openConversation(conversation, null); openConversation(conversation, null);
} }

View file

@ -28,6 +28,7 @@ import eu.siacs.conversations.entities.Conversation;
import eu.siacs.conversations.entities.Message; import eu.siacs.conversations.entities.Message;
import eu.siacs.conversations.services.XmppConnectionService; import eu.siacs.conversations.services.XmppConnectionService;
import eu.siacs.conversations.ui.ConversationActivity; 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.InvalidJidException;
import eu.siacs.conversations.xmpp.jid.Jid; 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 { try {
final SharedPreferences preferences = PreferenceManager final XmppConnectionService service = activity == null ? null : activity.xmppConnectionService;
.getDefaultSharedPreferences(activity); if (service == null) {
return false;
}
final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(activity);
boolean neverSend = preferences.getBoolean("never_send", false); boolean neverSend = preferences.getBoolean("never_send", false);
if (neverSend || Config.BUG_REPORTS == null) { if (neverSend || Config.BUG_REPORTS == null) {
return false; return false;