adding a couple scroll handle show/hide improvements
This commit is contained in:
parent
73e0fd9df9
commit
5bce1d717b
2 changed files with 17 additions and 8 deletions
|
@ -6,7 +6,7 @@ buildscript {
|
|||
propMinSdkVersion = 16
|
||||
propTargetSdkVersion = propCompileSdkVersion
|
||||
propVersionCode = 1
|
||||
propVersionName = '3.6.3'
|
||||
propVersionName = '3.6.5'
|
||||
kotlin_version = '1.2.10'
|
||||
support_libs = '27.0.2'
|
||||
}
|
||||
|
|
|
@ -73,8 +73,15 @@ class FastScroller : FrameLayout {
|
|||
|
||||
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
|
||||
super.onScrollStateChanged(recyclerView, newState)
|
||||
if (isScrollingEnabled && newState == RecyclerView.SCROLL_STATE_DRAGGING) {
|
||||
if (!isScrollingEnabled) {
|
||||
hideHandle()
|
||||
return
|
||||
}
|
||||
|
||||
if (newState == RecyclerView.SCROLL_STATE_DRAGGING) {
|
||||
showHandle()
|
||||
} else if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
hideHandle()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -109,7 +116,9 @@ class FastScroller : FrameLayout {
|
|||
|
||||
fun setScrollTo(y: Int) {
|
||||
currScrollY = y
|
||||
measureRecyclerView()
|
||||
updateHandlePosition()
|
||||
hideHandle()
|
||||
}
|
||||
|
||||
fun updatePrimaryColor() {
|
||||
|
@ -161,7 +170,6 @@ class FastScroller : FrameLayout {
|
|||
handle!!.y = getValueInRange(0f, recyclerViewHeight - handleHeight.toFloat(), targetY)
|
||||
}
|
||||
showHandle()
|
||||
hideHandle()
|
||||
}
|
||||
|
||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||
|
@ -269,11 +277,12 @@ class FastScroller : FrameLayout {
|
|||
|
||||
private fun showHandle() {
|
||||
handleHideHandler.removeCallbacksAndMessages(null)
|
||||
handle!!.animate().alpha(1f).start() // override the fadeout animation
|
||||
handle!!.alpha = 1f
|
||||
if (handleWidth == 0 && handleHeight == 0) {
|
||||
handleWidth = handle!!.width
|
||||
handleHeight = handle!!.height
|
||||
if (handle!!.alpha != 1f) {
|
||||
handle!!.alpha = 1f
|
||||
if (handleWidth == 0 && handleHeight == 0) {
|
||||
handleWidth = handle!!.width
|
||||
handleHeight = handle!!.height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue