provide fallback in case synchronizing around message list fails for some reason
This commit is contained in:
parent
ceac602185
commit
829ab885fd
|
@ -131,7 +131,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
public static final String STATE_PHOTO_URI = ConversationFragment.class.getName() + ".take_photo_uri";
|
public static final String STATE_PHOTO_URI = ConversationFragment.class.getName() + ".take_photo_uri";
|
||||||
private static final String STATE_LAST_MESSAGE_UUID = "state_last_message_uuid";
|
private static final String STATE_LAST_MESSAGE_UUID = "state_last_message_uuid";
|
||||||
|
|
||||||
final protected List<Message> messageList = new ArrayList<>();
|
private final List<Message> messageList = new ArrayList<>();
|
||||||
private final PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>();
|
private final PendingItem<ActivityResult> postponedActivityResult = new PendingItem<>();
|
||||||
private final PendingItem<String> pendingConversationsUuid = new PendingItem<>();
|
private final PendingItem<String> pendingConversationsUuid = new PendingItem<>();
|
||||||
private final PendingItem<Bundle> pendingExtras = new PendingItem<>();
|
private final PendingItem<Bundle> pendingExtras = new PendingItem<>();
|
||||||
|
@ -214,6 +214,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
|
synchronized (messageList) {
|
||||||
final int oldPosition = binding.messagesView.getFirstVisiblePosition();
|
final int oldPosition = binding.messagesView.getFirstVisiblePosition();
|
||||||
Message message = null;
|
Message message = null;
|
||||||
int childPos;
|
int childPos;
|
||||||
|
@ -239,6 +240,7 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
messageLoaderToast.cancel();
|
messageLoaderToast.cancel();
|
||||||
}
|
}
|
||||||
conversation.messagesLoaded.set(true);
|
conversation.messagesLoaded.set(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1586,7 +1588,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
|
||||||
if (pos >= 0) {
|
if (pos >= 0) {
|
||||||
Message message = null;
|
Message message = null;
|
||||||
for (int i = pos; i >= 0; --i) {
|
for (int i = pos; i >= 0; --i) {
|
||||||
|
try {
|
||||||
message = (Message) binding.messagesView.getItemAtPosition(i);
|
message = (Message) binding.messagesView.getItemAtPosition(i);
|
||||||
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
|
//should not happen if we synchronize properly. however if that fails we just gonna try item -1
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (message.getType() != Message.TYPE_STATUS) {
|
if (message.getType() != Message.TYPE_STATUS) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue