Fix crash with moveToLastSeen()

This commit is contained in:
Greyson Parrelli 2018-08-02 11:57:10 -04:00
parent 8ca11756be
commit 5a1ef31b49
2 changed files with 14 additions and 3 deletions

View File

@ -301,9 +301,12 @@ public class ConversationActivity extends PassphraseRequiredActionBarActivity
@Override
public void onSuccess(Boolean result) {
if (result != null && result) {
Log.i(TAG, "Finished loading draft");
Util.runOnMain(() -> {
if (fragment != null && fragment.isResumed()) {
fragment.moveToLastSeen();
} else {
Log.w(TAG, "Wanted to move to the last seen position, but the fragment was in an invalid state");
}
});
}

View File

@ -191,10 +191,18 @@ public class ConversationFragment extends Fragment
}
public void moveToLastSeen() {
if (lastSeen > 0) {
int position = getListAdapter().findLastSeenPosition(lastSeen);
scrollToLastSeenPosition(position);
if (lastSeen <= 0) {
Log.i(TAG, "No need to move to last seen.");
return;
}
if (list == null || getListAdapter() == null) {
Log.w(TAG, "Tried to move to last seen position, but we hadn't initialized the view yet.");
return;
}
int position = getListAdapter().findLastSeenPosition(lastSeen);
scrollToLastSeenPosition(position);
}
private void initializeResources() {