I have an application with database and content provider. In order to display some data from the database in ListView‘s, I useLoaderManager.
It’s simple and works perfectly well in most of case.
But, when to many change notifications from the content provider arrives, the UI is totally overloaded. It happens when there are many inserts, about 15 per seconds, on the uri observed by the cursor. I think even if the cursor load is in background, the large amount of bindView() calls is enough to overload the UI.
So I would like, in some case as above, limit the number of loads (and so onLoadFinished() calls) to something like one per seconds.
-
Is there a way to achieve that with
LoaderManager? I tried to play withstartLoading()andstopLoadingbut without success, and anyway it’s not recommended. -
Or maybe I have to manage a
Loaderby myself, but I will be surprised if this situation is not common.
Thanks for your advice.
EDIT
I actually missed a method… setUpdateThrottle(long delayMS) do exactly what I want.
You can override applyBatch(…) in your content provider and do something like this:
You can use this to batch your inserts into one transaction so notification only happens once.