/MultipleOnClickStrategy.kt Secret
Created
July 15, 2022 22:11
Star
You must be signed in to star a gist
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