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