Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private object TouchLocker {
- internal var lastTouchTime: Long = 0
- internal val TOUCH_FREEZE_TIME = 300L
- }
- fun singleTouch(delay: Long = TouchLocker.TOUCH_FREEZE_TIME, touchEvent: () -> Unit) {
- val currentTime = System.currentTimeMillis()
- if (currentTime - delay < TouchLocker.lastTouchTime) return
- TouchLocker.lastTouchTime = currentTime
- touchEvent.invoke()
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement