Class SimpleCarousel
- java.lang.Object
-
- com.cheetahdigital.uikit.widget.carousel.SimpleCarousel
-
public class SimpleCarousel extends java.lang.ObjectClass 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.PagerAdaptergetAdapter()intgetCurrentItem()voidinit(boolean isAutoScrollEnabled)Initialize carousel with default parameters.voidinitPageIndicator()Initializes the page indicator.voidsetAdapter(androidx.viewpager.widget.PagerAdapter adapter)Sets the adapter that provides the data and the views in this carousel.voidsetAutoScroll(boolean isEnabled)Determines whether carousel is allowed to autoscroll.voidsetCarouselSwipeListener(Carousel.CarouselSwipeListener mCarouselSwipeListener)Registers the swipe listener for the carousel.voidsetCurrentItem(int position)Sets the currently selected page.voidsetCurrentItem(int position, boolean smoothScroll)Sets the currently selected page.voidsetPageIndicatorMargin(int marginInPx)Sets the page indicator margin.voidsetTimedScrollerDuration(int animationDuration)Sets the scroll animation duration.voidupdateAutoScrollDuration(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 ofPagerAdapterto 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
-
-