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 {
if (!isSubscribed) {
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
} else {
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
}
}

View File

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

View File

@ -44,7 +44,7 @@
android:layout_marginTop="2dp"
android:text="@string/subscribe"
android:textColor="?attr/colorPrimary"
android:visibility="gone"/>
android:visibility="gone" />
</LinearLayout>
</LinearLayout>

View File

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