osmdroid/osmdroid — pull request #72 by emmjaykay (2014-10-31 21:05:09+00:00)
Title: catch exception

I have an app that uses the overlay and kept getting an error occasionally when moving around with the map. I think it comes from a long press event being detected but also being moved at the same time until an icon is no longer displayed to be overlayed

10-31 14:03:33.979 274-274/duckingoctodangerzone.duckingoctodangerzone E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:257)
at java.util.ArrayList.get(ArrayList.java:311)
at org.osmdroid.views.overlay.ItemizedOverlay.getItem(ItemizedOverlay.java:156)
at org.osmdroid.views.overlay.ItemizedIconOverlay.activateSelectedItems(ItemizedIconOverlay.java:167)
at org.osmdroid.views.overlay.ItemizedIconOverlay.onLongPress(ItemizedIconOverlay.java:135)
at org.osmdroid.views.overlay.OverlayManager.onLongPress(OverlayManager.java:245)
at org.osmdroid.views.MapView$MapViewGestureDetectorListener.onLongPress(MapView.java:1121)
at android.view.GestureDetector.dispatchLongPress(GestureDetector.java:619)
at android.view.GestureDetector.access$200(GestureDetector.java:38)
at android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:265)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
at dalvik.system.NativeStart.main(Native Method)

I could get osmdroid to compile but I could not get the rest of the packages to compile and GeoPoint dissappears from the util package when I used the resulting Jar file in my android project. SO, I could at least get this to compile but I couldn't test it. :(