-
Notifications
You must be signed in to change notification settings - Fork 1.3k
NPE on CancelableCallback.onCancel() #10643
Comments
Thank you for reaching out and reporting your problem. I'm not able to reproduce this one: Code for above: animateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(getNextLatLng())
.bearing(270)
.tilt(20)
.build();
MapboxMap.CancelableCallback callback = new MapboxMap.CancelableCallback() {
@Override
public void onCancel() {
Timber.i("Duration onCancel Callback called.");
Toast.makeText(
CameraAnimationTypeActivity.this,
"Duration onCancel Callback called.",
Toast.LENGTH_LONG).show();
}
@Override
public void onFinish() {
Timber.i("Duration onFinish Callback called.");
Toast.makeText(
CameraAnimationTypeActivity.this,
"Duration onFinish Callback called.",
Toast.LENGTH_LONG).show();
}
};
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 7500, callback);
}
}); Adding multiple animateCamera invocations doesn't show it either. |
In our case we animate a lot more often in the range of every 100ms. Will try to create some code to reproduce the bug hopefully soon. |
I'm thinking that positng the animation to the end of the message queue might be the source of this exception:
This post wast added to allow to invoke new animateCamera animations inside of the callback, it will be cleaner doing this just before invoking the callbacks instead. |
Interesting thanks. I already use a similar implementation with |
landed with #10646 feel free to test this out with the snapshot build |
Android
Mapbox 5.2.0
Steps to trigger behavior
Expected behavior
Should not crash but cancel correctly the first animation
Actual behavior
Crashes with
java.lang.NullPointerException: Attempt to invoke interface method 'void com.mapbox.mapboxsdk.maps.MapboxMap$CancelableCallback.onCancel()' on a null object reference at com.mapbox.mapboxsdk.maps.Transform.cancelTransitions(Transform.java:178) at com.mapbox.mapboxsdk.maps.MapGestureDetector$GestureListener.onScroll(MapGestureDetector.java:437) at android.view.GestureDetector.onTouchEvent(GestureDetector.java:622) at android.support.v4.view.GestureDetectorCompat$GestureDetectorCompatImplJellybeanMr2.onTouchEvent(GestureDetectorCompat.java:480) at android.support.v4.view.GestureDetectorCompat.onTouchEvent(GestureDetectorCompat.java:543) at com.mapbox.mapboxsdk.maps.MapGestureDetector.onTouchEvent(MapGestureDetector.java:245) at com.mapbox.mapboxsdk.maps.MapView.onTouchEvent(MapView.java:427) at android.view.View.dispatchTouchEvent(View.java:9993) at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2828)
The text was updated successfully, but these errors were encountered: