mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 22:30:30 +05:30
fix single click overlay
This commit is contained in:
parent
ce060f1df2
commit
9993cd0b4e
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -44,7 +44,7 @@
|
||||
android:layout_marginTop="2dp"
|
||||
android:text="@string/subscribe"
|
||||
android:textColor="?attr/colorPrimary"
|
||||
android:visibility="gone"/>
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user