Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. private object TouchLocker {
  2. internal var lastTouchTime: Long = 0
  3. internal val TOUCH_FREEZE_TIME = 300L
  4. }
  5.  
  6. fun singleTouch(delay: Long = TouchLocker.TOUCH_FREEZE_TIME, touchEvent: () -> Unit) {
  7. val currentTime = System.currentTimeMillis()
  8. if (currentTime - delay < TouchLocker.lastTouchTime) return
  9.  
  10. TouchLocker.lastTouchTime = currentTime
  11. touchEvent.invoke()
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement