优化 #5713
This commit is contained in:
@@ -11,12 +11,19 @@ class NoChildScrollNestedScrollView @JvmOverloads constructor(
|
||||
attrs: AttributeSet? = null,
|
||||
) : NestedScrollView(context, attrs) {
|
||||
|
||||
override fun requestChildRectangleOnScreen(
|
||||
child: View,
|
||||
rectangle: Rect?,
|
||||
immediate: Boolean
|
||||
): Boolean {
|
||||
return false
|
||||
private var isRequestChildFocus = false
|
||||
|
||||
override fun requestChildFocus(child: View?, focused: View?) {
|
||||
isRequestChildFocus = true
|
||||
super.requestChildFocus(child, focused)
|
||||
isRequestChildFocus = false
|
||||
}
|
||||
|
||||
override fun computeScrollDeltaToGetChildRectOnScreen(rect: Rect?): Int {
|
||||
if (isRequestChildFocus) {
|
||||
return 0
|
||||
}
|
||||
return super.computeScrollDeltaToGetChildRectOnScreen(rect)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-15
@@ -1,7 +1,6 @@
|
||||
package io.legado.app.ui.widget.recycler
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
@@ -14,23 +13,13 @@ class NoChildScrollLinearLayoutManager @JvmOverloads constructor(
|
||||
defStyleRes: Int = 0
|
||||
) : LinearLayoutManager(context, attrs, defStyleAttr, defStyleRes) {
|
||||
|
||||
override fun requestChildRectangleOnScreen(
|
||||
override fun onRequestChildFocus(
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State,
|
||||
child: View,
|
||||
rect: Rect,
|
||||
immediate: Boolean,
|
||||
focusedChildVisible: Boolean
|
||||
focused: View?
|
||||
): Boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
override fun requestChildRectangleOnScreen(
|
||||
parent: RecyclerView,
|
||||
child: View,
|
||||
rect: Rect,
|
||||
immediate: Boolean
|
||||
): Boolean {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user