I have ArrayList of custom objects that is the data underlying an ArrayAdapter for a ListView.
Sometimes this data is modified in a batch, such as fetching a set of new items from the web. When the data is modified in a batch, should notifyDataSetChanged() be called after every add() to the ArrayList
Some over simplified code:
for(Object object : newObjects){
list.add(object);
adapter.notifyDataSetChanged();
}
or should it be called once after all of the items in the batch have been added?
for(Object object : newObjects){
list.add(object);
}
adapter.notifyDataSetChanged()
Say there is a batch of 50 new objects. If 50 notifyDataSetChanged() calls are made right after another, like in the first example, will the views redraw themselves 50 times in a row (I imagine a major performance hit) or will it only perform the latest call and in a sense only redraw them once?
I'm basically wondering if I can use the first method or will it have a major performance impact?
Thanks