I know that this question has been asked too many times, but I think that the problems I'm trying to set up are slightly different from each other, maybe more complicated.
I am going to develop an application that uses the RESTful Web Service and should have the following requirements:
the application should show some books, their authors and their editors in lists and in detail
the application must also allow book search
books, authors, and editors retrieved from the RESTful web service
each object must be cached, so when I open an action, I first see the old data (if any), and the new one is updated from the network.
every time an object is updated, stakeholders must be notified ( ContentObserver
? Regular Listener
implementation?)
If the call is already being made (for example, api/books/1337
or api/editors
), the caller must be informed that he is downloading data and the old one (if one exists) should be indicated, as if he were the original caller.
some data (only books and authors) should be updated every N minutes (user-defined), and observers should be notified ( SyncAdapter
?)
Questions:
After reviewing and exploring all the components suggested by Virgil Dobrzanski in Google I / O 2010 , I doubt:
How can I transparently handle the concept of an update-entity for any caller? Do I have to use ContentObserver
in the ContentProvider
I have to implement?
If I use ContentObserver
, I can easily set the status flag for a single object (as suggested by Dobjanschi) like UPDATING
, INSERTING
and soon. But how should I handle the list? Say I need a list of books, where should I put the status flag? Should I put it in a status table for lists only? If so, I should observe two Cursor
s, one for status and one for the actual list (i.e. Tables / Content URI). And what if the entity I am asking for does not yet exist, or a REST call returns 404
? How to handle a callback?
If I put all my REST methods in **SyncAdapter**
, can I make "t24" update the list of entities / entities from the network (and therefore put it in the right table)? Thus, the status flag will be useful.
Can SyncAdapter
work with several objects (in fact, lists of entities, since I want to periodically update books and editors), since it only has a performSync
method?
If my implementation of SyncAdapter
was disabled by the user in the device settings, it will not update anything (and this is fine). But if the user clicks the Refresh Books button in the Activity, can I still call the performSync
method, or will it also be disabled?
source share