-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added ability to passthrough touch events - Changed OnEnd trigger to be before view is removed - Added the ability to not show start animation aka duration 0 - Added debounce click listener
- Loading branch information
1 parent
522e30c
commit 0f8ae3f
Showing
9 changed files
with
70 additions
and
38 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
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
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
23 changes: 23 additions & 0 deletions
23
spotlight/src/main/java/com/matadesigns/spotlight/utils/ViewExtension.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.matadesigns.spotlight.utils | ||
|
||
import android.os.SystemClock | ||
import android.util.Log | ||
import android.view.View | ||
|
||
class DebounceOnClickListener(var debounceTime: Long, var action: (View) -> Unit): View.OnClickListener { | ||
private var clickTime: Long = 0 | ||
|
||
override fun onClick(v: View) { | ||
val lastClickTime = clickTime | ||
clickTime = SystemClock.elapsedRealtime() | ||
if (SystemClock.elapsedRealtime() - lastClickTime < debounceTime) { | ||
Log.d("DebounceOnClickListener", "Blocked Click") | ||
return | ||
} | ||
action(v) | ||
} | ||
} | ||
|
||
fun View.setOnClickListenerWithDebounce(action: (View) -> Unit, debounceTime: Long = 600L) { | ||
this.setOnClickListener(DebounceOnClickListener(debounceTime, action)) | ||
} |