forked from mirrors/Fedilab
Some fixes
This commit is contained in:
parent
086be24686
commit
62b0caec11
3 changed files with 10 additions and 4 deletions
|
@ -327,6 +327,7 @@ public class StatusCache {
|
|||
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + since_id + "' ";
|
||||
limit = null;
|
||||
}
|
||||
|
||||
try {
|
||||
Cursor c = db.query(Sqlite.TABLE_STATUS_CACHE, null, selection, null, null, null, Sqlite.COL_STATUS_ID + order, limit);
|
||||
return createStatusReply(cursorToListOfStatuses(c));
|
||||
|
|
|
@ -404,6 +404,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
}
|
||||
//Update the timeline with new statuses
|
||||
updateStatusListWith(fetched_statuses.statuses);
|
||||
if (direction == DIRECTION.TOP && fetchingMissing) {
|
||||
binding.recyclerView.scrollToPosition(getPosition(fetched_statuses.statuses.get(fetched_statuses.statuses.size() - 1)) + 1);
|
||||
}
|
||||
if (!fetchingMissing) {
|
||||
if (fetched_statuses.pagination.max_id == null) {
|
||||
flagLoading = true;
|
||||
|
@ -427,7 +430,8 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
*
|
||||
* @param statusListReceived - List<Status> Statuses received
|
||||
*/
|
||||
private void updateStatusListWith(List<Status> statusListReceived) {
|
||||
private int updateStatusListWith(List<Status> statusListReceived) {
|
||||
int inserted = 0;
|
||||
if (statusListReceived != null && statusListReceived.size() > 0) {
|
||||
for (Status statusReceived : statusListReceived) {
|
||||
int position = 0;
|
||||
|
@ -443,6 +447,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
if (!timelineStatuses.contains(statusReceived) && !statusReceived.pinned && timelineType != Timeline.TimeLineEnum.ACCOUNT_TIMELINE) {
|
||||
timelineStatuses.add(position, statusReceived);
|
||||
statusAdapter.notifyItemInserted(position);
|
||||
inserted++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -457,6 +462,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
}
|
||||
}
|
||||
}
|
||||
return inserted;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -604,10 +610,10 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
|||
|
||||
});
|
||||
} else if (direction == DIRECTION.REFRESH || direction == DIRECTION.SCROLL_TOP) {
|
||||
timelinesVM.getTimelineCache(timelineStatuses, timelineParams)
|
||||
timelinesVM.getTimeline(timelineStatuses, timelineParams)
|
||||
.observe(getViewLifecycleOwner(), statusesRefresh -> {
|
||||
if (statusesRefresh == null || statusesRefresh.statuses == null || statusesRefresh.statuses.size() == 0) {
|
||||
getLiveStatus(direction, fetchingMissing, timelineParams);
|
||||
getCachedStatus(direction, fetchingMissing, timelineParams);
|
||||
} else {
|
||||
if (statusAdapter != null) {
|
||||
dealWithPagination(statusesRefresh, direction, true);
|
||||
|
|
|
@ -395,7 +395,6 @@ public class TimelinesVM extends AndroidViewModel {
|
|||
List<Status> statusList = timelineResponse.body();
|
||||
statuses.statuses = TimelineHelper.filterStatus(getApplication().getApplicationContext(), statusList, timelineParams.type);
|
||||
statuses.pagination = MastodonHelper.getPagination(timelineResponse.headers());
|
||||
|
||||
if (statusList != null && statusList.size() > 0) {
|
||||
for (Status status : statuses.statuses) {
|
||||
StatusCache statusCacheDAO = new StatusCache(getApplication().getApplicationContext());
|
||||
|
|
Loading…
Reference in a new issue