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

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

Closed

Description

@LukasPaczos

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

Activity

  1. added
    Android
    on Jun 2, 2017
  2. tobrun commented on Jun 2, 2017

    @tobrun
    Member

    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.

  3. added this to the android-v5.1.0 milestone on Jun 2, 2017
  4. LukasPaczos commented on Jun 2, 2017

    @LukasPaczos
    ContributorAuthor

    @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.

  5. tobrun commented on Jun 2, 2017

    @tobrun
    Member

    noticed the same myself 😉 thanks @LukasPaczos 🚀

  6. LukasPaczos commented on Jun 2, 2017

    @LukasPaczos
    ContributorAuthor

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

  7. self-assigned this
    on Jun 2, 2017
  8. tobrun commented on Jun 2, 2017

    @tobrun
    Member

    closed with #9173

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Android

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions