Class SimpleCarousel
- java.lang.Object
-
- com.cheetahdigital.uikit.widget.carousel.SimpleCarousel
-
public class SimpleCarousel extends java.lang.Object
Class for creating a simple image carousel.
-
-
Constructor Summary
Constructors Constructor Description SimpleCarousel(android.content.Context context, androidx.viewpager.widget.ViewPager viewPager, android.widget.LinearLayout pageIndicatorLinearLayout)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description androidx.viewpager.widget.PagerAdapter
getAdapter()
int
getCurrentItem()
void
init(boolean isAutoScrollEnabled)
Initialize carousel with default parameters.void
initPageIndicator()
Initializes the page indicator.void
setAdapter(androidx.viewpager.widget.PagerAdapter adapter)
Sets the adapter that provides the data and the views in this carousel.void
setAutoScroll(boolean isEnabled)
Determines whether carousel is allowed to autoscroll.void
setCarouselSwipeListener(Carousel.CarouselSwipeListener mCarouselSwipeListener)
Registers the swipe listener for the carousel.void
setCurrentItem(int position)
Sets the currently selected page.void
setCurrentItem(int position, boolean smoothScroll)
Sets the currently selected page.void
setPageIndicatorMargin(int marginInPx)
Sets the page indicator margin.void
setTimedScrollerDuration(int animationDuration)
Sets the scroll animation duration.void
updateAutoScrollDuration(int autoScrollDuration)
Updates the carousel speed
-
-
-
Method Detail
-
init
public void init(boolean isAutoScrollEnabled)
Initialize carousel with default parameters.- Parameters:
isAutoScrollEnabled
- true to enable autoscrolling, else false
-
updateAutoScrollDuration
public void updateAutoScrollDuration(int autoScrollDuration)
Updates the carousel speed- Parameters:
autoScrollDuration
- duration of auto scroll
-
initPageIndicator
public void initPageIndicator()
Initializes the page indicator.
-
getCurrentItem
public int getCurrentItem()
- Returns:
- the currently selected page.
-
setCurrentItem
public void setCurrentItem(int position)
Sets the currently selected page.- Parameters:
position
- current position to select
-
setCurrentItem
public void setCurrentItem(int position, boolean smoothScroll)
Sets the currently selected page.- Parameters:
position
- current position to selectsmoothScroll
- true to smooth scroll, else false
-
getAdapter
public androidx.viewpager.widget.PagerAdapter getAdapter()
- Returns:
- Fetches the pager adapter.
-
setAdapter
public void setAdapter(androidx.viewpager.widget.PagerAdapter adapter)
Sets the adapter that provides the data and the views in this carousel.- Parameters:
adapter
- instance ofPagerAdapter
to use for the view pager
-
setPageIndicatorMargin
public void setPageIndicatorMargin(int marginInPx)
Sets the page indicator margin.- Parameters:
marginInPx
- margin size between each page indicators
-
setTimedScrollerDuration
public void setTimedScrollerDuration(int animationDuration)
Sets the scroll animation duration.- Parameters:
animationDuration
- duration of the scroll animation
-
setAutoScroll
public void setAutoScroll(boolean isEnabled)
Determines whether carousel is allowed to autoscroll.- Parameters:
isEnabled
- True if allowed to autoscroll, else false.
-
setCarouselSwipeListener
public void setCarouselSwipeListener(Carousel.CarouselSwipeListener mCarouselSwipeListener)
Registers the swipe listener for the carousel.- Parameters:
mCarouselSwipeListener
- listener for handling swipe gestures
-
-