Giter Club home page Giter Club logo

carouselrecyclerview's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

carouselrecyclerview's Issues

java.lang.ArithmeticException: divide by zero

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)

java.lang.ArithmeticException: divide by zero

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)

CarouselRecyclerView not scrolling to given position

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

ReflectionViewContainer Not loading reflection image

Hi,
I'm using this library but ReflectionViewContainer failed to load reflection image.
Please, check image

`
Screenshot_2021-07-17-20-08-04-971_com example a3dgallery
<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>`

App is getting crashed when try to reset data

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

PagerSnapHelper not working

Tried to add the PagerSnapHelper for the carouselrecyclerview to achieve one item per swipe, but not working

setItemSelectlistener will not work when changing adapter with setting alpha

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

Non Touch devices

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

How to Implement Adapter ??

@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 ??

Removing an item causes NullPointerException

When an item is removed from the backing dataset and adapter is notified via notifyItemRemoved method, demo app crashes with NullPointerException.

  • Add method to 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)
    }
  • App crashes with the following exception log
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)

IndexOutOfBoundsException: Invalid item position when smoothScrollToPosition

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?

java.lang.ArithmeticException: divide by zero in version 1.2.2

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)

Divide by zero crash when calling notifydatasetchanged during scroll animation

java.lang.ArithmeticException: divide by zero
at com.jackandphantom.carouselrecyclerview.CarouselLayoutManager.onSelectedCallback(CarouselLayoutManager.kt:559)

selectedPosition = abs(selectedPosition % itemCount)

Example for reproducing the issue:

  1. Have a carousel recyclerview in a layout under SwipeRefreshLayout
  2. Use the SwipeRefreshLayout to load the list items using notifydatasetchanged on the adapter while the carousel is inbetween 2 items

Tried invalidation, canceling animations, removing all views - to no avail.

App getting crashed

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)

Adapter.notifyItemChanged(int) causes it to crash

    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)
...

Remove Reflection Image?

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!

Pagination handling

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()
                        }
                    }
                }
            })

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.