What I want to do: run a background thread which calculates ListView contents and update ListView partially, while results are calculated.
What I know I have to avoid: I cannot mess with ListAdapter contents from background thread, so I inherited AsyncTask and publish result (add entries to adapter) from onProgressUpdate. My Adapter uses ArrayList of result objects, all operations on those arraylists are synchronized.
Research of other people: there is very valuable data here. I also suffered from almost daily crashes for group of ~500 users, and when I added
`java.lang.IllegalStateException:` The content of the adapter has changed but ListView did not receive a notification. Make sure the content of your adapter is not modified from a background thread, but only from the UI thread. [in ListView(2131296334, class android.widget.ListView) with Adapter(class com.transportoid.Tracks.TrackListAdapter)]
I had the same issue.
I was adding items to my
ArrayList outside the UI thread.
added the items and called
notifyDataSetChanged() in the UI thread and I resolved this.