Fixes issue #132 - No scroll when only two new toots

This commit is contained in:
stom79 2017-12-16 08:35:01 +01:00
parent 7adfe497cd
commit 3f7d6c1e2c
1 changed files with 4 additions and 2 deletions

View File

@ -317,14 +317,16 @@ public class DisplayStatusFragment extends Fragment implements OnRetrieveFeedsIn
}
}
int tootPerPage = sharedpreferences.getInt(Helper.SET_TOOTS_PER_PAGE, 40);
if( tmpStatuses.size() != tootPerPage) {
if( tmpStatuses.size() >= tootPerPage) {
if (tmpStatuses.size() > 0 && Long.parseLong(tmpStatuses.get(tmpStatuses.size() - 1).getId()) > Long.parseLong(bookmark)) {
tmpStatuses.get(tmpStatuses.size() - 1).setFetchMore(true);
}
}
this.statuses.addAll(position, tmpStatuses);
statusListAdapter.notifyItemRangeInserted(position, tmpStatuses.size());
if( position+tmpStatuses.size() > 1) //Avoids to scroll to the second toots due to the offset
if( tmpStatuses.size() < 3) //If new toots are only two
lv_status.scrollToPosition(0);
else
lv_status.scrollToPosition(position+tmpStatuses.size());
}