Skip to content

Commit

Permalink
Merge pull request nitaliano#82 from mfazekas/fix-utm-from-string-null
Browse files Browse the repository at this point in the history
[android] fix ImageEntry map
  • Loading branch information
mfazekas committed Jun 5, 2019
2 parents 475dda9 + 3bdcc16 commit 4d41499
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
import com.mapbox.rctmgl.events.FeatureClickEvent;
import com.mapbox.rctmgl.utils.DownloadMapImageTask;
import com.mapbox.rctmgl.utils.ImageEntry;

import java.net.URL;
import java.util.List;
Expand All @@ -35,7 +36,7 @@ public class RCTMGLShapeSource extends RCTSource<GeoJsonSource> {
private Double mTolerance;
private boolean mRemoved = false;

private List<Map.Entry<String, String>> mImages;
private List<Map.Entry<String, ImageEntry>> mImages;
private List<Map.Entry<String, BitmapDrawable>> mNativeImages;

public RCTMGLShapeSource(Context context, RCTMGLShapeSourceManager manager) {
Expand Down Expand Up @@ -91,7 +92,7 @@ public void removeFromMap(RCTMGLMapView mapView) {
Style style = this.getStyle();
if (style != null) {
if (hasImages()) {
for (Map.Entry<String, String> image : mImages) {
for (Map.Entry<String, ImageEntry> image : mImages) {
style.removeImage(image.getKey());
}
}
Expand Down Expand Up @@ -155,7 +156,7 @@ public void setTolerance(double tolerance) {
mTolerance = tolerance;
}

public void setImages(List<Map.Entry<String, String>> images) {
public void setImages(List<Map.Entry<String, ImageEntry>> images) {
mImages = images;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.media.Image;
import android.util.Log;
import android.view.View;

Expand All @@ -19,6 +20,7 @@
import com.mapbox.rctmgl.components.mapview.RCTMGLMapView;
import com.mapbox.rctmgl.components.styles.layers.RCTLayer;
import com.mapbox.rctmgl.events.constants.EventKeys;
import com.mapbox.rctmgl.utils.ImageEntry;
import com.mapbox.rctmgl.utils.ResourceUtils;

import java.net.MalformedURLException;
Expand Down Expand Up @@ -124,12 +126,12 @@ public void setTolerance(RCTMGLShapeSource source, double tolerance) {

@ReactProp(name = "images")
public void setImages(RCTMGLShapeSource source, ReadableMap map) {
List<Map.Entry<String, String>> images = new ArrayList<>();
List<Map.Entry<String, ImageEntry>> images = new ArrayList<>();

ReadableMapKeySetIterator iterator = map.keySetIterator();
while (iterator.hasNextKey()) {
String imageName = iterator.nextKey();
images.add(new AbstractMap.SimpleEntry<String, String>(imageName, map.getString(imageName)));
images.add(new AbstractMap.SimpleEntry<String, ImageEntry>(imageName, new ImageEntry(map.getString(imageName), 1.0)));
}

source.setImages(images);
Expand Down

0 comments on commit 4d41499

Please sign in to comment.