I have a ContentProvider
which fetches data from sqlite database and loads it via Loader
. It's updated by a Service
which runs an AsyncTask
to download data from server and update it in the ContentProvider
. I hope it's clear but to be sure:
ListFragment
takes data fromContentProvider
viaLoader
,ContentProvider
gets updated with aService
.
Now, when my local sqlite database is empty the first time I launch the app, it shows that it has no events, even though they're being currently downloaded via Service
. I would rather have a ProgressBar
shown at this moment (the infinite spinning wheel, not a bar). But if I show a ProgressBar
when there are no results from database, it would be there even after fetching data from sever in this specific case when there are no records in the external database (and it occurs quite often in my case). So:
When the data is downloaded for the first time by the
Service
I would like to show a ProgressBar untilContentProvider
gives non-empty result OR theService
finished it's job.When
ContentProvider
returned nothing ANDService
finished it's job (and fetched empty result) I would like the app to show "no results found".
My problem is probably: how to notify the ListFragment
that the Service
is still running or that it finished ts job. I mean - I shouldn't store any reference to the calling Fragment
inside the Service
. It goes against the idea of ContentProviders
, doesn't it? So how?
Note: I don't really know which fragment of code would be helpful here, so if you feel that you need to see some specific frag, just tell me in comments. Thanks!