Skip to content

Commit

Permalink
Add support to enable/disable scrolling in recyclerview
Browse files Browse the repository at this point in the history
  • Loading branch information
mattiasrosberg committed Jan 12, 2022
1 parent 4c1559c commit 4a35106
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class CarouselLayoutManager constructor(
/** Use for restore scrolling in recyclerview at the time of orientation change*/
private var isOrientationChange = false

/** set to enable/disable scrolling in recyclerview */
private var isScrollingEnabled = true

/** Initialize all the attribute from the constructor and also apply some conditions */
init {
this.mInfinite = isLoop
Expand Down Expand Up @@ -172,7 +175,8 @@ class CarouselLayoutManager constructor(
* @return return boolean value to tell recyclerview for scroll handling with horizontal direction
* */
override fun canScrollHorizontally(): Boolean {
return true

return isScrollingEnabled
}

/**
Expand Down Expand Up @@ -637,6 +641,13 @@ class CarouselLayoutManager constructor(
this.mSelectedListener = l
}

/**
* set isScrollingEnabled value
*/
fun setIsScrollingEnabled(isScrollingEnabled: Boolean) {
this.isScrollingEnabled = isScrollingEnabled
}

/**
* Get the selected position or centered position
* @return selectedPosition
Expand Down

0 comments on commit 4a35106

Please sign in to comment.