sparrow007 / carouselrecyclerview Goto Github PK
View Code? Open in Web Editor NEWCarousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.
License: Apache License 2.0
Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager.
License: Apache License 2.0
many time scrolling fast in left side, setItemSelectListener -> onItemSelected-> it provide wrong position.
I want to implement pagination and unable do this. current I am doing this using but its crashing
carouselRecipes.addOnScrollListener(object : RecyclerView.OnScrollListener() {
override fun onScrollStateChanged(recyclerView: RecyclerView, newState: Int) {
super.onScrollStateChanged(recyclerView, newState)
}
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
val linearLayoutManager = recyclerView.layoutManager as LinearLayoutManager?
if (!loading) {
if (linearLayoutManager != null && linearLayoutManager.findLastCompletelyVisibleItemPosition() == list.size - 1) {
callingapi()
}
}
}
})
The mentioned exception occurs for instance when I filter the items in the list (change the items in the array and notifyDataSetChanged) > scroll to a position larger than 0 and > unfiltered the list > call smoothScrollToPosition(0). This also happens when the filter leaves only a single item in the list and then I unfiltered the list and > call smoothScrollToPosition(0). I was able to fix this problem by changing the CarouselLayoutManager#layoutItems method to use itemCount from RecyclerView.State.#getItemCount instead of RecyclerView#getItemCount. in the doc about RecyclerView#getItemCount it says "Note that this number is not necessarily equal to State#getItemCount() .In methods where State is available, you should use State#getItemCount() instead." I wonde r whether is better to pass the state also to to other methods in CarouselLayoutManager where item count is accessed directly through RecyclerView#getItemCount. Or would you expect any negative effects of this?
On adding or removing an item, some random items are blinking.
After adding a bunch of data inside the scrollview, in the last added the carousel view but it is not showing in the ui
if(selectedTeam=="homeTeam") {
adapter = carousalViewAdapter(
homePlayerList!!,
basketballData.getTeams[0].colors[0]
)
carouselRecyclerview.adapter = adapter
carouselRecyclerview.set3DItem(false)
setIntervalRatio(0.7f)
carouselRecyclerview.setAlpha(true)
carouselRecyclerview.setInfinite(false)
}
else
{
adapter = carousalViewAdapter(
awayTeamPlayerList!!,
basketballData.getTeams[1].colors[0]
)
carouselRecyclerview.adapter = adapter
carouselRecyclerview.set3DItem(false)
setIntervalRatio(0.7f)
carouselRecyclerview.setAlpha(true)
carouselRecyclerview.setInfinite(false)
}
In this case ItemSelectListener will only work when all property settings are removed. property will change each time when we set adapter also
java.lang.ArithmeticException: divide by zero
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.onSelectedCallback(CarouselLayoutManager.kt:543)
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.access$onSelectedCallback(CarouselLayoutManager.kt:17)
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager$startScroll$2.onAnimationEnd(CarouselLayoutManager.kt:383)
at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:554)
at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1242)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1484)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1161)
at android.view.Choreographer.doCallbacks(Choreographer.java:986)
at android.view.Choreographer.doFrame(Choreographer.java:894)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1148)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7697)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
set3DItem(true)
setAlpha(true)
setInfinite(true)
applied all the properties still its not working
I liked your library. Thank you.
Do this support for vertical scroll?
java.lang.NullPointerException
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.getChildActualPos(CarouselLayoutManager.kt:468)
at com.jackandphantom.carouselrecyclerview.CarouselRecyclerview.getChildDrawingOrder(CarouselRecyclerview.kt:106)
at android.view.ViewGroup.getAndVerifyPreorderedIndex(ViewGroup.java:1733)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:3510)
at android.view.View.draw(View.java:17192)
at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java:4429)
at android.view.View.updateDisplayListIfDirty(View.java:16171)
at android.view.View.draw(View.java:16955)
...
@sparrow007 glad to see this awsm library Sir...
But I have some doubt related to its adapter, so do I need to use a normal adapter or this library has some sort of in build adapter class ??
For our design we need to use the isFlat mode, but the forced 1.1f spacing is too much. It would be awesome if even with isFlat we could set 0.1f or other values to setIntervalRatio.
I want to show some icons and different colors for the selected item. like, I want to show border for the center/selected item. I tried it by adding it in the adapter item but it's causing issues after notifydataset change.
Is there a way to make the first item focus on Android Tv we use D-Pad..
android:focusableInTouchMode="true"
android:focusable="true"
android:focusedByDefault="true"
android:nextFocusDown="@id/includeRow2"
Does not work
I want to use it with Java.
How I can use it?
Hi there,
I have to dynamically scroll the recycler view to a given positon, unlikely when i use rv.scrollToPosition(givenPosition) the app crashes.
Following the error : " Caused by: kotlin.UninitializedPropertyAccessException: lateinit property recycler has not been initialized at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.scrollToPosition(CarouselLayoutManager.kt:404)".
Really hope someone out there can help me. Thanks a lot
java.lang.ArithmeticException: divide by zero
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.onSelectedCallback(CarouselLayoutManager.kt:543)
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.access$onSelectedCallback(CarouselLayoutManager.kt:17)
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager$startScroll$2.onAnimationEnd(CarouselLayoutManager.kt:383)
at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:554)
at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1250)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1492)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:970)
at android.view.Choreographer.doCallbacks(Choreographer.java:796)
at android.view.Choreographer.doFrame(Choreographer.java:727)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:250)
at android.app.ActivityThread.main(ActivityThread.java:7848)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:958)
Always getting this error when have 1 item in recycler, remove that item, and call adapter.notifyDataSetChanged()
java.lang.ArithmeticException: divide by zero
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.onSelectedCallback(CarouselLayoutManager.kt:641)
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.access$onSelectedCallback(CarouselLayoutManager.kt:17)
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager$startScroll$2.onAnimationEnd(CarouselLayoutManager.kt:473)
at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:554)
at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1253)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1495)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:970)
at android.view.Choreographer.doCallbacks(Choreographer.java:796)
at android.view.Choreographer.doFrame(Choreographer.java:727)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7651)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
In my case app got crashed.
the case is, first I scrolled recyclerview and try to reset the adapter's data before we got the ideal scrolling state of recyclerview.
Have fixed this issue in the below PR.
#40
Hi,
I'm using this library but ReflectionViewContainer failed to load reflection image.
Please, check image
`
<com.jackandphantom.carouselrecyclerview.view.ReflectionViewContainer
android:layout_width="200dp"
android:orientation="vertical"
app:reflect_gap="0dp"
android:layout_gravity="center"
android:gravity="center"
app:reflect_relativeDepth="0.5"
android:layout_height="340dp">
<ImageView
android:layout_width="200dp"
android:id="@+id/carousalImage"
android:layout_height="200dp"
android:scaleType="centerCrop"
/>
</com.jackandphantom.carouselrecyclerview.view.ReflectionViewContainer>`
Tried to add the PagerSnapHelper for the carouselrecyclerview to achieve one item per swipe, but not working
Hi, this is awesome library, amazing experience to use this library, but can i set auto scroll with duration? thanks
java.lang.ArithmeticException: divide by zero
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.onSelectedCallback(CarouselLayoutManager.kt:559)
selectedPosition = abs(selectedPosition % itemCount)
Example for reproducing the issue:
Tried invalidation, canceling animations, removing all views - to no avail.
I love the way this looks, but I have a use case where I need this without the reflection. I am not sure how to go about doing this. Thanks so much!
When an item is removed from the backing dataset and adapter is notified via notifyItemRemoved
method, demo app crashes with NullPointerException.
DataAdapter
and call it within MainActivity
fun removeData() {
// remove last item for test purposes
val orgListSize = list.size
this.list = this.list.subList(0, orgListSize - 1).toList()
notifyItemRemoved(orgListSize - 1)
}
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.jackandphantom.carousellayout, PID: 28559
java.lang.NullPointerException
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.getChildActualPos(CarouselLayoutManager.kt:468)
at com.jackandphantom.carouselrecyclerview.CarouselRecyclerview.getChildDrawingOrder(CarouselRecyclerview.kt:106)
at android.view.ViewGroup.getAndVerifyPreorderedIndex(ViewGroup.java:2134)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4351)
at android.view.View.draw(View.java:22670)
at androidx.recyclerview.widget.RecyclerView.draw(RecyclerView.java:4429)
at android.view.View.updateDisplayListIfDirty(View.java:21491)
at android.view.View.draw(View.java:22377)
at android.view.ViewGroup.drawChild(ViewGroup.java:4595)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4354)
at android.view.View.updateDisplayListIfDirty(View.java:21482)
at android.view.View.draw(View.java:22377)
at android.view.ViewGroup.drawChild(ViewGroup.java:4595)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4354)
at android.view.View.updateDisplayListIfDirty(View.java:21482)
at android.view.View.draw(View.java:22377)
at android.view.ViewGroup.drawChild(ViewGroup.java:4595)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4354)
at android.view.View.updateDisplayListIfDirty(View.java:21482)
at android.view.View.draw(View.java:22377)
at android.view.ViewGroup.drawChild(ViewGroup.java:4595)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4354)
at android.view.View.updateDisplayListIfDirty(View.java:21482)
at android.view.View.draw(View.java:22377)
at android.view.ViewGroup.drawChild(ViewGroup.java:4595)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4354)
at android.view.View.updateDisplayListIfDirty(View.java:21482)
at android.view.View.draw(View.java:22377)
at android.view.ViewGroup.drawChild(ViewGroup.java:4595)
at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4354)
at android.view.View.draw(View.java:22670)
at com.android.internal.policy.DecorView.draw(DecorView.java:826)
at android.view.View.updateDisplayListIfDirty(View.java:21491)
at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:559)
at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:565)
at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:642)
at android.view.ViewRootImpl.draw(ViewRootImpl.java:4372)
at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:4077)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3335)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:2135)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8636)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1035)
at android.view.Choreographer.doCallbacks(Choreographer.java:858)
at android.view.Choreographer.doFrame(Choreographer.java:789)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1020)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:236)
at android.app.ActivityThread.main(ActivityThread.java:8045)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:620)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1011)
It's stable crash on scrolling, probably when re-assign items and adapter on scrolling animation.
java.lang.ArithmeticException: divide by zero
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.onSelectedCallback(CarouselLayoutManager.kt:543)
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.access$onSelectedCallback(CarouselLayoutManager.kt:17)
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager$startScroll$2.onAnimationEnd(CarouselLayoutManager.kt:383)
at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1149)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1309)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
at android.animation.AnimationHandler.-wrap2(AnimationHandler.java)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:869)
at android.view.Choreographer.doCallbacks(Choreographer.java:683)
at android.view.Choreographer.doFrame(Choreographer.java:616)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.