Created
July 12, 2016 06:48
-
-
Save olkunmustafa/5558f59bd94b3873446da9b09d19da14 to your computer and use it in GitHub Desktop.
Used As a lightweight alternative to GestureDetector you can use this class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class DoubleClickListener implements OnClickListener { | |
private static final long DOUBLE_CLICK_TIME_DELTA = 300;//milliseconds | |
long lastClickTime = 0; | |
@Override | |
public void onClick(View v) { | |
long clickTime = System.currentTimeMillis(); | |
if (clickTime - lastClickTime < DOUBLE_CLICK_TIME_DELTA){ | |
onDoubleClick(v); | |
} else { | |
onSingleClick(v); | |
} | |
lastClickTime = clickTime; | |
} | |
public abstract void onSingleClick(View v); | |
public abstract void onDoubleClick(View v); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment