/** * Override this method to handle a "tap" on a balloon. By default, does nothing and returns * false. * * @param index - The index of the item whose balloon is tapped. * @return true if you handled the tap, otherwise false. */ @Override protected boolean onBalloonTap(int index) { if (onTapListener != null) { onTapListener.onTap(latitude, longitude, indexData); } return true; }
@Override public boolean onTouch(View v, MotionEvent event) { mView = v; switch (event.getAction()) { // NORMAL CASE : FIRST POINTER DOWN case MotionEvent.ACTION_DOWN: // Start dragging startDrag(event); state = State.DRAG; lastDownX = event.getX(); lastDownY = event.getY(); break; // NORMAL CASE : SECOND POINTER DOWN case MotionEvent.ACTION_POINTER_2_DOWN: startDrag(event); startZoom(event); state = State.ZOOM; break; // NORMAL CASE : SECOND POINTER UP case MotionEvent.ACTION_POINTER_2_UP: // End zooming, goes back to dragging state = State.DRAG; break; // NORMAL CASE : FIRST POINTER UP case MotionEvent.ACTION_UP: // End everything state = State.NONE; endDrag(); // Treat clicks if (isClick(event, lastDownX, lastDownY, event.getX(), event.getY())) { long time = System.currentTimeMillis(); handlerClick.removeCallbacks(runnableClick); if (time - lastClickTime < MAX_DOUBLE_CLICK_TIME) { if (onDoubleTapListener != null) { onDoubleTapListener.onDoubleTap(event.getX(), event.getY()); lastClickTime = 0; } else { handlerClick.postDelayed(runnableClick, 0); } } else { if (onTapListener != null) { onTapListener.onTap(event.getX(), event.getY()); lastClickTime = 0; } lastClickTime = System.currentTimeMillis(); handlerClick.postDelayed(runnableClick, MAX_CLICK_TIME); } } break; // TRICKY CASE : FIRST POINTER UP WHEN SECOND STILL DOWN case MotionEvent.ACTION_POINTER_1_UP: dragLastX = pointer2LastX; dragLastY = pointer2LastY; state = State.DRAG; break; // TRICKY CASE : FIRST POINTER UP THEN DOWN WHILE SECOND POINTER STILL UP case MotionEvent.ACTION_POINTER_1_DOWN: pointer2LastX = event.getX(POINTER1); pointer2LastY = event.getY(POINTER1); startDrag(event); startZoom(event); state = State.ZOOM; break; // NORMAL CASE : MOVE case MotionEvent.ACTION_MOVE: switch (state) { case ZOOM: pointer2LastX = event.getX(POINTER2); pointer2LastY = event.getY(POINTER2); zoom(event); case DRAG: drag(event); break; default: break; } break; } return true; }