I have an ArrayList:
ArrayList<GroundOverlayOptions> goArray;
- ca. 2-3k of elements. When i try to display it like this:
for (GroundOverlayOptions temp : goArray) {
map.addGroundOverlay(temp);
}
it takes a lot of UiThread time (ca. 10-15s) and it creates ANR bugs. map.addGroudOverlay() must be run on UiThread. Is there any workaround for this?
content of goArray:
float longitude, float latitude, float width,float height, int color
{
final Bitmap bitmap = Bitmap
.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
bitmap.setPixel(0, 0, color);
final BitmapDescriptor image = BitmapDescriptorFactory
.fromBitmap(bitmap);
final LatLngBounds bounds = new LatLngBounds(new LatLng(latitude
- height / 2, longitude - width / 2), new LatLng(latitude
+ height / 2, longitude + width / 2));
long startTime = System.currentTimeMillis();
GroundOverlayOptions go = new GroundOverlayOptions().image(image)
.positionFromBounds(bounds).transparency(0.33f);
goArray.add(go);
}
Why dont you try AsyncTask to do that?
The place where you doing the loop call AsyncTask to handle this. Pass the goArray to AsyncTask.