abhinav-adtechs / osmbonuspack

Automatically exported from code.google.com/p/osmbonuspack
0 stars 0 forks source link

MarkerInfoWindow OnTouchListener cannot be modified #81

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If one wants to modify the capability of the OnTouchListener for 
MarkerInfoWindow, it is not possible to do so. The default behavior is to close 
the MarkerInfoWindow, but that my not be desired functionality of the touch 
event.

The MarkerInfoWindow can be extended, but since the touch event capability is 
in the constructor, it is not possible to modify. Extending the InfoWindow to 
accomplish this task is also not a simple task since the Marker.setInfoWindow 
method only takes in a MarkerInfoWindow, not a more generic InfoWindow.

Having a setTouchListener method in the MarkerInfoWindow could be useful to 
solve this issue (similar functionality exists for the Google Maps Android API 
v2), example:
public void setOnMarkerInfoWindowTouchListener(View.OnTouchListener listener) {
        mView.setOnTouchListener(listener);
    }

Using v4.8 of OSMBonusPack.

Original issue reported on code.google.com by vinaydan...@gmail.com on 13 Aug 2014 at 6:06

GoogleCodeExporter commented 8 years ago
Wasn't sure how to change to type of issue to "Enhancement"...

Original comment by vinaydan...@gmail.com on 13 Aug 2014 at 6:08

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Effectively, that could be done. 

However, there is already a simple solution to solve such issues: in your own 
"MyInfoWindow" constructor, you can get the view, and set another 
OnTouchListener to it. 
It will replace the OnTouchListener previously set in the MarkerInfoWindow 
constructor. 

public MyInfoWindow(MapView mapView) {
super(R.layout.bonuspack_bubble, mapView);

getView().setOnTouchListener(new View.OnTouchListener() {
    @Override public boolean onTouch(View v, MotionEvent e) {
        if (e.getAction() == MotionEvent.ACTION_UP){
            //Do here whatever you want. Maybe nothing. 
        }
        return true;
    }
});
}

The idea behind getView() is to let developers full access to their custom 
views. 
So in fact, I prefer this approach to a more dedicated/restricted 
setOnMarkerInfoWindowTouchListener() method. 

Original comment by mathieu....@gmail.com on 16 Aug 2014 at 6:06

GoogleCodeExporter commented 8 years ago

Original comment by mathieu....@gmail.com on 1 Sep 2014 at 3:47