Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ public void setMapZoom(float zoom) {
}

@SuppressLint("NewApi")
@Override
public void run() {
if (!shouldRender(immutableOf(DefaultAdvancedMarkersClusterRenderer.this.mClusters), immutableOf(clusters))) {
mCallback.run();
Expand Down Expand Up @@ -641,13 +642,16 @@ private MarkerModifier() {
*/
public void add(boolean priority, CreateMarkerTask c) {
lock.lock();
sendEmptyMessage(BLANK);
if (priority) {
mOnScreenCreateMarkerTasks.add(c);
} else {
mCreateMarkerTasks.add(c);
try {
sendEmptyMessage(BLANK);
if (priority) {
mOnScreenCreateMarkerTasks.add(c);
} else {
mCreateMarkerTasks.add(c);
}
} finally {
lock.unlock();
}
lock.unlock();
}

/**
Expand All @@ -658,13 +662,16 @@ public void add(boolean priority, CreateMarkerTask c) {
*/
public void remove(boolean priority, Marker m) {
lock.lock();
sendEmptyMessage(BLANK);
if (priority) {
mOnScreenRemoveMarkerTasks.add(m);
} else {
mRemoveMarkerTasks.add(m);
try {
sendEmptyMessage(BLANK);
if (priority) {
mOnScreenRemoveMarkerTasks.add(m);
} else {
mRemoveMarkerTasks.add(m);
}
} finally {
lock.unlock();
}
lock.unlock();
}

/**
Expand All @@ -676,8 +683,11 @@ public void remove(boolean priority, Marker m) {
*/
public void animate(MarkerWithPosition marker, LatLng from, LatLng to) {
lock.lock();
mAnimationTasks.add(new AnimationTask(marker, from, to));
lock.unlock();
try {
mAnimationTasks.add(new AnimationTask(marker, from, to));
} finally {
lock.unlock();
}
}

/**
Expand All @@ -690,10 +700,13 @@ public void animate(MarkerWithPosition marker, LatLng from, LatLng to) {
*/
public void animateThenRemove(MarkerWithPosition marker, LatLng from, LatLng to) {
lock.lock();
AnimationTask animationTask = new AnimationTask(marker, from, to);
animationTask.removeOnAnimationComplete(mClusterManager.getMarkerManager());
mAnimationTasks.add(animationTask);
lock.unlock();
try {
AnimationTask animationTask = new AnimationTask(marker, from, to);
animationTask.removeOnAnimationComplete(mClusterManager.getMarkerManager());
mAnimationTasks.add(animationTask);
} finally {
lock.unlock();
}
}

@Override
Expand Down Expand Up @@ -757,8 +770,8 @@ private void removeMarker(Marker m) {
* @return true if there is still work to be processed.
*/
public boolean isBusy() {
lock.lock();
try {
lock.lock();
return !(mCreateMarkerTasks.isEmpty() && mOnScreenCreateMarkerTasks.isEmpty() &&
mOnScreenRemoveMarkerTasks.isEmpty() && mRemoveMarkerTasks.isEmpty() &&
mAnimationTasks.isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ public void setMapZoom(float zoom) {
}

@SuppressLint("NewApi")
@Override
public void run() {
if (!shouldRender(immutableOf(DefaultClusterRenderer.this.mClusters), immutableOf(clusters))) {
mCallback.run();
Expand Down Expand Up @@ -632,13 +633,16 @@ private MarkerModifier() {
*/
public void add(boolean priority, CreateMarkerTask c) {
lock.lock();
sendEmptyMessage(BLANK);
if (priority) {
mOnScreenCreateMarkerTasks.add(c);
} else {
mCreateMarkerTasks.add(c);
try {
sendEmptyMessage(BLANK);
if (priority) {
mOnScreenCreateMarkerTasks.add(c);
} else {
mCreateMarkerTasks.add(c);
}
} finally {
lock.unlock();
}
lock.unlock();
}

/**
Expand All @@ -649,13 +653,16 @@ public void add(boolean priority, CreateMarkerTask c) {
*/
public void remove(boolean priority, Marker m) {
lock.lock();
sendEmptyMessage(BLANK);
if (priority) {
mOnScreenRemoveMarkerTasks.add(m);
} else {
mRemoveMarkerTasks.add(m);
try {
sendEmptyMessage(BLANK);
if (priority) {
mOnScreenRemoveMarkerTasks.add(m);
} else {
mRemoveMarkerTasks.add(m);
}
} finally {
lock.unlock();
}
lock.unlock();
}

/**
Expand All @@ -667,8 +674,11 @@ public void remove(boolean priority, Marker m) {
*/
public void animate(MarkerWithPosition marker, LatLng from, LatLng to) {
lock.lock();
mAnimationTasks.add(new AnimationTask(marker, from, to));
lock.unlock();
try {
mAnimationTasks.add(new AnimationTask(marker, from, to));
} finally {
lock.unlock();
}
}

/**
Expand All @@ -681,10 +691,13 @@ public void animate(MarkerWithPosition marker, LatLng from, LatLng to) {
*/
public void animateThenRemove(MarkerWithPosition marker, LatLng from, LatLng to) {
lock.lock();
AnimationTask animationTask = new AnimationTask(marker, from, to);
animationTask.removeOnAnimationComplete(mClusterManager.getMarkerManager());
mAnimationTasks.add(animationTask);
lock.unlock();
try {
AnimationTask animationTask = new AnimationTask(marker, from, to);
animationTask.removeOnAnimationComplete(mClusterManager.getMarkerManager());
mAnimationTasks.add(animationTask);
} finally {
lock.unlock();
}
}

@Override
Expand Down Expand Up @@ -748,8 +761,8 @@ private void removeMarker(Marker m) {
* @return true if there is still work to be processed.
*/
public boolean isBusy() {
lock.lock();
try {
lock.lock();
return !(mCreateMarkerTasks.isEmpty() && mOnScreenCreateMarkerTasks.isEmpty() &&
mOnScreenRemoveMarkerTasks.isEmpty() && mRemoveMarkerTasks.isEmpty() &&
mAnimationTasks.isEmpty()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ public void addLayerToMap() {
*
* @return iterable of Feature elements
*/
@Override
@SuppressWarnings("unchecked")
public Iterable<GeoJsonFeature> getFeatures() {
return (Iterable<GeoJsonFeature>) super.getFeatures();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private static KmlContainer assignPropertiesToContainer(XmlPullParser parser)
String containerId = null;
HashMap<String, String> containerProperties = new HashMap<String, String>();
HashMap<String, KmlStyle> containerStyles = new HashMap<String, KmlStyle>();
HashMap<? extends Feature, Object> containerPlacemarks = new HashMap<>();
HashMap<KmlPlacemark, Object> containerPlacemarks = new HashMap<>();
ArrayList<KmlContainer> nestedContainers = new ArrayList<KmlContainer>();
HashMap<String, String> containerStyleMaps = new HashMap<String, String>();
HashMap<KmlGroundOverlay, GroundOverlay> containerGroundOverlays
Expand All @@ -105,7 +105,7 @@ private static KmlContainer assignPropertiesToContainer(XmlPullParser parser)
} else if (parser.getName().equals(STYLE)) {
setContainerStyle(parser, containerStyles);
} else if (parser.getName().equals(PLACEMARK)) {
setContainerPlacemark(parser, (HashMap<KmlPlacemark, Object>) containerPlacemarks);
setContainerPlacemark(parser, containerPlacemarks);
} else if (parser.getName().equals(EXTENDED_DATA)) {
setExtendedDataProperties(parser, containerProperties);
} else if (parser.getName().equals(GROUND_OVERLAY)) {
Expand All @@ -116,7 +116,7 @@ private static KmlContainer assignPropertiesToContainer(XmlPullParser parser)
eventType = parser.next();
}

return new KmlContainer(containerProperties, containerStyles, (HashMap<KmlPlacemark, Object>) containerPlacemarks,
return new KmlContainer(containerProperties, containerStyles, containerPlacemarks,
containerStyleMaps, nestedContainers, containerGroundOverlays, containerId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

import com.google.android.gms.maps.GoogleMap;
import com.google.maps.android.collections.GroundOverlayManager;
import com.google.maps.android.data.Layer;
import com.google.maps.android.collections.MarkerManager;
import com.google.maps.android.collections.PolygonManager;
import com.google.maps.android.collections.PolylineManager;
import com.google.maps.android.data.Layer;
import com.google.maps.android.data.Renderer;

import org.xmlpull.v1.XmlPullParser;
Expand All @@ -39,6 +39,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Locale;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

Expand Down Expand Up @@ -337,7 +338,7 @@ public KmlLayer(GoogleMap map,
if (entryCount > maxKmzEntryCount) {
throw new IOException("Zip bomb detected! Max number of entries exceeded: " + maxKmzEntryCount);
}
if (parser == null && entry.getName().toLowerCase().endsWith(".kml")) {
if (parser == null && entry.getName().toLowerCase(Locale.ROOT).endsWith(".kml")) {
parser = parseKml(countingStream);
} else {
Bitmap bitmap = BitmapFactory.decodeStream(countingStream);
Expand Down Expand Up @@ -474,6 +475,7 @@ public Iterable<KmlPlacemark> getPlacemarks() {
*
* @return true if there is at least 1 container within the KmlLayer, false otherwise
*/
@Override
public boolean hasContainers() {
return super.hasContainers();
}
Expand All @@ -483,6 +485,7 @@ public boolean hasContainers() {
*
* @return iterable of KmlContainerInterface objects
*/
@Override
public Iterable<KmlContainer> getContainers() {
return super.getContainers();
}
Expand All @@ -492,6 +495,7 @@ public Iterable<KmlContainer> getContainers() {
*
* @return iterable of KmlGroundOverlay objects
*/
@Override
public Iterable<KmlGroundOverlay> getGroundOverlays() {
return super.getGroundOverlays();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ public void addLayerToMap() {
*
* @param map map to place placemark, container, style and ground overlays on
*/
@Override
public void setMap(GoogleMap map) {
removeLayerFromMap();
super.setMap(map);
Expand Down Expand Up @@ -499,6 +500,7 @@ private void downloadGroundOverlays() {
private void addGroundOverlayToMap(String groundOverlayUrl,
HashMap<KmlGroundOverlay, GroundOverlay> groundOverlays, boolean containerVisibility) {
BitmapDescriptor groundOverlayBitmap = getCachedGroundOverlayImage(groundOverlayUrl);
HashMap<KmlGroundOverlay, GroundOverlay> groundOverlaysToUpdate = new HashMap<>();
for (KmlGroundOverlay kmlGroundOverlay : groundOverlays.keySet()) {
if (kmlGroundOverlay.getImageUrl().equals(groundOverlayUrl)) {
GroundOverlayOptions groundOverlayOptions = kmlGroundOverlay.getGroundOverlayOptions()
Expand All @@ -507,9 +509,10 @@ private void addGroundOverlayToMap(String groundOverlayUrl,
if (!containerVisibility) {
mapGroundOverlay.setVisible(false);
}
groundOverlays.put(kmlGroundOverlay, mapGroundOverlay);
groundOverlaysToUpdate.put(kmlGroundOverlay, mapGroundOverlay);
}
}
groundOverlays.putAll(groundOverlaysToUpdate);
}

/**
Expand Down
Loading