mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2025-06-23 21:50:10 +03:00
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 + "' ";
|
selection += "AND " + Sqlite.COL_STATUS_ID + " > '" + since_id + "' ";
|
||||||
limit = null;
|
limit = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Cursor c = db.query(Sqlite.TABLE_STATUS_CACHE, null, selection, null, null, null, Sqlite.COL_STATUS_ID + order, limit);
|
Cursor c = db.query(Sqlite.TABLE_STATUS_CACHE, null, selection, null, null, null, Sqlite.COL_STATUS_ID + order, limit);
|
||||||
return createStatusReply(cursorToListOfStatuses(c));
|
return createStatusReply(cursorToListOfStatuses(c));
|
||||||
|
|
|
@ -404,6 +404,9 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
}
|
}
|
||||||
//Update the timeline with new statuses
|
//Update the timeline with new statuses
|
||||||
updateStatusListWith(fetched_statuses.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 (!fetchingMissing) {
|
||||||
if (fetched_statuses.pagination.max_id == null) {
|
if (fetched_statuses.pagination.max_id == null) {
|
||||||
flagLoading = true;
|
flagLoading = true;
|
||||||
|
@ -427,7 +430,8 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
*
|
*
|
||||||
* @param statusListReceived - List<Status> Statuses received
|
* @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) {
|
if (statusListReceived != null && statusListReceived.size() > 0) {
|
||||||
for (Status statusReceived : statusListReceived) {
|
for (Status statusReceived : statusListReceived) {
|
||||||
int position = 0;
|
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) {
|
if (!timelineStatuses.contains(statusReceived) && !statusReceived.pinned && timelineType != Timeline.TimeLineEnum.ACCOUNT_TIMELINE) {
|
||||||
timelineStatuses.add(position, statusReceived);
|
timelineStatuses.add(position, statusReceived);
|
||||||
statusAdapter.notifyItemInserted(position);
|
statusAdapter.notifyItemInserted(position);
|
||||||
|
inserted++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -457,6 +462,7 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return inserted;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -604,10 +610,10 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
|
|
||||||
});
|
});
|
||||||
} else if (direction == DIRECTION.REFRESH || direction == DIRECTION.SCROLL_TOP) {
|
} else if (direction == DIRECTION.REFRESH || direction == DIRECTION.SCROLL_TOP) {
|
||||||
timelinesVM.getTimelineCache(timelineStatuses, timelineParams)
|
timelinesVM.getTimeline(timelineStatuses, timelineParams)
|
||||||
.observe(getViewLifecycleOwner(), statusesRefresh -> {
|
.observe(getViewLifecycleOwner(), statusesRefresh -> {
|
||||||
if (statusesRefresh == null || statusesRefresh.statuses == null || statusesRefresh.statuses.size() == 0) {
|
if (statusesRefresh == null || statusesRefresh.statuses == null || statusesRefresh.statuses.size() == 0) {
|
||||||
getLiveStatus(direction, fetchingMissing, timelineParams);
|
getCachedStatus(direction, fetchingMissing, timelineParams);
|
||||||
} else {
|
} else {
|
||||||
if (statusAdapter != null) {
|
if (statusAdapter != null) {
|
||||||
dealWithPagination(statusesRefresh, direction, true);
|
dealWithPagination(statusesRefresh, direction, true);
|
||||||
|
|
|
@ -395,7 +395,6 @@ public class TimelinesVM extends AndroidViewModel {
|
||||||
List<Status> statusList = timelineResponse.body();
|
List<Status> statusList = timelineResponse.body();
|
||||||
statuses.statuses = TimelineHelper.filterStatus(getApplication().getApplicationContext(), statusList, timelineParams.type);
|
statuses.statuses = TimelineHelper.filterStatus(getApplication().getApplicationContext(), statusList, timelineParams.type);
|
||||||
statuses.pagination = MastodonHelper.getPagination(timelineResponse.headers());
|
statuses.pagination = MastodonHelper.getPagination(timelineResponse.headers());
|
||||||
|
|
||||||
if (statusList != null && statusList.size() > 0) {
|
if (statusList != null && statusList.size() > 0) {
|
||||||
for (Status status : statuses.statuses) {
|
for (Status status : statuses.statuses) {
|
||||||
StatusCache statusCacheDAO = new StatusCache(getApplication().getApplicationContext());
|
StatusCache statusCacheDAO = new StatusCache(getApplication().getApplicationContext());
|
||||||
|
|
Loading…
Reference in a new issue