[android] - add binding integration for cross source collision

This commit is contained in:
tobrun
2018-09-11 22:11:09 +02:00
committed by Chris Loer
parent d735d89835
commit 5238c77696
8 changed files with 64 additions and 17 deletions

View File

@@ -24,7 +24,6 @@ import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ZoomButtonsController;
import com.mapbox.android.gestures.AndroidGesturesManager;
import com.mapbox.mapboxsdk.MapStrictMode;
import com.mapbox.mapboxsdk.Mapbox;
@@ -48,6 +47,8 @@ import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.storage.FileSource;
import com.mapbox.mapboxsdk.utils.BitmapUtils;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.ref.WeakReference;
@@ -56,9 +57,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import static com.mapbox.mapboxsdk.maps.widgets.CompassView.TIME_MAP_NORTH_ANIMATION;
import static com.mapbox.mapboxsdk.maps.widgets.CompassView.TIME_WAIT_IDLE;
@@ -322,7 +320,8 @@ public class MapView extends FrameLayout implements NativeMapView.ViewCallback {
addView(glSurfaceView, 0);
}
nativeMapView = new NativeMapView(getContext(), getPixelRatio(), this, mapRenderer);
boolean crossSourceCollisions = mapboxMapOptions.getCrossSourceCollisions();
nativeMapView = new NativeMapView(getContext(), getPixelRatio(), crossSourceCollisions, this, mapRenderer);
nativeMapView.addOnMapChangedListener(change -> {
// dispatch events to external listeners
if (!onMapChangedListeners.isEmpty()) {

View File

@@ -82,6 +82,8 @@ public class MapboxMapOptions implements Parcelable {
private float pixelRatio;
private boolean crossSourceCollisions = true;
/**
* Creates a new MapboxMapOptions object.
*/
@@ -131,6 +133,7 @@ public class MapboxMapOptions implements Parcelable {
localIdeographFontFamily = in.readString();
pixelRatio = in.readFloat();
foregroundLoadColor = in.readInt();
crossSourceCollisions = in.readByte() != 0;
}
/**
@@ -232,6 +235,9 @@ public class MapboxMapOptions implements Parcelable {
mapboxMapOptions.foregroundLoadColor(
typedArray.getInt(R.styleable.mapbox_MapView_mapbox_foregroundLoadColor, LIGHT_GRAY)
);
mapboxMapOptions.crossSourceCollisions(
typedArray.getBoolean(R.styleable.mapbox_MapView_mapbox_cross_source_collisions, true)
);
} finally {
typedArray.recycle();
}
@@ -566,6 +572,21 @@ public class MapboxMapOptions implements Parcelable {
return this;
}
/**
* Enable cross-source symbol collision detection, defaults to true.
* <p>
* If set to false, symbol layers will only run collision detection against
* other symbol layers that are part of the same source.
* </p>
*
* @param crossSourceCollisions true to enable, false to disable
* @return This
*/
public MapboxMapOptions crossSourceCollisions(boolean crossSourceCollisions) {
this.crossSourceCollisions = crossSourceCollisions;
return this;
}
/**
* Set the font family for generating glyphs locally for ideographs in the &#x27;CJK Unified Ideographs&#x27;
* and &#x27;Hangul Syllables&#x27; ranges.
@@ -602,6 +623,14 @@ public class MapboxMapOptions implements Parcelable {
return prefetchesTiles;
}
/**
* Check whether cross-source symbol collision detection is enabled.
*
* @return true if enabled
*/
public boolean getCrossSourceCollisions() {
return crossSourceCollisions;
}
/**
* Set the flag to render the map surface on top of another surface.
@@ -945,6 +974,7 @@ public class MapboxMapOptions implements Parcelable {
dest.writeString(localIdeographFontFamily);
dest.writeFloat(pixelRatio);
dest.writeInt(foregroundLoadColor);
dest.writeByte((byte) (crossSourceCollisions ? 1 : 0));
}
@Override
@@ -1050,6 +1080,10 @@ public class MapboxMapOptions implements Parcelable {
return false;
}
if (crossSourceCollisions != options.crossSourceCollisions) {
return false;
}
return false;
}
@@ -1090,6 +1124,7 @@ public class MapboxMapOptions implements Parcelable {
result = 31 * result + (zMediaOverlay ? 1 : 0);
result = 31 * result + (localIdeographFontFamily != null ? localIdeographFontFamily.hashCode() : 0);
result = 31 * result + (int) pixelRatio;
result = 31 * result + (crossSourceCollisions ? 1 : 0);
return result;
}
}

View File

@@ -12,7 +12,6 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import com.mapbox.geojson.Feature;
import com.mapbox.geojson.Geometry;
import com.mapbox.mapboxsdk.LibraryLoader;
@@ -85,18 +84,19 @@ final class NativeMapView {
// Constructors
//
public NativeMapView(final Context context, final ViewCallback viewCallback, final MapRenderer mapRenderer) {
this(context, context.getResources().getDisplayMetrics().density, viewCallback, mapRenderer);
public NativeMapView(final Context context, final boolean crossSourceCollisions, final ViewCallback viewCallback,
final MapRenderer mapRenderer) {
this(context, context.getResources().getDisplayMetrics().density, crossSourceCollisions, viewCallback, mapRenderer);
}
public NativeMapView(final Context context, float pixelRatio,
public NativeMapView(final Context context, final float pixelRatio, final boolean crossSourceCollisions,
final ViewCallback viewCallback, final MapRenderer mapRenderer) {
this.mapRenderer = mapRenderer;
this.viewCallback = viewCallback;
this.fileSource = FileSource.getInstance(context);
this.pixelRatio = pixelRatio;
this.thread = Thread.currentThread();
nativeInitialize(this, fileSource, mapRenderer, pixelRatio);
nativeInitialize(this, fileSource, mapRenderer, pixelRatio, crossSourceCollisions);
}
//
@@ -936,7 +936,8 @@ final class NativeMapView {
private native void nativeInitialize(NativeMapView nativeMapView,
FileSource fileSource,
MapRenderer mapRenderer,
float pixelRatio);
float pixelRatio,
boolean crossSourceCollisions);
@Keep
private native void nativeDestroy();