Skip to content

Commit

Permalink
update maps sdk to latest beta
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Mar 27, 2018
1 parent a015408 commit ba9a875
Show file tree
Hide file tree
Showing 10 changed files with 227 additions and 242 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public void whenMapCameraInitializesTilted_iconsGetPlacedWithCorrectOffset() thr
locationLayerPlugin.setRenderMode(RenderMode.NORMAL);
locationLayerPlugin.forceLocationUpdate(location);
SymbolLayer layer = mapboxMap.getLayerAs(FOREGROUND_LAYER);
uiController.loopMainThreadForAtLeast(200);
Float[] value = layer.getIconOffset().getValue();
Assert.assertEquals((-0.05 * 60), value[1], 0.1);
});
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,25 @@

import timber.log.Timber;

import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.OnMapReadyCallback;

import java.lang.reflect.Field;

public class OnMapReadyIdlingResource implements IdlingResource {
public class OnMapReadyIdlingResource implements IdlingResource, OnMapReadyCallback {

private final Activity activity;
private MapboxMap mapboxMap;
private IdlingResource.ResourceCallback resourceCallback;

public OnMapReadyIdlingResource(Activity activity) {
this.activity = activity;
try {
Field field = activity.getClass().getDeclaredField("mapView");
field.setAccessible(true);
((MapView) field.get(activity)).getMapAsync(this);
} catch (Exception err) {
throw new RuntimeException(err);
}
}

@Override
Expand All @@ -26,32 +33,23 @@ public String getName() {

@Override
public boolean isIdleNow() {
boolean idle = isMapboxMapReady();
if (idle && resourceCallback != null) {
resourceCallback.onTransitionToIdle();
}
return idle;
return mapboxMap != null;
}

@Override
public void registerIdleTransitionCallback(ResourceCallback resourceCallback) {
this.resourceCallback = resourceCallback;
}

private boolean isMapboxMapReady() {
try {
Field field = activity.getClass().getDeclaredField("mapboxMap");
field.setAccessible(true);
mapboxMap = (MapboxMap) field.get(activity);
Timber.e("isMapboxReady called with value " + (mapboxMap != null));
return mapboxMap != null;
} catch (Exception exception) {
Timber.e("could not reflect", exception);
return false;
}
}

public MapboxMap getMapboxMap() {
return mapboxMap;
}

@Override
public void onMapReady(MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
if (resourceCallback != null) {
resourceCallback.onTransitionToIdle();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public boolean onOptionsItemSelected(MenuItem item) {
return super.onOptionsItemSelected(item);
}


switch (item.getItemId()) {
case R.id.menu_building_min_zoom:
buildingPlugin.setMinZoomLevel(14);
Expand Down
2 changes: 1 addition & 1 deletion gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ext {
]

version = [
mapboxMapSdk : '6.0.0-beta.3',
mapboxMapSdk : '6.0.0-beta.5',
mapboxGeocoding : '3.0.0-beta.3',
mapboxGeoJson : '3.0.0-beta.3',
mapboxServices : '2.2.10',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@

import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.style.functions.Function;
import com.mapbox.mapboxsdk.style.layers.FillExtrusionLayer;
import com.mapbox.mapboxsdk.style.light.Light;

import static com.mapbox.mapboxsdk.constants.MapboxConstants.MAXIMUM_ZOOM;
import static com.mapbox.mapboxsdk.constants.MapboxConstants.MINIMUM_ZOOM;
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.get;
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
import static com.mapbox.mapboxsdk.style.expressions.Expression.literal;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.fillExtrusionColor;
Expand Down Expand Up @@ -93,13 +96,14 @@ private void initLayer(String belowLayer) {
fillExtrusionLayer.setProperties(
visibility(visible ? VISIBLE : NONE),
fillExtrusionColor(color),
fillExtrusionHeight(Function.composite(
"height",
exponential(
stop(15f, 0f, fillExtrusionHeight(0f)),
stop(16f, 0f, fillExtrusionHeight(0f)),
stop(16f, 1000f, fillExtrusionHeight(1000f))
))),
fillExtrusionHeight(
interpolate(
exponential(1f),
zoom(),
stop(15, literal(0)),
stop(16, get("height"))
)
),
fillExtrusionOpacity(opacity)
);
addLayer(fillExtrusionLayer, belowLayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@
import static com.mapbox.mapboxsdk.plugins.locationlayer.Utils.generateShadow;
import static com.mapbox.mapboxsdk.plugins.locationlayer.Utils.getBitmapFromDrawable;
import static com.mapbox.mapboxsdk.plugins.locationlayer.Utils.getDrawable;
import static com.mapbox.mapboxsdk.style.functions.Function.zoom;
import static com.mapbox.mapboxsdk.style.functions.stops.Stop.stop;
import static com.mapbox.mapboxsdk.style.functions.stops.Stops.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.exponential;
import static com.mapbox.mapboxsdk.style.expressions.Expression.interpolate;
import static com.mapbox.mapboxsdk.style.expressions.Expression.stop;
import static com.mapbox.mapboxsdk.style.expressions.Expression.zoom;
import static com.mapbox.mapboxsdk.style.layers.Property.ICON_ROTATION_ALIGNMENT_MAP;
import static com.mapbox.mapboxsdk.style.layers.Property.NONE;
import static com.mapbox.mapboxsdk.style.layers.Property.VISIBLE;
Expand Down Expand Up @@ -164,14 +165,14 @@ private void addSymbolLayer(String layerId, String beforeLayerId) {
layer.setProperties(
iconAllowOverlap(true),
iconIgnorePlacement(true),
iconSize(zoom(
exponential(
stop(22f, iconSize(1f)),
stop(12f, iconSize(1f)),
stop(10f, iconSize(0.6f)),
stop(0f, iconSize(0.6f))
).withBase(1f)
)),
iconSize(
interpolate(exponential(1f), zoom(),
stop(22f, 1f),
stop(12f, 1f),
stop(10f, 0.6f),
stop(0f, 0.6f)
)
),
iconRotationAlignment(ICON_ROTATION_ALIGNMENT_MAP));
addLayerToMap(layer, beforeLayerId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ private void cancelCameraCompassAnimations() {
}

private void resetCameraCompassAnimation(CameraPosition currentCameraPosition) {
if (cameraCompassBearingAnimator == null) {
if (cameraCompassBearingAnimator == null || cameraLatLngAnimator == null) {
return;
}
long duration = cameraLatLngAnimator.getDuration();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void initializeOptions(LocationLayerOptions options) {
}

void setCameraMode(@CameraMode.Mode int cameraMode) {
boolean wasTracking = isLocationTracking();
final boolean wasTracking = isLocationTracking();
this.cameraMode = cameraMode;
mapboxMap.cancelTransitions();
adjustGesturesThresholds();
Expand Down Expand Up @@ -120,7 +120,7 @@ private void notifyCameraTrackingChangeListener(boolean wasTracking) {
internalCameraTrackingChangedListener.onCameraTrackingChanged(cameraMode);
if (wasTracking && !isLocationTracking()) {
mapboxMap.getUiSettings().setFocalPoint(null);
moveGestureDetector.setMoveThreshold(moveGestureDetector.getDefaultMoveThreshold());
moveGestureDetector.setMoveThreshold(0f);
internalCameraTrackingChangedListener.onCameraTrackingDismissed();
}
}
Expand Down
Loading

0 comments on commit ba9a875

Please sign in to comment.