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

[android] Monkey crashes cherry pick #10440 #10472

Merged
merged 1 commit into from
Nov 16, 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 @@ -235,8 +235,10 @@ boolean onTouchEvent(MotionEvent event) {
velocityTracker = null;
break;
case MotionEvent.ACTION_MOVE:
velocityTracker.addMovement(event);
velocityTracker.computeCurrentVelocity(1000);
if (velocityTracker != null) {
velocityTracker.addMovement(event);
velocityTracker.computeCurrentVelocity(1000);
}
break;
}

Expand Down Expand Up @@ -551,6 +553,11 @@ public boolean onScale(ScaleGestureDetector detector) {
// Called when fingers leave screen
@Override
public void onScaleEnd(final ScaleGestureDetector detector) {
if (velocityTracker == null) {
return;
}


if (rotateGestureOccurred || quickZoom) {
reset();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,9 @@ int getHeight() {
//

void addOnMapChangedListener(@NonNull MapView.OnMapChangedListener listener) {
mapView.addOnMapChangedListener(listener);
if (mapView != null) {
mapView.addOnMapChangedListener(listener);
}
}

void removeOnMapChangedListener(@NonNull MapView.OnMapChangedListener listener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,16 +238,18 @@ void setZoom(double zoom, @NonNull PointF focalPoint) {
}

void setZoom(double zoom, @NonNull PointF focalPoint, long duration) {
mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
@Override
public void onMapChanged(int change) {
if (change == MapView.REGION_DID_CHANGE_ANIMATED) {
cameraChangeDispatcher.onCameraIdle();
mapView.removeOnMapChangedListener(this);
if (mapView != null) {
mapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
@Override
public void onMapChanged(int change) {
if (change == MapView.REGION_DID_CHANGE_ANIMATED) {
cameraChangeDispatcher.onCameraIdle();
mapView.removeOnMapChangedListener(this);
}
}
}
});
mapView.setZoom(zoom, focalPoint, duration);
});
mapView.setZoom(zoom, focalPoint, duration);
}
}

// Direction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,14 @@ protected void onStop() {

stopped = true;

// Stop ongoing animations, prevent memory lekas
MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager();
for (MarkerView markerView : markerViews) {
View view = markerViewManager.getView(markerView);
if (view != null) {
view.animate().cancel();
// Stop ongoing animations, prevent memory leaks
if (mapboxMap != null) {
MarkerViewManager markerViewManager = mapboxMap.getMarkerViewManager();
for (MarkerView markerView : markerViews) {
View view = markerViewManager.getView(markerView);
if (view != null) {
view.animate().cancel();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ private void onLatLngListLoaded(List<LatLng> latLngs, int amount) {
}

private void showMarkers(int amount) {
if (mapboxMap == null || locations == null) {
return;
}

mapboxMap.clear();

if (locations.size() < amount) {
Expand Down