How to deal with Large number of ClusterItems in Cluster - Android GoogleMaps V2
Solution 1:
Do you use rentMarkerList
anywhere else? If not, you can refactor your code in this way:
rentClusterManager = new ClusterManager<OffersMarker>(this, gmap);
rentClusterRenderer = new OffersClusterRenderer(this, gmap, rentClusterManager);
rentClusterManager.setRenderer(rentClusterRenderer);
for (AdMarker adMarker : adsArray) { //<-- adsArray.size() = 6500
rentClusterManager.addItem(makeOffersMarker(adLocation, nrOfAds, realEstateAdIds, OffersMarker.DEALTYPE.SALE_CODE));
}
rentClusterManager.cluster();
So you don't create an extra list of markers and don't add them all at the same time, but add them one by one.
You can also repleace foreach loop with simple for loop. According to this Android performance patterns episode, it works faster.
I don't think that that will significantly improve the performance, it's just little optimization tips, that may help.