Don't scroll to last seen until the recyclerview has been measured

// FREEBIE
This commit is contained in:
Moxie Marlinspike 2017-02-18 14:32:22 -08:00
parent acca4a72d3
commit a075bf7505

View File

@ -442,10 +442,15 @@ public class ConversationFragment extends Fragment
}
private void scrollToLastSeenPosition(long lastSeen) {
int lastSeenPosition = getListAdapter().findLastSeenPosition(lastSeen);
final int lastSeenPosition = getListAdapter().findLastSeenPosition(lastSeen);
if (lastSeenPosition > 0) {
((LinearLayoutManager)list.getLayoutManager()).scrollToPositionWithOffset(lastSeenPosition, list.getHeight());
list.post(new Runnable() {
@Override
public void run() {
((LinearLayoutManager)list.getLayoutManager()).scrollToPositionWithOffset(lastSeenPosition, list.getHeight());
}
});
} else {
setLastSeen(0);
}