PATRIK27 / osmdroid

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

Enhancement for onSingleTapConfirmed handling in overlays. #125

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Dear Osmdroid, 

One of my overlays wants to handle the onSingleTapConfirmed action so I put in 
an interface into OpenStreetMapViewOverlay which any overlay can implement and 
the code into OpenStreetMapView.  I think other events could be handled this 
way.  Do you think this is suitable for inclusion or is there a better way to 
implement this.

Thanks, 
Aron.

Interface in OpenStreetMapViewOverlay

    public interface SingleTapConfirmed
    {
        public boolean onSingleTapConfirmed(final MotionEvent e);
    }

Code in OpenStreetMapView.OpenStreetMapViewDoubleClickListener

        @Override
        public boolean onSingleTapConfirmed(final MotionEvent e) {
            boolean handled = false;

            List<OpenStreetMapViewOverlay> overlays = getOverlays();

            for (OpenStreetMapViewOverlay osmvo : overlays) 
            {
                if (osmvo instanceof SingleTapConfirmed)
                {
                    SingleTapConfirmed stc = (SingleTapConfirmed)osmvo; 
                    if (stc.onSingleTapConfirmed(e))
                    {
                        // if an overlay handles it exit
                        handled = true;
                        break;
                    }
                }
            }
            return handled;
        }

Original issue reported on code.google.com by palmer.a...@gmail.com on 16 Dec 2010 at 1:35

GoogleCodeExporter commented 8 years ago
I tried something else. See how the attached patch works.

Original comment by neilboyd on 16 Dec 2010 at 3:59

Attachments:

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Yeah thats great, thought I had checked the latest version.  Havent tested it 
yet, I am quite a bit behind the latest version at the minute so wont be able 
to quickly test, but it looks right.
Thanks, 
Aron.

Original comment by palmer.a...@gmail.com on 16 Dec 2010 at 4:07

GoogleCodeExporter commented 8 years ago
This is a sub-task of issue 51 

Original comment by kurtzm...@gmail.com on 12 Jan 2011 at 5:11

GoogleCodeExporter commented 8 years ago
Fixed in r782.

Original comment by kurtzm...@gmail.com on 7 Feb 2011 at 4:02