fix single click overlay

This commit is contained in:
Bnyro 2022-07-11 16:39:35 +02:00
parent ce060f1df2
commit 9993cd0b4e
4 changed files with 16 additions and 12 deletions

View File

@ -177,11 +177,13 @@ class SearchAdapter(
binding.searchSubButton.setOnClickListener { binding.searchSubButton.setOnClickListener {
if (!isSubscribed) { if (!isSubscribed) {
subscribe(token, channelId) subscribe(token, channelId)
binding.searchSubButton.text = binding.root.context.getString(R.string.unsubscribe) binding.searchSubButton.text =
binding.root.context.getString(R.string.unsubscribe)
isSubscribed = true isSubscribed = true
} else { } else {
unsubscribe(token, channelId) unsubscribe(token, channelId)
binding.searchSubButton.text = binding.root.context.getString(R.string.subscribe) binding.searchSubButton.text =
binding.root.context.getString(R.string.subscribe)
isSubscribed = false isSubscribed = false
} }
} }

View File

@ -9,28 +9,30 @@ class DoubleClickListener(
private val callback: Callback private val callback: Callback
) : View.OnClickListener { ) : View.OnClickListener {
private var lastClicked: Long = -1L private var lastClicked: Long = -1L
private var doubleClicked: Boolean = false
override fun onClick(v: View?) { override fun onClick(v: View?) {
lastClicked = when { lastClicked = when {
lastClicked == -1L -> { lastClicked == -1L -> {
doubleClicked = false checkForSingleClick()
System.currentTimeMillis() System.currentTimeMillis()
} }
isDoubleClicked() -> { isDoubleClicked() -> {
doubleClicked = true
callback.doubleClicked() callback.doubleClicked()
-1L -1L
} }
else -> { else -> {
Handler(Looper.getMainLooper()).postDelayed({ checkForSingleClick()
if (!doubleClicked) callback.singleClicked()
}, doubleClickTimeLimitMills)
System.currentTimeMillis() System.currentTimeMillis()
} }
} }
} }
private fun checkForSingleClick() {
Handler(Looper.getMainLooper()).postDelayed({
if (lastClicked != -1L) callback.singleClicked()
}, doubleClickTimeLimitMills)
}
private fun getTimeDiff(from: Long, to: Long): Long { private fun getTimeDiff(from: Long, to: Long): Long {
return to - from return to - from
} }

View File

@ -389,7 +389,7 @@
android:id="@+id/rewindFL" android:id="@+id/rewindFL"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight=".40"> android:layout_weight=".35">
<ImageButton <ImageButton
android:id="@+id/rewindBTN" android:id="@+id/rewindBTN"
@ -407,14 +407,14 @@
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight=".20" /> android:layout_weight=".30" />
<!-- double tap forward btn --> <!-- double tap forward btn -->
<FrameLayout <FrameLayout
android:id="@+id/forwardFL" android:id="@+id/forwardFL"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight=".40"> android:layout_weight=".35">
<ImageButton <ImageButton
android:id="@+id/forwardBTN" android:id="@+id/forwardBTN"