forked from mirrors/Fedilab
Some improvements with timelines
This commit is contained in:
parent
50f9cb2b7b
commit
f9c3393c5e
3 changed files with 17 additions and 8 deletions
|
@ -652,6 +652,7 @@ public class StatusCache {
|
||||||
List<Status> statusList = new ArrayList<>();
|
List<Status> statusList = new ArrayList<>();
|
||||||
while (c.moveToNext()) {
|
while (c.moveToNext()) {
|
||||||
Status status = convertCursorToStatus(c);
|
Status status = convertCursorToStatus(c);
|
||||||
|
status.cached = true;
|
||||||
statusList.add(status);
|
statusList.add(status);
|
||||||
}
|
}
|
||||||
//Close the cursor
|
//Close the cursor
|
||||||
|
@ -674,6 +675,7 @@ public class StatusCache {
|
||||||
List<Notification> notificationList = new ArrayList<>();
|
List<Notification> notificationList = new ArrayList<>();
|
||||||
while (c.moveToNext()) {
|
while (c.moveToNext()) {
|
||||||
Notification notification = convertCursorToNotification(c);
|
Notification notification = convertCursorToNotification(c);
|
||||||
|
notification.cached = true;
|
||||||
notificationList.add(notification);
|
notificationList.add(notification);
|
||||||
}
|
}
|
||||||
//Close the cursor
|
//Close the cursor
|
||||||
|
@ -697,6 +699,7 @@ public class StatusCache {
|
||||||
List<Conversation> conversationList = new ArrayList<>();
|
List<Conversation> conversationList = new ArrayList<>();
|
||||||
while (c.moveToNext()) {
|
while (c.moveToNext()) {
|
||||||
Conversation conversation = convertCursorToConversation(c);
|
Conversation conversation = convertCursorToConversation(c);
|
||||||
|
conversation.cached = true;
|
||||||
conversationList.add(conversation);
|
conversationList.add(conversation);
|
||||||
}
|
}
|
||||||
//Close the cursor
|
//Close the cursor
|
||||||
|
|
|
@ -425,8 +425,6 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||||
binding.recyclerView.setLayoutManager(mLayoutManager);
|
binding.recyclerView.setLayoutManager(mLayoutManager);
|
||||||
binding.recyclerView.setAdapter(statusAdapter);
|
binding.recyclerView.setAdapter(statusAdapter);
|
||||||
//Fetching new messages
|
|
||||||
route(DIRECTION.FETCH_NEW, true);
|
|
||||||
|
|
||||||
if (searchCache == null && timelineType != Timeline.TimeLineEnum.TREND_MESSAGE) {
|
if (searchCache == null && timelineType != Timeline.TimeLineEnum.TREND_MESSAGE) {
|
||||||
binding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
binding.recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||||
|
@ -461,6 +459,10 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
//For home (first tab) we fetch new messages
|
||||||
|
if (timelineType == Timeline.TimeLineEnum.HOME) {
|
||||||
|
route(DIRECTION.FETCH_NEW, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -576,11 +578,16 @@ public class FragmentMastodonTimeline extends Fragment implements StatusAdapter.
|
||||||
}
|
}
|
||||||
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(requireActivity());
|
||||||
boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true);
|
boolean useCache = sharedpreferences.getBoolean(getString(R.string.SET_USE_CACHE), true);
|
||||||
if (useCache && direction != DIRECTION.SCROLL_TOP && direction != DIRECTION.FETCH_NEW) {
|
|
||||||
getCachedStatus(direction, fetchingMissing, timelineParams);
|
Handler handler = new Handler();
|
||||||
} else {
|
//The action for fetching new messages is delayed for other timelines than HOME
|
||||||
getLiveStatus(direction, fetchingMissing, timelineParams, status);
|
handler.postDelayed(() -> {
|
||||||
}
|
if (useCache && direction != DIRECTION.SCROLL_TOP && direction != DIRECTION.FETCH_NEW) {
|
||||||
|
getCachedStatus(direction, fetchingMissing, timelineParams);
|
||||||
|
} else {
|
||||||
|
getLiveStatus(direction, fetchingMissing, timelineParams, status);
|
||||||
|
}
|
||||||
|
}, timelineType == Timeline.TimeLineEnum.HOME ? 0 : 1000);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -461,7 +461,6 @@ public class TimelinesVM extends AndroidViewModel {
|
||||||
List<Status> notPresentStatuses = new ArrayList<>();
|
List<Status> notPresentStatuses = new ArrayList<>();
|
||||||
for (Status status : statuses.statuses) {
|
for (Status status : statuses.statuses) {
|
||||||
if (!timelineStatuses.contains(status)) {
|
if (!timelineStatuses.contains(status)) {
|
||||||
status.cached = true;
|
|
||||||
notPresentStatuses.add(status);
|
notPresentStatuses.add(status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue