1

The reason I ask is because I want to display a ProgressDialog throbber in the ActionBar while any AsyncTask started by my main Activity is running.

My current solution (that semi-works) extends the AsyncTaskLoader. In that class I override the onForceLoad() method and add the loader's Id and class name to a Map (keyed on the Loader Id) that is managed in my Application; when a Loader is added to the Map I show the loading throbber in the ActionBar. Whenever a LoaderCallback's onLoadFinished is called I remove the Loader from the Map using the Id and check whether or not the Map is empty. If the Map is empty I stop displaying the laoding throbber.

The problem that I am facing is that if, for instance, 5 Loaders are running and the user clicks refresh which restarts all 5 Loaders again, not all Loader's onLoadFinished will be called. Which results in the loading throbber getting displayed indefinitely because the Map never becomes empty. I think this may have something to do with the way Loaders are throttled but I am not sure.

Alex Lockwood
  • 83,063
  • 39
  • 206
  • 250
oracleicom
  • 918
  • 4
  • 11
  • 19
  • why can't you stop the loaders when they hit refresh? – L7ColWinters Jan 18 '12 at 16:02
  • Well I could but I'm not sure that would solve the problem because I've also seen this happen when loaders trigger other loaders in the onFinishedLoad. For instance once I get the user's location using a Loader I force another Loader to load data based on the new location. In addition, shouldn't the LoaderManager manage the Loades and when they should get executed? – oracleicom Jan 18 '12 at 17:06
  • well there is a destroyLoader method. Just use the latest location that is found when doing your other loaders. – L7ColWinters Jan 18 '12 at 17:17

0 Answers0