How not to notify cursor very often after URI data changes
I have very common situation: activity displays ListView with data from CursorAdapter (items from feed), and cursor is being notified by ContentProvider about changes in data by its URI.
The problem appears when very many items are inserted (thousands of items), so UI becomes unresponsive after notifications. So i need to set more coarse notifications.
My ideas are:
- Do开发者_高级运维 not notify, requery by myself, e.g. every 1 second
- Save notification time in ContentProvider, and notify if it is older than 1 sec.
Any common solutions of this situation?
Thanks.
You should probably handle the notifications and updating of the adapter in an AsyncTask to keep the UI responsive. Combined with correct use of bindView and newView, you'll probably find your UI is much more responsive. See Moving CursorAdapter cursor creation to background thread and Android CursorAdapters, ListViews and background threads for a little more information.
精彩评论