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

Upgrade MapView to allow multiple onTouchListener #509

Closed

Description

@Ph0tonic

Hello,

I used the mapbox annotation plugin in one of my project and hit a limitation regarding the event manager. This plugin uses the following code on mapView to allow annotations to be draggable (as described here https://github.com/mapbox/mapbox-plugins-android/issues/884) :

mapView.setOnTouchListener { view, event -> ... }

But when a user wants to add its own detection system to add a functionality like custom drawing Mapbox example, he is stuck due to a limitation of the view which offer only one OnTouchListener. There exist a workaround consisting of adding another view on top of mapView to intercept the event but I think that there might be a better solution.

This issue could be resolved by adding a new interface to mapView which would allow to have multiple onTouchListener. I thought about something like this :

private List<OnTouchListener> onTouchListeners = new ArrayList<>();

public boolean addOnTouchListener(OnTouchListener listener) {
   return onTouchListeners.add(listener);
}

public boolean removeOnTouchListener(OnTouchListener listener) {
   return onTouchListeners.remove(listener);
}

@Override
public boolean onTouchEvent(MotionEvent event)
   if (isGestureDetectorInitialized() && mapGestureDetector.onTouchEvent(event) || super.onTouchEvent(event)) {
     return true;
   }

   for (OnTouchListener listener : onTouchListeners) {
     if (listener.onTouch(this, event) {
       return true;
     }
   }
   return false;
}

Any thoughts and ideas are most appreciated 👍 @LukasPaczos, @tobrun and @tarigo

Activity

  1. Ph0tonic commented on Aug 10, 2020

    @Ph0tonic
    ContributorAuthor

    Any thoughts about this and it's linked PR ?
    /cc @LukasPaczos, @tobrun and @tarigo

  2. Ph0tonic commented on Sep 7, 2020

    @Ph0tonic
    ContributorAuthor

    Any updates on this ?
    /cc @LukasPaczos, @tobrun and @tarigo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions