Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Cherry pick IAE to release-agua #10339

Merged
merged 2 commits into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,8 @@ void onRestoreInstanceState(Bundle savedInstanceState) {
trackingSettings.onRestoreInstanceState(savedInstanceState);

if (cameraPosition != null) {
easeCamera(CameraUpdateFactory.newCameraPosition(
new CameraPosition.Builder(cameraPosition).build()),
0,
false,
null,
!trackingSettings.isLocationTrackingDisabled()
moveCamera(CameraUpdateFactory.newCameraPosition(
new CameraPosition.Builder(cameraPosition).build())
);
}

Expand Down Expand Up @@ -846,6 +842,10 @@ public final void easeCamera(final CameraUpdate update, final int durationMs, fi
*/
public final void easeCamera(final CameraUpdate update, final int durationMs, final boolean easingInterpolator,
final MapboxMap.CancelableCallback callback, final boolean isDismissable) {

if (durationMs <= 0) {
throw new IllegalArgumentException("Null duration passed into easeCamera");
}
new Handler().post(new Runnable() {
@Override
public void run() {
Expand Down Expand Up @@ -918,6 +918,9 @@ public final void animateCamera(CameraUpdate update, int durationMs) {
*/
public final void animateCamera(final CameraUpdate update, final int durationMs,
final MapboxMap.CancelableCallback callback) {
if (durationMs <= 0) {
throw new IllegalArgumentException("Null duration passed into animageCamera");
}
new Handler().post(new Runnable() {
@Override
public void run() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
* <p>
* Use {@link MyLocationViewSettings} to manipulate the state of this view.
* </p>
*
* @deprecated use location layer plugin from
* https://github.com/mapbox/mapbox-plugins-android/tree/master/plugins/locationlayer instead.
*/
Expand Down Expand Up @@ -639,8 +640,7 @@ public void setMyLocationTrackingMode(@MyLocationTracking.Mode int myLocationTra
if (location != null) {
if (myLocationTrackingMode == MyLocationTracking.TRACKING_FOLLOW) {
// center map directly
mapboxMap.easeCamera(CameraUpdateFactory.newLatLng(new LatLng(location)), 0, false /*linear interpolator*/,
null, true);
mapboxMap.moveCamera(CameraUpdateFactory.newLatLng(new LatLng(location)));
} else {
// do not use interpolated location from tracking mode
latLng = null;
Expand Down Expand Up @@ -1022,8 +1022,7 @@ void updateLatLng(@NonNull Location location) {
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), animationDuration, false, null,
true);
} else {
mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(builder.build()), 0, false, null,
true);
mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(builder.build()));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package com.mapbox.mapboxsdk.maps;

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.mockito.Mockito.mock;

public class MapboxMapTest {

private MapboxMap mapboxMap;

@Before
public void beforeTest() {

mapboxMap = new MapboxMap(mock(NativeMapView.class),
mock(Transform.class),
mock(UiSettings.class),
mock(TrackingSettings.class),
mock(MyLocationViewSettings.class),
mock(Projection.class),
mock(MapboxMap.OnRegisterTouchListener.class),
mock(AnnotationManager.class),
mock(CameraChangeDispatcher.class));
}

@Test(expected = IllegalArgumentException.class)
public void testAnimateCameraChecksDurationPositive() {
mapboxMap.animateCamera(CameraUpdateFactory.newLatLng(new LatLng(30.0, 30.0)),
0, null);
}

@Test(expected = IllegalArgumentException.class)
public void testEaseCameraChecksDurationPositive() {
mapboxMap.easeCamera(CameraUpdateFactory.newLatLng(new LatLng(30.0, 30.0)),
0, null);
}

@After
public void afterTest() {
mapboxMap = null;
}
}