0

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:

  1. Do not notify, requery by myself, e.g. every 1 second
  2. Save notification time in ContentProvider, and notify if it is older than 1 sec.

Any common solutions of this situation?

Thanks.

kzotin
  • 5,365
  • 3
  • 29
  • 36

1 Answers1

0

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.

Community
  • 1
  • 1
RivieraKid
  • 5,923
  • 4
  • 38
  • 47
  • Cursor is populated in background with AsyncQueryHandler, and Views are recycled correctly. UI is responding perfectly when database is not changing – kzotin Feb 05 '11 at 12:51
  • In that case, it would probably help if you post the code that you are using when populating the listview, and for handling the updates - it almost sounds like something is blocking the UI thread, but it's impossible to say based on the info in your question. – RivieraKid Feb 06 '11 at 16:59