2020-07-04 13:45:01 -04:00
|
|
|
package eu.kanade.tachiyomi.widget
|
2020-05-06 23:16:02 -04:00
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.util.AttributeSet
|
|
|
|
import android.view.MotionEvent
|
|
|
|
import eu.davidea.fastscroller.FastScroller
|
|
|
|
import eu.kanade.tachiyomi.R
|
2020-05-07 22:40:23 -04:00
|
|
|
import eu.kanade.tachiyomi.util.system.dpToPxEnd
|
2020-05-06 23:16:02 -04:00
|
|
|
|
|
|
|
class MaterialFastScroll @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
|
|
|
FastScroller(context, attrs) {
|
|
|
|
|
|
|
|
init {
|
|
|
|
setViewsToUse(
|
|
|
|
R.layout.material_fastscroll, R.id.fast_scroller_bubble, R.id.fast_scroller_handle
|
|
|
|
)
|
2020-05-07 22:40:23 -04:00
|
|
|
autoHideEnabled = true
|
|
|
|
ignoreTouchesOutsideHandle = true
|
2020-05-06 23:16:02 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
|
|
|
if (isHidden) return false
|
|
|
|
return super.onTouchEvent(event)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun setBubbleAndHandlePosition(y: Float) {
|
|
|
|
super.setBubbleAndHandlePosition(y)
|
2020-05-07 22:40:23 -04:00
|
|
|
if (bubbleEnabled) {
|
|
|
|
bubble.y = handle.y - bubble.height / 2f + handle.height / 2f
|
|
|
|
bubble.translationX = (-45f).dpToPxEnd
|
|
|
|
}
|
2020-05-06 23:16:02 -04:00
|
|
|
}
|
|
|
|
}
|