Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
private class DebugModeTapListener implements View.OnClickListener {
private int tapCount = 0;
private long lastTap = SystemClock.elapsedRealtime();
@Override
public void onClick(final View v) {
final Context context = getApplicationContext();
long currentTap = SystemClock.elapsedRealtime();
if (currentTap - lastTap < 500) {
tapCount++;
} else {
tapCount = 1;
}
lastTap = currentTap;
if (tapCount > 10) {
// User has tapped 10 times in 5 seconds
Toast.makeText(context, "No peeking! ;-)", Toast.LENGTH_SHORT)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.