Skip to content

Commit

Permalink
Merge pull request #189 from rubensousa/touch_issue
Browse files Browse the repository at this point in the history
Do not start considering touch scrolling until scroll state changes
  • Loading branch information
rubensousa authored Feb 3, 2024
2 parents b24bdae + e525fa0 commit cd64092
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

## Version 1.2.0

### 1.2.0-rc01

2024-02-03

#### Bug fixes

- Fixed focus being sent to the wrong item when scrolling with touch events before pressing a key ([#188](https://github.com/rubensousa/DpadRecyclerView/issues/188))

### 1.2.0-beta02

2024-01-28
Expand Down
1 change: 1 addition & 0 deletions dpadrecyclerview/api/dpadrecyclerview.api
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public class com/rubensousa/dpadrecyclerview/DpadRecyclerView : androidx/recycle
public final fun smoothScrollBy (II)V
public final fun smoothScrollBy (IILandroid/view/animation/Interpolator;)V
public fun startNestedScroll (II)Z
public fun stopNestedScroll ()V
}

public abstract interface class com/rubensousa/dpadrecyclerview/DpadRecyclerView$OnKeyInterceptListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ open class DpadRecyclerView @JvmOverloads constructor(
private var pivotLayoutManager: PivotLayoutManager? = null
private var isOverlappingRenderingEnabled = true
private var isRetainingFocus = false
private var startedTouchScroll = false
private var touchInterceptListener: OnTouchInterceptListener? = null
private var smoothScrollByBehavior: SmoothScrollByBehavior? = null
private var keyInterceptListener: OnKeyInterceptListener? = null
Expand Down Expand Up @@ -403,15 +404,23 @@ open class DpadRecyclerView @JvmOverloads constructor(
override fun startNestedScroll(axes: Int, type: Int): Boolean {
val result = super.startNestedScroll(axes, type)
if (type == ViewCompat.TYPE_TOUCH) {
pivotLayoutManager?.setScrollingFromTouchEvent(true)
startedTouchScroll = true
}
return result
}

override fun stopNestedScroll() {
super.stopNestedScroll()
startedTouchScroll = false
}

override fun onScrollStateChanged(state: Int) {
super.onScrollStateChanged(state)
if (state == SCROLL_STATE_IDLE) {
startedTouchScroll = false
pivotLayoutManager?.setScrollingFromTouchEvent(false)
} else if (startedTouchScroll) {
pivotLayoutManager?.setScrollingFromTouchEvent(true)
}
}

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.2.0-beta02
LIBRARY_VERSION=1.2.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.2.0-beta02'
version: '1.2.0-rc01'
social:
- icon: 'fontawesome/brands/github'
link: 'https://github.com/rubensousa/DpadRecyclerView'
Expand Down

0 comments on commit cd64092

Please sign in to comment.