Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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