in case fragment starts after activity is bound to service; fetch conversation from uuid
This commit is contained in:
parent
962ecbedfa
commit
1500299607
|
@ -92,6 +92,7 @@ import eu.siacs.conversations.ui.util.ScrollState;
|
||||||
import eu.siacs.conversations.ui.util.SendButtonAction;
|
import eu.siacs.conversations.ui.util.SendButtonAction;
|
||||||
import eu.siacs.conversations.ui.util.SendButtonTool;
|
import eu.siacs.conversations.ui.util.SendButtonTool;
|
||||||
import eu.siacs.conversations.ui.widget.EditMessage;
|
import eu.siacs.conversations.ui.widget.EditMessage;
|
||||||
|
import eu.siacs.conversations.utils.ExceptionHelper;
|
||||||
import eu.siacs.conversations.utils.MessageUtils;
|
import eu.siacs.conversations.utils.MessageUtils;
|
||||||
import eu.siacs.conversations.utils.NickValidityChecker;
|
import eu.siacs.conversations.utils.NickValidityChecker;
|
||||||
import eu.siacs.conversations.utils.StylingHelper;
|
import eu.siacs.conversations.utils.StylingHelper;
|
||||||
|
@ -1804,14 +1805,18 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
if (this.reInitRequiredOnStart) {
|
if (this.reInitRequiredOnStart && this.conversation != null) {
|
||||||
final Bundle extras = pendingExtras.pop();
|
final Bundle extras = pendingExtras.pop();
|
||||||
reInit(conversation, extras != null);
|
reInit(this.conversation, extras != null);
|
||||||
if (extras != null) {
|
if (extras != null) {
|
||||||
processExtras(extras);
|
processExtras(extras);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (conversation == null && activity != null && activity.xmppConnectionService != null) {
|
||||||
Log.d(Config.LOGTAG, "skipped reinit on start");
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2567,18 +2572,9 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
Log.d(Config.LOGTAG, "ConversationFragment.onBackendConnected()");
|
Log.d(Config.LOGTAG, "ConversationFragment.onBackendConnected()");
|
||||||
String uuid = pendingConversationsUuid.pop();
|
String uuid = pendingConversationsUuid.pop();
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
Conversation conversation = activity.xmppConnectionService.findConversationByUuid(uuid);
|
if (!findAndReInitByUuidOrArchive(uuid)) {
|
||||||
if (conversation == null) {
|
|
||||||
clearPending();
|
|
||||||
activity.onConversationArchived(null);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
reInit(conversation);
|
|
||||||
ScrollState scrollState = pendingScrollState.pop();
|
|
||||||
String lastMessageUuid = pendingLastMessageUuid.pop();
|
|
||||||
if (scrollState != null) {
|
|
||||||
setScrollPosition(scrollState, lastMessageUuid);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (!activity.xmppConnectionService.isConversationStillOpen(conversation)) {
|
if (!activity.xmppConnectionService.isConversationStillOpen(conversation)) {
|
||||||
clearPending();
|
clearPending();
|
||||||
|
@ -2593,6 +2589,22 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
clearPending();
|
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() {
|
private void clearPending() {
|
||||||
if (postponedActivityResult.pop() != null) {
|
if (postponedActivityResult.pop() != null) {
|
||||||
Log.e(Config.LOGTAG, "cleared pending intent with unhandled result left");
|
Log.e(Config.LOGTAG, "cleared pending intent with unhandled result left");
|
||||||
|
|
Loading…
Reference in New Issue