-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Organise annotations function definitions #2539
Comments
Doing some testing and noticed we get crash due to unmodifiable lists. Will convert everything to use normal lists and make Will do this tomorrow as I am out of time. |
Ah addMarkers should use a List of MarkerOptions, my bad! Just one remark to the commit: Marker m;
int count = markers.size();
for (int i = 0; i < count; i++) {
m = markers.get(i);
m.setId(ids[i]);
m.setMapView(this);
mAnnotations.add(m); Instead of: for (int i = 0; i < markers.size(); i++) {
markers.get(i).setId(ids[i]);
markers.get(i).setMapView(this);
mAnnotations.add(markers.get(i));
} The whole reason behind this is that this code needs to be scalable, eg iOS sample is adding 1000 markers. In second code snippet this will result in a lot of garbage objects while in first snippet this will not. Jake Wharton has created a nice presentation on this subject. |
@tobrun Ah interesting. I'll copy your code to the other methods then. I also optimised our |
@tobrun I changed to use the faster for loop for markers, and polylines. I changed to use shallow List copies. Finally I renamed |
Changed the milestone as I think this is something we should get in to v2.1.0 so that I can JavaDoc the tidier functions. |
While working on #2002 I noticed the
MapView
annotation functions need a bit of a tidy up as they do not follow a logical pattern.E.g.
addMarker
is the only function that takes aMarker
object directly not a...Options
object. Important for this API which is supposed to take a mutable object and return a immutable object (#2538 will need this).I made a pass at fixing this and will push to a branch.
The text was updated successfully, but these errors were encountered: