I'm facing the following problem:
I have a web service of a social network that allows to query a user uploaded videos. The web service signature is:
getUserVideos(String username, int quantity, int offset)
I need to create a gallery with the videos. So basically I request [quantity=10,offset=0] then [quantity=10,offset=10], using a ViewPger for the gallery.
At this point, with the gallery working (and in the position 15 for this example). We need to save the state if the user leaves the app, i.e. pressing the home button. Later, when the user return to the app after some hours, the getUserVideos
service may return different data (i.e. if the given username has uploaded new videos in the meanwhile).
I see two different behaviors but find both wrong.
- Save the list of videos when leaving the app and restore it when the user comes back, since there is new data in the server and the client data is old, the client offsets and the server offsets will not match, returning repeated videos or never returning others.
- Requery to the server keeping the index in the gallery but updating the content (that is return to the video number 15). This will cause that the user returns to see a different video that the one he was seeing before leaving.
What are the common approaches for this kind of problems?