From 4a35106e1ed1b2c119372c8d9081cbb376235ef7 Mon Sep 17 00:00:00 2001 From: Mattias Rosberg Date: Wed, 12 Jan 2022 14:22:21 +0100 Subject: [PATCH] Add support to enable/disable scrolling in recyclerview --- .../carouselrecyclerview/CarouselLayoutManager.kt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/carouselrecyclerview/src/main/java/com/jackandphantom/carouselrecyclerview/CarouselLayoutManager.kt b/carouselrecyclerview/src/main/java/com/jackandphantom/carouselrecyclerview/CarouselLayoutManager.kt index 3290987..7431f56 100644 --- a/carouselrecyclerview/src/main/java/com/jackandphantom/carouselrecyclerview/CarouselLayoutManager.kt +++ b/carouselrecyclerview/src/main/java/com/jackandphantom/carouselrecyclerview/CarouselLayoutManager.kt @@ -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 @@ -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 } /** @@ -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