diff --git a/docs/changelog.md b/docs/changelog.md index 8b1d2276..91a089b3 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -2,6 +2,14 @@ ## Version 1.3.0 +### 1.3.0-rc02 + +2024-07-11 + +#### Bug fixes + +- Fixed `DpadRecyclerView` not immediately stopping the search for the pivot in some scenarios ([#238](https://github.com/rubensousa/DpadRecyclerView/pull/238)) + ### 1.3.0-rc01 2024-07-08 diff --git a/dpadrecyclerview/src/androidTest/kotlin/com/rubensousa/dpadrecyclerview/test/tests/scrolling/VerticalGridScrollTest.kt b/dpadrecyclerview/src/androidTest/kotlin/com/rubensousa/dpadrecyclerview/test/tests/scrolling/VerticalGridScrollTest.kt index 8acbbdfe..dfb09f33 100644 --- a/dpadrecyclerview/src/androidTest/kotlin/com/rubensousa/dpadrecyclerview/test/tests/scrolling/VerticalGridScrollTest.kt +++ b/dpadrecyclerview/src/androidTest/kotlin/com/rubensousa/dpadrecyclerview/test/tests/scrolling/VerticalGridScrollTest.kt @@ -253,6 +253,7 @@ class VerticalGridScrollTest : DpadRecyclerViewTest() { fun testMultipleFastDifferentSpanFocusChanges() { launchFragment() onRecyclerView("Change span size lookup") { recyclerView -> + recyclerView.setSmoothScrollMaxPendingMoves(25) recyclerView.setSpanSizeLookup(object : DpadSpanSizeLookup() { override fun getSpanSize(position: Int): Int { return if (position == 0 || position.rem(spanCount + 1) == 0) { diff --git a/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/layout/PivotLayout.kt b/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/layout/PivotLayout.kt index d07de77a..a8b9ee1c 100644 --- a/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/layout/PivotLayout.kt +++ b/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/layout/PivotLayout.kt @@ -231,40 +231,17 @@ internal class PivotLayout( fun onItemsAdded(positionStart: Int, itemCount: Int) { itemChanges.insertionPosition = positionStart itemChanges.insertionItemCount = itemCount - onItemsChanged() } fun onItemsRemoved(positionStart: Int, itemCount: Int) { itemChanges.removalPosition = positionStart itemChanges.removalItemCount = itemCount - onItemsChanged() } fun onItemsMoved(from: Int, to: Int, itemCount: Int) { itemChanges.moveFromPosition = from itemChanges.moveToPosition = to itemChanges.moveItemCount = itemCount - onItemsChanged() - } - - private fun onItemsChanged() { - if (!layoutInfo.isScrolling) { - return - } - val firstPos = layoutInfo.findFirstAddedPosition() - val lastPos = layoutInfo.findLastAddedPosition() - val changesOutOfBounds = if (!layoutInfo.shouldReverseLayout()) { - itemChanges.isOutOfBounds(firstPos, lastPos) - } else { - itemChanges.isOutOfBounds(lastPos, firstPos) - } - if (changesOutOfBounds) { - return - } - layoutInfo.getRecyclerView()?.apply { - stopScroll() - requestLayout() - } } fun setOnChildLaidOutListener(listener: OnChildLaidOutListener?) { diff --git a/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/scroll/BaseSmoothScroller.kt b/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/scroll/BaseSmoothScroller.kt index 74e29f6a..0bc5084e 100644 --- a/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/scroll/BaseSmoothScroller.kt +++ b/dpadrecyclerview/src/main/java/com/rubensousa/dpadrecyclerview/layoutmanager/scroll/BaseSmoothScroller.kt @@ -49,6 +49,14 @@ internal open class BaseSmoothScroller( fun cancel() { isCanceled = true + layoutInfo.getRecyclerView()?.apply { + postOnAnimation { + if (layoutInfo.isScrolling) { + requestLayout() + } + stopScroll() + } + } } fun isCanceled(): Boolean = isCanceled diff --git a/gradle.properties b/gradle.properties index 6bb35050..572ccdca 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,4 +22,4 @@ kotlin.code.style=official # thereby reducing the size of the R class for that library android.nonTransitiveRClass=true android.enableR8.fullMode=true -LIBRARY_VERSION=1.3.0-rc01 \ No newline at end of file +LIBRARY_VERSION=1.3.0-rc02 \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index de5ee0a2..151915cd 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -24,7 +24,7 @@ theme: extra: dpadrecyclerview: - version: '1.3.0-rc01' + version: '1.3.0-rc02' social: - icon: 'fontawesome/brands/github' link: 'https://github.com/rubensousa/DpadRecyclerView'