[android] #5076 - fixed update marker for MarkerView, rewrite update marker jni, cleanup animation api

This commit is contained in:
Tobrun
2016-06-06 11:13:40 +02:00
parent 436c23c40b
commit 0a646b4487
9 changed files with 100 additions and 84 deletions

View File

@@ -1,7 +1,6 @@
package com.mapbox.mapboxsdk.annotations;
import android.os.Parcelable;
import android.support.annotation.AnimatorRes;
import android.support.annotation.NonNull;
import com.mapbox.mapboxsdk.geometry.LatLng;
@@ -26,8 +25,6 @@ public abstract class BaseMarkerViewOptions<U extends MarkerView, T extends Base
protected float anchorV = 1f;
protected float infoWindowAnchorU = 0.5f;
protected float infoWindowAnchorV = 0.0f;
protected int selectAnimRes;
protected int deselectAnimRes;
protected int rotation;
protected boolean visible = true;
protected boolean selected;
@@ -119,28 +116,6 @@ public abstract class BaseMarkerViewOptions<U extends MarkerView, T extends Base
return getThis();
}
/**
* Set the animator resource to be used when an MarkerView is selected.
*
* @param selectAnimRes the used animator resource
* @return the object for which the method was called
*/
public T selectAnimatorResource(@AnimatorRes int selectAnimRes) {
this.selectAnimRes = selectAnimRes;
return getThis();
}
/**
* Set the animator resource to be used when an MarkerView is deselected.
*
* @param deselectAnimRes the used animator resource
* @return the object for which the method was called
*/
public T deselectAnimatorResource(@AnimatorRes int deselectAnimRes) {
this.deselectAnimRes = deselectAnimRes;
return getThis();
}
/**
* Set the rotation of the MarkerView.
*
@@ -244,24 +219,6 @@ public abstract class BaseMarkerViewOptions<U extends MarkerView, T extends Base
return infoWindowAnchorV;
}
/**
* Get the animator resource used for selecting the MarkerView.
*
* @return the animator resource
*/
public int getSelectAnimRes() {
return selectAnimRes;
}
/**
* Get the animator resource used for deselecting the MarkerView.
*
* @return the animator resource
*/
public int getDeselectAnimRes() {
return deselectAnimRes;
}
/**
* Get the rotation of the MarkerView.
*

View File

@@ -28,8 +28,6 @@ public class MarkerViewOptions extends BaseMarkerViewOptions<MarkerView, MarkerV
flat(in.readByte() != 0);
anchor(in.readFloat(), in.readFloat());
infoWindowAnchor(in.readFloat(), in.readFloat());
selectAnimatorResource(in.readInt());
deselectAnimatorResource(in.readInt());
rotation(in.readInt());
visible(in.readByte() != 0);
if (in.readByte() != 0) {
@@ -61,8 +59,6 @@ public class MarkerViewOptions extends BaseMarkerViewOptions<MarkerView, MarkerV
out.writeFloat(getAnchorV());
out.writeFloat(getInfoWindowAnchorU());
out.writeFloat(getInfoWindowAnchorV());
out.writeInt(getSelectAnimRes());
out.writeInt(getDeselectAnimRes());
out.writeInt(getRotation());
out.writeByte((byte) (isVisible() ? 1 : 0));
Icon icon = getIcon();

View File

@@ -445,6 +445,7 @@ public class MapView extends FrameLayout {
callback.onMapReady(mMapboxMap);
iterator.remove();
}
mMapboxMap.getMarkerViewManager().scheduleViewMarkerInvalidation();
}
} else if (change == REGION_IS_CHANGING || change == REGION_DID_CHANGE || change == DID_FINISH_LOADING_MAP) {
mMapboxMap.getMarkerViewManager().scheduleViewMarkerInvalidation();
@@ -672,11 +673,11 @@ public class MapView extends FrameLayout {
return mContentPaddingBottom;
}
int getContentWidth(){
int getContentWidth() {
return getWidth() - mContentPaddingLeft - mContentPaddingRight;
}
int getContentHeight(){
int getContentHeight() {
return getHeight() - mContentPaddingBottom - mContentPaddingTop;
}
@@ -993,7 +994,10 @@ public class MapView extends FrameLayout {
Log.w(MapboxConstants.TAG, "marker has an id of -1, possibly was not added yet, doing nothing");
}
ensureIconLoaded(updatedMarker);
if (!(updatedMarker instanceof MarkerView)) {
ensureIconLoaded(updatedMarker);
}
mNativeMapView.updateMarker(updatedMarker);
}
@@ -1021,7 +1025,7 @@ public class MapView extends FrameLayout {
}
long addMarker(@NonNull Marker marker) {
if(mDestroyed){
if (mDestroyed) {
return 0l;
}
return mNativeMapView.addMarker(marker);

View File

@@ -20,7 +20,6 @@ import com.mapbox.mapboxsdk.annotations.Annotation;
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.IconFactory;
import com.mapbox.mapboxsdk.annotations.InfoWindow;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.MarkerOptions;

View File

@@ -7,6 +7,7 @@ import android.graphics.RectF;
import android.os.Build;
import android.view.Surface;
import com.mapbox.mapboxsdk.annotations.Icon;
import com.mapbox.mapboxsdk.annotations.Marker;
import com.mapbox.mapboxsdk.annotations.Polygon;
import com.mapbox.mapboxsdk.annotations.Polyline;
@@ -371,7 +372,9 @@ final class NativeMapView {
}
public void updateMarker(Marker marker) {
nativeUpdateMarker(mNativeMapViewPtr, marker);
LatLng position = marker.getPosition();
Icon icon = marker.getIcon();
nativeUpdateMarker(mNativeMapViewPtr, marker.getId(), position.getLatitude(), position.getLongitude(), icon.getId());
}
public void removeAnnotation(long id) {
@@ -462,7 +465,7 @@ final class NativeMapView {
nativeRemoveCustomLayer(mNativeMapViewPtr, id);
}
public double[] getCameraValues(){
public double[] getCameraValues() {
return nativeGetCameraValues(mNativeMapViewPtr);
}
@@ -591,7 +594,7 @@ final class NativeMapView {
private native long nativeAddMarker(long nativeMapViewPtr, Marker marker);
private native void nativeUpdateMarker(long nativeMapViewPtr, Marker marker);
private native void nativeUpdateMarker(long nativeMapViewPtr, long markerId, double lat, double lon, String iconId);
private native long[] nativeAddMarkers(long nativeMapViewPtr, List<Marker> markers);