Skip to content

Instantly share code, notes, and snippets.

@5AbhishekSaxena
Created July 15, 2022 22:11
Show Gist options
  • Save 5AbhishekSaxena/3d1d3a761f74b998419d9a5e61a721f2 to your computer and use it in GitHub Desktop.
Save 5AbhishekSaxena/3d1d3a761f74b998419d9a5e61a721f2 to your computer and use it in GitHub Desktop.
class MultipleOnClickStrategy(
private val times: Int,
private val runnable: () -> Unit
) : OnClickStrategy {
private var clickCounter = 0
override fun onClick() {
incrementClickCounter()
if (clickCounter == times) {
resetClickCounter()
runnable()
}
}
private fun incrementClickCounter() {
clickCounter++
}
private fun resetClickCounter() {
clickCounter = 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment