aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Gultsch <daniel@gultsch.de>2016-05-31 16:44:59 +0200
committerDaniel Gultsch <daniel@gultsch.de>2016-05-31 16:44:59 +0200
commitb3337c4ad76cd000d038d6fff97ca8b66832be39 (patch)
tree4b5ee8c309ebf0e68b6c0b560b19a37f213cac9c
parentb7c8ce1511e3db47af6b90d6705062c827bf257d (diff)
don't scroll to pos 0 when uuid wasn't found
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationFragment.java11
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);
}