Your question is kind of unclear but I think what you want is to prevent double clicks from updating your map twice.
Using the code you provided (from the link), to prevent double clicks to update the map twice you can use this code:
public class TouchableWrapper extends FrameLayout {
// Map updates only when click has been done 250 Milliseconds after the last one
private long lastClicked;
private static final long CLICK_DELAY = 250L;
private long lastTouched = 0;
private static final long SCROLL_TIME = 200L; // 200 Milliseconds, but you can adjust that to your liking
private UpdateMapAfterUserInterection updateMapAfterUserInterection;
public TouchableWrapper(Context context) {
super(context);
// Force the host activity to implement the UpdateMapAfterUserInterection Interface
try {
updateMapAfterUserInterection = (ActivityMapv2) context;
} catch (ClassCastException e) {
throw new ClassCastException(context.toString() + " must implement UpdateMapAfterUserInterection");
}
}
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
lastTouched = SystemClock.uptimeMillis();
break;
case MotionEvent.ACTION_UP:
final long now = SystemClock.uptimeMillis();
if (now - lastTouched > SCROLL_TIME) {
if (lastClicked == 0 || ( now - lastClicked > CLICK_DELAY)) {
// Update the map
updateMapAfterUserInterection.onUpdateMapAfterUserInterection();
lastClicked = now;
}
}
break;
}
return super.dispatchTouchEvent(ev);
}
// Map Activity must implement this interface
public interface UpdateMapAfterUserInterection {
public void onUpdateMapAfterUserInterection();
}
}
Explanation:
This saves the time of last UP motion. Then when the next one happens it checks if 250 Milliseconds have passed, if not the update is skipped.
If however you want to prevent double clicks from updating your map at all, you will need to delay the whole update in a specific amount of time. During that time you check for any additional clicks, if they happen, you cancel the update of the map.