mirror of
https://github.com/quik-sms/quik.git
synced 2026-11-17 19:38:52 +01:00
Does not scroll to bottom of current conversation if no new SMS are received in this conversation
This commit is contained in:
committed by
Stéphane BAUSSERON
parent
e134516b3c
commit
00430de112
@@ -208,6 +208,7 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
|
||||
mAdapter.setItemClickListener(this);
|
||||
mAdapter.setMultiSelectListener(this);
|
||||
mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
||||
private long mLastMessageId = -1;
|
||||
@Override
|
||||
public void onChanged() {
|
||||
LinearLayoutManager manager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
|
||||
@@ -225,8 +226,15 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
|
||||
position = mAdapter.getItemCount() - 1;
|
||||
}
|
||||
|
||||
if (position != -1) {
|
||||
manager.smoothScrollToPosition(mRecyclerView, null, position);
|
||||
if(mAdapter.getCount() > 0) {
|
||||
MessageItem lastMessage = mAdapter.getItem(mAdapter.getCount() - 1);
|
||||
if (mLastMessageId >= 0 && mLastMessageId != lastMessage.getMessageId()) {
|
||||
// Scroll to bottom only if a new message was inserted in this conversation
|
||||
if (position != -1) {
|
||||
manager.smoothScrollToPosition(mRecyclerView, null, position);
|
||||
}
|
||||
}
|
||||
mLastMessageId = lastMessage.getMessageId();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user