Skip to content

Instantly share code, notes, and snippets.

@banasiak
Created April 17, 2019 15:25
Show Gist options
  • Save banasiak/e75c8dab2adecabd8928c17d28cc7afa to your computer and use it in GitHub Desktop.
Save banasiak/e75c8dab2adecabd8928c17d28cc7afa to your computer and use it in GitHub Desktop.
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