Skip to content

Commit

Permalink
Merge pull request #234 from rubensousa/bump-1.3.0rc01
Browse files Browse the repository at this point in the history
1.3.0-rc01
  • Loading branch information
rubensousa authored Jul 9, 2024
2 parents 0a864da + 7243741 commit 516740d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 7 deletions.
6 changes: 6 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Version 1.3.0

### 1.3.0-rc01

2024-07-08

- Reverted default of `setLayoutWhileScrollingEnabled()` back to false.

### 1.3.0-beta02

2024-06-20
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class LayoutWhileScrollingTest : DpadRecyclerViewTest() {
// given
var layoutCompleted = 0
onRecyclerView("Disable layout during scroll") { recyclerView ->
recyclerView.setLayoutWhileScrollingEnabled(false)
recyclerView.addOnLayoutCompletedListener(
object : DpadRecyclerView.OnLayoutCompletedListener {
override fun onLayoutCompleted(state: RecyclerView.State) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ open class DpadRecyclerView @JvmOverloads constructor(
private var isOverlappingRenderingEnabled = true
private var isRetainingFocus = false
private var startedTouchScroll = false
private var layoutWhileScrollingEnabled = false
private var layoutWhileScrollingEnabled = true
private var hasPendingLayout = false
private var touchInterceptListener: OnTouchInterceptListener? = null
private var smoothScrollByBehavior: SmoothScrollByBehavior? = null
Expand Down Expand Up @@ -1298,20 +1298,19 @@ open class DpadRecyclerView @JvmOverloads constructor(
fun getOnMotionInterceptListener(): OnMotionInterceptListener? = motionInterceptListener

/**
* By default, [DpadRecyclerView] skips layout requests during scrolling because of:
* By default, [DpadRecyclerView] does not skip layout requests during scrolling,
* but you might want to do this because of the following:
* 1. Compose animations trigger a full unnecessary layout-pass
* 2. Content jumping around while scrolling is not ideal sometimes
*
* @param enabled true if layout requests should be possible while scrolling,
* or false if they should be postponed until [RecyclerView.SCROLL_STATE_IDLE].
* Default is false.
* Default is true.
*/
fun setLayoutWhileScrollingEnabled(enabled: Boolean) {
layoutWhileScrollingEnabled = enabled
}

internal fun isScrollingFromTouch() = startedTouchScroll

@VisibleForTesting
internal fun detachFromWindow() {
onDetachedFromWindow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,40 @@ 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?) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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-beta02
LIBRARY_VERSION=1.3.0-rc01
2 changes: 1 addition & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ theme:

extra:
dpadrecyclerview:
version: '1.3.0-beta02'
version: '1.3.0-rc01'
social:
- icon: 'fontawesome/brands/github'
link: 'https://github.com/rubensousa/DpadRecyclerView'
Expand Down

0 comments on commit 516740d

Please sign in to comment.