mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Improvements to fast scroller
Now able to tap behind the fastscroller, aka the entire the right side of the screen, which helps actually tap the download button in manga details (and fixes #1113)
This commit is contained in:
parent
1657a088ef
commit
1596bce43e
3 changed files with 19 additions and 5 deletions
|
@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.base
|
|||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.MotionEvent
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.marginTop
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -45,9 +44,9 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
MotionEvent.ACTION_DOWN -> {
|
||||
if (
|
||||
if (context.resources.isLTR) {
|
||||
event.x < handle.x - ViewCompat.getPaddingStart(handle)
|
||||
event.x < handle.x - handle.paddingStart
|
||||
} else {
|
||||
event.x > handle.width + ViewCompat.getPaddingStart(handle)
|
||||
event.x > handle.width + handle.paddingStart
|
||||
}
|
||||
) return false
|
||||
val y = event.y
|
||||
|
@ -59,7 +58,9 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
showScrollbar()
|
||||
setBubbleAndHandlePosition(y)
|
||||
setRecyclerViewPosition(y)
|
||||
return true
|
||||
}
|
||||
dispatchTouchToRecycler(event)
|
||||
return true
|
||||
}
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
|
@ -70,6 +71,7 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
notifyScrollStateChange(true)
|
||||
showBubble()
|
||||
showScrollbar()
|
||||
dispatchTouchToRecycler(event) { action = MotionEvent.ACTION_CANCEL }
|
||||
}
|
||||
if (canScroll) {
|
||||
setBubbleAndHandlePosition(y)
|
||||
|
@ -79,12 +81,23 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
|
|||
}
|
||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||
startY = 0f
|
||||
if (!canScroll) {
|
||||
dispatchTouchToRecycler(event)
|
||||
}
|
||||
canScroll = false
|
||||
}
|
||||
}
|
||||
return super.onTouchEvent(event)
|
||||
}
|
||||
|
||||
private fun dispatchTouchToRecycler(event: MotionEvent, block: (MotionEvent.() -> Unit)? = null) {
|
||||
val ev2 = MotionEvent.obtain(event)
|
||||
ev2.offsetLocation(this.x, this.y)
|
||||
block?.invoke(ev2)
|
||||
recyclerView.dispatchTouchEvent(ev2)
|
||||
ev2.recycle()
|
||||
}
|
||||
|
||||
override fun setBubbleAndHandlePosition(y: Float) {
|
||||
super.setBubbleAndHandlePosition(y)
|
||||
if (bubbleEnabled) {
|
||||
|
|
|
@ -93,9 +93,8 @@
|
|||
<include
|
||||
layout="@layout/download_button"
|
||||
android:id="@+id/download_button"
|
||||
android:layout_width="50dp"
|
||||
android:layout_width="54dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="center"
|
||||
android:contentDescription="@string/download"
|
||||
android:src="@drawable/border_circle"
|
||||
android:padding="3dp"/>
|
||||
|
||||
|
@ -43,6 +44,7 @@
|
|||
app:tint="?attr/colorSecondary"
|
||||
android:layout_gravity="center"
|
||||
android:layout_width="30dp"
|
||||
android:contentDescription="@string/download"
|
||||
android:layout_height="30dp"
|
||||
android:background="@drawable/round_ripple"
|
||||
android:padding="5dp"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue