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

Camera animation: onCancel() in CancelableCallback never called #6910

Closed
mhettig opened this issue Nov 4, 2016 · 2 comments
Closed

Camera animation: onCancel() in CancelableCallback never called #6910

mhettig opened this issue Nov 4, 2016 · 2 comments

Comments

@mhettig
Copy link

mhettig commented Nov 4, 2016

Hey,

as mentioned in the title I'm a little confused about the behavior of the onCancel() method in the MapboxMap.CancelableCallback(). It never seems to be called when stopping a camera animation e.g. by user input (note the code snippet below to see my implementation). Currently I'm running on mapbox-android-sdk:4.2.0-beta.4.

According to the API documentation onCancel() should be called:

If the animation stops due to interruption by [...] a user gesture (1)

or if the animation did not complete normally. (2)

So the expected behavior would be: onCancel() get's called if interrupting the camera animation by a user gesture.

But the actual behavior is quite more strange: Regardless of whether the animation finishes as planned or gets interrupted onFinished() gets called making it impossible to distinguish between a successful completed animation or an incomplete one.

Example code:

CameraPosition newPosition = new CameraPosition.Builder()
    .target(new LatLng(mMapBoxMap.getMyLocation()))
    .zoom(14)
    .build();

mMapBoxMap.animateCamera(CameraUpdateFactory.newCameraPosition(newPosition), 2000,
    new MapboxMap.CancelableCallback()
    {
        @Override
        public void onCancel()
        {
        ...
        }

        @Override
        public void onFinish()
        {
        ...
        }
});
@tobrun
Copy link
Member

tobrun commented Nov 4, 2016

I noticed the same and implemented a fix for this yesterday. This was merged with the 4.2.0 release branch and will be available with next snapshot/beta/release. Thank you for reaching out!

@tobrun tobrun closed this as completed Nov 4, 2016
@mhettig
Copy link
Author

mhettig commented Nov 4, 2016

Okay cool. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants