From e452d5d46d584875ba17623b9d6047ae07a6d522 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 17 Nov 2017 21:00:01 +0100 Subject: [PATCH] stop scrolling before changing conversations. fixes #2700 --- .../eu/siacs/conversations/ui/ConversationActivity.java | 6 ++++++ .../eu/siacs/conversations/ui/ConversationFragment.java | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java index 1357cf4e0..f8f515981 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationActivity.java @@ -139,6 +139,9 @@ public class ConversationActivity extends XmppActivity } public void showConversationsOverview() { + if (mConversationFragment != null) { + mConversationFragment.stopScrolling(); + } if (mContentView instanceof SlidingPaneLayout) { SlidingPaneLayout mSlidingPaneLayout = (SlidingPaneLayout) mContentView; mShouldPanelBeOpen.set(true); @@ -222,6 +225,7 @@ public class ConversationActivity extends XmppActivity public void onItemClick(AdapterView arg0, View clickedView, int position, long arg3) { if (getSelectedConversation() != conversationList.get(position)) { + ConversationActivity.this.mConversationFragment.stopScrolling(); setSelectedConversation(conversationList.get(position)); ConversationActivity.this.mConversationFragment.reInit(getSelectedConversation()); conversationWasSelectedByKeyboard = false; @@ -1110,6 +1114,7 @@ public class ConversationActivity extends XmppActivity private boolean openConversationByIndex(int index) { try { this.conversationWasSelectedByKeyboard = true; + this.mConversationFragment.stopScrolling(); setSelectedConversation(this.conversationList.get(index)); this.mConversationFragment.reInit(getSelectedConversation()); if (index > listView.getLastVisiblePosition() - 1 || index < listView.getFirstVisiblePosition() + 1) { @@ -1328,6 +1333,7 @@ public class ConversationActivity extends XmppActivity final String text = intent.getStringExtra(TEXT); final String nick = intent.getStringExtra(NICK); final boolean pm = intent.getBooleanExtra(PRIVATE_MESSAGE, false); + this.mConversationFragment.stopScrolling(); if (selectConversationByUuid(uuid)) { this.mConversationFragment.reInit(getSelectedConversation()); if (nick != null) { diff --git a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java index e8972b9f4..eec30ff4b 100644 --- a/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/main/java/eu/siacs/conversations/ui/ConversationFragment.java @@ -11,6 +11,7 @@ import android.content.Intent; import android.content.IntentSender.SendIntentException; import android.os.Bundle; import android.os.Handler; +import android.os.SystemClock; import android.support.v13.view.inputmethod.InputConnectionCompat; import android.support.v13.view.inputmethod.InputContentInfoCompat; import android.text.Editable; @@ -25,6 +26,7 @@ import android.view.Gravity; import android.view.KeyEvent; import android.view.LayoutInflater; import android.view.MenuItem; +import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; import android.view.ViewGroup; @@ -1425,6 +1427,12 @@ public class ConversationFragment extends Fragment implements EditMessage.Keyboa } } + public void stopScrolling() { + long now = SystemClock.uptimeMillis(); + MotionEvent cancel = MotionEvent.obtain(now, now, MotionEvent.ACTION_CANCEL, 0, 0, 0); + messagesView.dispatchTouchEvent(cancel); + } + private boolean showLoadMoreMessages(final Conversation c) { final boolean mam = hasMamSupport(c); final MessageArchiveService service = activity.xmppConnectionService.getMessageArchiveService();