-
Notifications
You must be signed in to change notification settings - Fork 40
Carousel
alirezat775 edited this page Jul 16, 2019
·
1 revision
create a new instance, need context carouselView instance and adapter
val adapter = SampleAdapter() val carousel = Carousel(this, carousel_view, adapter)set orientation: first argument set orientation and second argument set reverse layout
carousel.setOrientation(CarouselView.HORIZONTAL, false)add item: add a custom model with data
carousel.add(SampleModel(1))atuo scroll: first argument set enable or disable auto scrolling, second time interval scrolling, third enable or disable loop mode
carousel.autoScroll(true, 5000, true)sliderMode: enable or disable slider mode
carousel.enableSlider(true)scaleView: enable or disable scale center view
carousel.scaleView(true)addAll items: add a list of a custom model with data
carousel.addAll(list)changeListener: notify when item scrolling and changed position
carousel.addCarouselListener(object : CarouselListener {
override fun onPositionChange(position: Int) {
Log.d(TAG, "currentPosition : $position")
}
override fun onScroll(dx: Int, dy: Int) {
Log.d(TAG, "onScroll dx : $dx -- dy : $dx")
}
})lazyload: interface for a lazyloading item when list receive at the end
carousel.lazyLoad(true, object : CarouselLazyLoadListener {
override fun onLoadMore(page: Int, totalItemsCount: Int, view: CarouselView) {
if (hasNextPage) {
Log.d(TAG, "load new item on lazy mode")
carousel.add(SampleModel(11))
carousel.add(SampleModel(12))
carousel.add(SampleModel(13))
carousel.add(SampleModel(14))
carousel.add(SampleModel(15))
hasNextPage = false
}
}
})