[android] - add more tests, refactor map padding
This commit is contained in:
@@ -387,10 +387,11 @@ final class NativeMapView {
|
||||
nativeRotateBy(sx / pixelRatio, sy / pixelRatio, ex, ey, duration);
|
||||
}
|
||||
|
||||
public void setContentPadding(int[] padding) {
|
||||
public void setContentPadding(float[] padding) {
|
||||
if (checkState("setContentPadding")) {
|
||||
return;
|
||||
}
|
||||
// TopLeftBottomRight
|
||||
nativeSetContentPadding(
|
||||
padding[1] / pixelRatio,
|
||||
padding[0] / pixelRatio,
|
||||
@@ -398,6 +399,19 @@ final class NativeMapView {
|
||||
padding[2] / pixelRatio);
|
||||
}
|
||||
|
||||
public float[] getContentPadding() {
|
||||
if (checkState("getContentPadding")) {
|
||||
return new float[] {0, 0, 0, 0};
|
||||
}
|
||||
float[] topLeftBottomRight = nativeGetContentPadding();
|
||||
return new float[]{
|
||||
topLeftBottomRight[1] * pixelRatio,
|
||||
topLeftBottomRight[0] * pixelRatio,
|
||||
topLeftBottomRight[3] * pixelRatio,
|
||||
topLeftBottomRight[2] * pixelRatio
|
||||
};
|
||||
}
|
||||
|
||||
public void setBearing(double degrees) {
|
||||
if (checkState("setBearing")) {
|
||||
return;
|
||||
@@ -1115,7 +1129,10 @@ final class NativeMapView {
|
||||
private native void nativeRotateBy(double sx, double sy, double ex, double ey, long duration);
|
||||
|
||||
@Keep
|
||||
private native void nativeSetContentPadding(double top, double left, double bottom, double right);
|
||||
private native void nativeSetContentPadding(float top, float left, float bottom, float right);
|
||||
|
||||
@Keep
|
||||
private native float[] nativeGetContentPadding();
|
||||
|
||||
@Keep
|
||||
private native void nativeSetBearing(double degrees, long duration);
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.mapbox.mapboxsdk.maps;
|
||||
import android.graphics.PointF;
|
||||
import android.support.annotation.FloatRange;
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.mapbox.geojson.Point;
|
||||
import com.mapbox.mapboxsdk.constants.GeometryConstants;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
@@ -32,7 +31,11 @@ public class Projection {
|
||||
|
||||
void setContentPadding(int[] contentPadding) {
|
||||
this.contentPadding = contentPadding;
|
||||
nativeMapView.setContentPadding(contentPadding);
|
||||
float[] output = new float[contentPadding.length];
|
||||
for (int i = 0; i < contentPadding.length; i++) {
|
||||
output[i] = contentPadding[i];
|
||||
}
|
||||
nativeMapView.setContentPadding(output);
|
||||
}
|
||||
|
||||
int[] getContentPadding() {
|
||||
@@ -121,10 +124,10 @@ public class Projection {
|
||||
top = 0;
|
||||
bottom = nativeMapView.getHeight();
|
||||
} else {
|
||||
left = contentPadding[0];
|
||||
right = nativeMapView.getWidth() - contentPadding[2];
|
||||
top = contentPadding[1];
|
||||
bottom = nativeMapView.getHeight() - contentPadding[3];
|
||||
left = (float) contentPadding[0];
|
||||
right = (float) (nativeMapView.getWidth() - contentPadding[2]);
|
||||
top = (float) contentPadding[1];
|
||||
bottom = (float) (nativeMapView.getHeight() - contentPadding[3]);
|
||||
}
|
||||
|
||||
LatLng center = fromScreenLocation(new PointF(left + (right - left) / 2, top + (bottom - top) / 2));
|
||||
|
||||
Reference in New Issue
Block a user