Skip to content

Commit

Permalink
Fix webtoon last visible item position calculation (#562)
Browse files Browse the repository at this point in the history
Covers the case when image height > screen height.
  • Loading branch information
FooIbar authored Mar 22, 2024
1 parent 6682b5d commit 3493092
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,21 @@ class WebtoonLayoutManager(context: Context) : LinearLayoutManager(context) {
*/
fun findLastEndVisibleItemPosition(): Int {
ensureLayoutState()
@ViewBoundsCheck.ViewBounds val preferredBoundsFlag =
(ViewBoundsCheck.FLAG_CVE_LT_PVE or ViewBoundsCheck.FLAG_CVE_EQ_PVE)

val fromIndex = childCount - 1
val toIndex = -1

val child = if (mOrientation == HORIZONTAL) {
val callback = if (mOrientation == HORIZONTAL) {
mHorizontalBoundCheck
.findOneViewWithinBoundFlags(fromIndex, toIndex, preferredBoundsFlag, 0)
} else {
mVerticalBoundCheck
.findOneViewWithinBoundFlags(fromIndex, toIndex, preferredBoundsFlag, 0)
}.mCallback
val start = callback.parentStart
val end = callback.parentEnd
for (i in childCount - 1 downTo 0) {
val child = getChildAt(i)!!
val childStart = callback.getChildStart(child)
val childEnd = callback.getChildEnd(child)
if (childEnd <= end || childStart < start) {
return getPosition(child)
}
}

return if (child == null) NO_POSITION else getPosition(child)
return NO_POSITION
}
}

0 comments on commit 3493092

Please sign in to comment.