aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-04-22 19:31:56 +0200
committerChristian Schneppe <christian@pix-art.de>2018-04-22 19:31:56 +0200
commitf44e12b077384c1f0fb14234f518e41fa73710a5 (patch)
tree88e457049caa5f6fdb3624432ec3511d26075ee3 /src
parentf61d006835b9690daeebb20963ca2a2b75ae30cb (diff)
in case fragment starts after activity is bound to service; fetch conversation from uuid
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java39
1 files changed, 25 insertions, 14 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index 1feb40b1f..8519c30cf 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -2085,14 +2085,18 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
@Override
public void onStart() {
super.onStart();
- if (this.reInitRequiredOnStart) {
+ if (this.reInitRequiredOnStart && this.conversation != null) {
final Bundle extras = pendingExtras.pop();
- reInit(conversation, extras != null);
+ reInit(this.conversation, extras != null);
if (extras != null) {
processExtras(extras);
}
- } else {
- Log.d(Config.LOGTAG, "skipped reinit on start");
+ } else if (conversation == null && activity != null && activity.xmppConnectionService != null) {
+ final String uuid = pendingConversationsUuid.pop();
+ Log.d(Config.LOGTAG, "ConversationFragment.onStart() - activity was bound but no conversation loaded. uuid=" + uuid);
+ if (uuid != null) {
+ findAndReInitByUuidOrArchive(uuid);
+ }
}
}
@@ -3012,18 +3016,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
Log.d(Config.LOGTAG, "ConversationFragment.onBackendConnected()");
String uuid = pendingConversationsUuid.pop();
if (uuid != null) {
- Conversation conversation = activity.xmppConnectionService.findConversationByUuid(uuid);
- if (conversation == null) {
- clearPending();
- activity.onConversationArchived(null);
+ if (!findAndReInitByUuidOrArchive(uuid)) {
return;
}
- reInit(conversation);
- ScrollState scrollState = pendingScrollState.pop();
- String lastMessageUuid = pendingLastMessageUuid.pop();
- if (scrollState != null) {
- setScrollPosition(scrollState, lastMessageUuid);
- }
} else {
if (!activity.xmppConnectionService.isConversationStillOpen(conversation)) {
clearPending();
@@ -3038,6 +3033,22 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
clearPending();
}
+ private boolean findAndReInitByUuidOrArchive(@NonNull final String uuid) {
+ Conversation conversation = activity.xmppConnectionService.findConversationByUuid(uuid);
+ if (conversation == null) {
+ clearPending();
+ activity.onConversationArchived(null);
+ return false;
+ }
+ reInit(conversation);
+ ScrollState scrollState = pendingScrollState.pop();
+ String lastMessageUuid = pendingLastMessageUuid.pop();
+ if (scrollState != null) {
+ setScrollPosition(scrollState, lastMessageUuid);
+ }
+ return true;
+ }
+
private void clearPending() {
if (postponedActivityResult.pop() != null) {
Log.e(Config.LOGTAG, "cleared pending intent with unhandled result left");