Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.3.0-rc01 #234

Merged
merged 5 commits into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading