-
-
Save 5AbhishekSaxena/3d1d3a761f74b998419d9a5e61a721f2 to your computer and use it in GitHub Desktop.
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
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