diff options
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/eu/siacs/conversations/ui/ConversationFragment.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index 5d5e4c29..8e0b30a8 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -13,6 +13,7 @@ import android.os.Bundle; import android.os.Handler; import android.support.annotation.Nullable; import android.text.InputType; +import android.util.Log; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; import android.view.Gravity; @@ -157,7 +158,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa ConversationFragment.this.conversation.populateWithMessages(ConversationFragment.this.messageList); updateStatusMessages(); messageListAdapter.notifyDataSetChanged(); - int pos = getIndexOf(uuid,messageList); + int pos = Math.max(getIndexOf(uuid,messageList),0); messagesView.setSelectionFromTop(pos, pxOffset); messagesLoaded = true; if (messageLoaderToast != null) { @@ -210,7 +211,7 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } } - return 0; + return -1; } private final int KEYCHAIN_UNLOCK_NOT_REQUIRED = 0; @@ -802,11 +803,13 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa this.messagesLoaded = true; synchronized (this.messageList) { final Message first = conversation.getFirstUnreadMessage(); + final int bottom = Math.max(0, this.messageList.size() - 1); final int pos; if (first == null) { - pos = Math.max(0,this.messageList.size() - 1); + pos = bottom; } else { - pos = getIndexOf(first.getUuid(), this.messageList); + int i = getIndexOf(first.getUuid(), this.messageList); + pos = i < 0 ? bottom : i; } messagesView.setSelection(pos); } |