forked from upstream-mirrors/quik
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.setItemClickListener(this);
|
||||||
mAdapter.setMultiSelectListener(this);
|
mAdapter.setMultiSelectListener(this);
|
||||||
mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
mAdapter.registerAdapterDataObserver(new RecyclerView.AdapterDataObserver() {
|
||||||
|
private long mLastMessageId = -1;
|
||||||
@Override
|
@Override
|
||||||
public void onChanged() {
|
public void onChanged() {
|
||||||
LinearLayoutManager manager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
|
LinearLayoutManager manager = (LinearLayoutManager) mRecyclerView.getLayoutManager();
|
||||||
@@ -225,8 +226,15 @@ public class MessageListFragment extends QKFragment implements ActivityLauncher,
|
|||||||
position = mAdapter.getItemCount() - 1;
|
position = mAdapter.getItemCount() - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (position != -1) {
|
if(mAdapter.getCount() > 0) {
|
||||||
manager.smoothScrollToPosition(mRecyclerView, null, position);
|
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