aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2015-04-08 13:04:50 +0200
committeriNPUTmice <daniel@gultsch.de>2015-04-08 13:04:50 +0200
commit0843db71cef5cd375d4255c777a98a8648006304 (patch)
treeb34374cbc911974bad7ebcb9d24031239d7cc5d1
parent5c5ff5cc7aa9c139865e2d319a7e23385d4d171a (diff)
maintain scroll position after undo
-rw-r--r--src/main/java/eu/siacs/conversations/ui/ConversationActivity.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
index 82939355..e771e6dc 100644
--- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
+++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java
@@ -183,13 +183,19 @@ public class ConversationActivity extends XmppActivity
listView.setDismissCallback(new EnhancedListView.OnDismissCallback() {
@Override
- public EnhancedListView.Undoable onDismiss(EnhancedListView enhancedListView, final int position) {
+ public EnhancedListView.Undoable onDismiss(final EnhancedListView enhancedListView, final int position) {
boolean formerlySelected;
+
+ final int index = listView.getFirstVisiblePosition();
+ View v = listView.getChildAt(0);
+
swipedConversation = listAdapter.getItem(position);
listAdapter.remove(swipedConversation);
swipedConversation.markRead();
+ final int top = (v == null) ? 0 : (v.getTop() - listView.getPaddingTop());
+
if (position == 0 && listAdapter.getCount() == 0) {
endConversation(swipedConversation, false, true);
return null;
@@ -214,6 +220,8 @@ public class ConversationActivity extends XmppActivity
.reInit(getSelectedConversation());
}
swipedConversation = null;
+ listView.setSelectionFromTop(index + (listView.getChildCount() < position ? 1 : 0), top);
+
}
@Override