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

[android] disabling gestures while animation is in progress #9172

Closed
LukasPaczos opened this issue Jun 2, 2017 · 5 comments
Closed

[android] disabling gestures while animation is in progress #9172

LukasPaczos opened this issue Jun 2, 2017 · 5 comments
Assignees
Labels
Android Mapbox Maps SDK for Android

Comments

@LukasPaczos
Copy link
Member

Platform: Android
Mapbox SDK version: v5.1.0-beta.3

I'm trying to block gestures while animation is in progress, but unfortunatelly cannot achieve that in any way.
On v4.2.0 I had no problems with this.

animation_queue_issue

    public void tilt(View view) {
        map.getUiSettings().setAllGesturesEnabled(false);
        Log.d("Map", "disabling gestures");
        CameraPosition position = map.getCameraPosition();
        CameraPosition.Builder builder = new CameraPosition.Builder(position);
        if (tilted) {
            tilted = false;
            builder.tilt(0);
        }
        else {
            builder.tilt(60);
            tilted = true;
        }

        map.animateCamera(CameraUpdateFactory.newCameraPosition(builder.build()), 1500, new MapboxMap.CancelableCallback() {
            @Override
            public void onCancel() {
                Log.d("Map", "animation - canceled - enabling gestures");
                map.getUiSettings().setAllGesturesEnabled(true);
            }

            @Override
            public void onFinish() {
                map.getUiSettings().setAllGesturesEnabled(true);
                Log.d("Map", "animation - finished - enabling gestures");
            }
        });
    }
Map: disabling gestures
Map: animation - finished - enabling gestures
Map: disabling gestures
Map: animation - finished - enabling gestures
Map: disabling gestures
Map: animation - canceled - enabling gestures
Map: scrolling
Map: scrolling
Map: scrolling
Map: scrolling
Map: scrolling
@tobrun
Copy link
Member

tobrun commented Jun 2, 2017

Was able to reproduce the issue. Additional note is when disabling gestures up front and doing an animation, you can still interrupt the animation. This shouldn't happen.

@tobrun tobrun added this to the android-v5.1.0 milestone Jun 2, 2017
@LukasPaczos
Copy link
Member Author

@tobrun I found an issue. In MapGestureDetector#onScroll() condition if (!trackingSettings.isScrollGestureCurrentlyEnabled()) is being checked too late and animation is being canceled inside if (!scrollInProgress) condition.

Simply moving

if (!trackingSettings.isScrollGestureCurrentlyEnabled()) {
        return false;
      }

to the top of onScroll() method fixes the issue.

@tobrun
Copy link
Member

tobrun commented Jun 2, 2017

noticed the same myself 😉 thanks @LukasPaczos 🚀

@LukasPaczos
Copy link
Member Author

@tobrun could you create a PR with this fix? I don't have a setup to do so unfortunately.

@tobrun
Copy link
Member

tobrun commented Jun 2, 2017

closed with #9173

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

No branches or pull requests

3 participants