MaterialFastScroll updates

This commit is contained in:
arkon
2020-05-07 22:40:23 -04:00
parent 3b45fcdb21
commit d86d861e4b
9 changed files with 44 additions and 23 deletions

View File

@@ -5,7 +5,7 @@ import android.util.AttributeSet
import android.view.MotionEvent
import eu.davidea.fastscroller.FastScroller
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.util.system.dpToPx
import eu.kanade.tachiyomi.util.system.dpToPxEnd
class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
FastScroller(context, attrs) {
@@ -14,6 +14,8 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
setViewsToUse(
R.layout.material_fastscroll, R.id.fast_scroller_bubble, R.id.fast_scroller_handle
)
autoHideEnabled = true
ignoreTouchesOutsideHandle = true
}
override fun onTouchEvent(event: MotionEvent): Boolean {
@@ -23,7 +25,9 @@ class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: Attr
override fun setBubbleAndHandlePosition(y: Float) {
super.setBubbleAndHandlePosition(y)
bubble.y = handle.y - bubble.height / 2f + handle.height / 2f
bubble.translationX = (-45).dpToPx.toFloat()
if (bubbleEnabled) {
bubble.y = handle.y - bubble.height / 2f + handle.height / 2f
bubble.translationX = (-45f).dpToPxEnd
}
}
}