-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* feat: SingleClick Util 추가 * feat: 바텀 시트 바깥 클릭 막기 * feat: single 클릭 적용 * refactor: SingleClick 메서드명 변경 * refactor: xml 파일 호출 순서 맞추기
- Loading branch information
1 parent
8550e89
commit c88c5d4
Showing
5 changed files
with
37 additions
and
6 deletions.
There are no files selected for viewing
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
30 changes: 30 additions & 0 deletions
30
android/festago/app/src/main/java/com/festago/festago/presentation/util/SingleClickUtil.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,30 @@ | ||
package com.festago.festago.presentation.util | ||
|
||
import android.os.SystemClock | ||
import android.view.View | ||
import androidx.databinding.BindingAdapter | ||
|
||
class OnSingleClickListener( | ||
private var interval: Int = 600, | ||
private var onSingleClick: (View) -> Unit, | ||
) : View.OnClickListener { | ||
|
||
private var lastClickTime: Long = 0 | ||
|
||
override fun onClick(v: View) { | ||
val elapsedRealtime = SystemClock.elapsedRealtime() | ||
if ((elapsedRealtime - lastClickTime) < interval) { | ||
return | ||
} | ||
lastClickTime = elapsedRealtime | ||
onSingleClick(v) | ||
} | ||
} | ||
|
||
@BindingAdapter("onSingleClick") | ||
fun View.setOnSingleClickListener(onSingleClick: (View) -> Unit) { | ||
val oneClick = OnSingleClickListener { | ||
onSingleClick(it) | ||
} | ||
setOnClickListener(oneClick) | ||
} |
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