P
P
penexe2016-01-21 06:51:10
Android
penexe, 2016-01-21 06:51:10

How to make categories for recyclerview elements that are loaded from the web?

Tell your friends how to do this.
There is a news feed, it is loaded from the network and saved to the database, such as a cache.
Loading occurs through an infinite scroll and swipe to refresh events. The main condition is the date of the news. Those in the request to the web service, I use the date of the last loaded news (it will be the first in the list), and the date of the first (the one that turns out to be the last when scrolling).
If I additionally indicate the category in the requests, it will turn out that the next time I load news from an infrequently updated category, the date of the last. the news will be very old, and returning, for example, to the general news feed in the application, and trying to download the news further, they will be even older. those part of the news for a certain period of time will not be loaded.
How to make such a tape?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
paldraken, 2016-01-21
@paldraken

Treat the cache as short-lived data. The task of which is to avoid repeated requests to the network when recreating the activity (for example, when the screen is rotated). And when changing filters or categories, it is worth invalidating the cache and getting the data again.

A
Alexey Perelygin, 2016-01-21
@orcDamnar

In general, a little strange logic. For paging, it is better to specify not the time period, but the start time (last news) + the number of news in the pack. as a result, do not depend on the lower bound.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question