Closed Gloix closed 6 years ago
Maybe an updates.clear()
inside notifyDataSetChanged()
could solve it(?). Unfortunately I cannot quick-fix in my project it since it's a private member 😕.
Would you be able to create a sample project that demonstrates the crash?
Sure, here it is
https://github.com/Gloix/MapMeBug
Remember to use a valid Google Maps Key to test it. Also, note that I don't even have to modify the list of adapted items to trigger the error. I just need to call notifyDataSetChanged()
twice.
Great, thanks for this!
It seems like the fix will be quite simple although it will require a bit of testing.
I don't know if it's a bad use of the library or not, but when performing the following sequence of actions, bad things can occur.
notifyDataSetChanged()
. After that,getItemCount()
gets called, returning 1 as result.notifyDataSetChanged()
. After that,getItemCount()
gets called, returning 0 as result.onCreateAnnotation(...)
with position=0, leading to a crash since there are no items in the list.Apparently, the adapter remembers the first amount of annotations to be added to the map, but the second call to
notifyDataSetChanged()
does not get taken into account.