Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Issues with "Changes sample app to use view pager 2" #50

Open
kaaholst opened this issue Feb 6, 2021 · 3 comments
Open

Issues with "Changes sample app to use view pager 2" #50

kaaholst opened this issue Feb 6, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@kaaholst
Copy link

kaaholst commented Feb 6, 2021

I've experienced various issues in the sample app, after the above commit, which is on the development branch as of 26 Nov 2020.

I put them all here in the same issue, because they might share the same root cause.

  1. When switching tabs he app will sometimes crash with the below stacktrace. Unfortunately I haven't found a way to reliably trigger this, but it does occur frequently.
  2. Display a tab, switch to another tab and then go back to the original tab, will stop the fast scroller handle from moving when the list is scrolled. The fast scroller handle still works. When using the Basic tab, this means that the fast scroller will not become visible when the list is scrolled.

2021-02-05 22:50:22.986 26158-26158/com.qtalk.sample D/RVFastScroller: Touch Action: 1
2021-02-05 22:50:24.590 26158-26158/com.qtalk.sample D/AndroidRuntime: Shutting down VM
2021-02-05 22:50:24.599 26158-26158/com.qtalk.sample E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.qtalk.sample, PID: 26158
java.lang.IllegalStateException: Observer com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller$adapterDataObserver$1$1@e29f01d was not registered.
at android.database.Observable.unregisterObserver(Observable.java:69)
at androidx.recyclerview.widget.RecyclerView$Adapter.unregisterAdapterDataObserver(RecyclerView.java:7537)
at com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller.detachFastScrollerFromRecyclerView(RecyclerViewFastScroller.kt:964)
at com.qtalk.recyclerviewfastscroller.RecyclerViewFastScroller.onDetachedFromWindow(RecyclerViewFastScroller.kt:381)
at android.view.View.dispatchDetachedFromWindow(View.java:17456)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3681)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3673)
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:3673)
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:5227)
at android.view.ViewGroup.removeViewAt(ViewGroup.java:5174)
at androidx.recyclerview.widget.RecyclerView$5.removeViewAt(RecyclerView.java:915)
at androidx.recyclerview.widget.ChildHelper.removeViewAt(ChildHelper.java:168)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.removeViewAt(RecyclerView.java:8946)
at androidx.recyclerview.widget.RecyclerView$LayoutManager.removeAndRecycleViewAt(RecyclerView.java:9217)
at androidx.recyclerview.widget.LinearLayoutManager.recycleChildren(LinearLayoutManager.java:1437)
at androidx.recyclerview.widget.LinearLayoutManager.recycleViewsFromEnd(LinearLayoutManager.java:1531)
at androidx.recyclerview.widget.LinearLayoutManager.recycleByLayoutState(LinearLayoutManager.java:1556)
at androidx.recyclerview.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1582)
at androidx.recyclerview.widget.LinearLayoutManager.scrollBy(LinearLayoutManager.java:1395)
at androidx.recyclerview.widget.LinearLayoutManager.scrollHorizontallyBy(LinearLayoutManager.java:1124)
at androidx.recyclerview.widget.RecyclerView.scrollStep(RecyclerView.java:1969)
at androidx.recyclerview.widget.RecyclerView$ViewFlinger.run(RecyclerView.java:5476)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1029)
at android.view.Choreographer.doCallbacks(Choreographer.java:841)
at android.view.Choreographer.doFrame(Choreographer.java:769)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1015)
at android.os.Handler.handleCallback(Handler.java:793)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:173)
at android.app.ActivityThread.main(ActivityThread.java:6698)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:782)

@shahsurajk shahsurajk added the bug Something isn't working label Feb 7, 2021
@LunarX
Copy link

LunarX commented Apr 5, 2022

I have the same problem, and found out that rewriting the function registerDataObserver() of the library as follows did seem to circumvent the crash. But I'm not sure this tackles the root of the issue.

The problem seems to be caused because the observer is registered more than once before being detached. It is first registered in initImpl() and then, every time you click and scroll down using the scrollbar, the observer is registered again at line 418.

@shahsurajk would you happen to have any insight on the issue?

By the way, this is the same issue as #43

My temporary fix:

private fun registerDataObserver() {
    if (recyclerView.adapter?.hasObservers() != true) {
        recyclerView.adapter?.registerAdapterDataObserver(adapterDataObserver.value)
    }
}

@hamed8080
Copy link

I have exactly the same problem and I hope it'll be fixed because it's one of the most popular libraries that I think most developers use!

@SweetD3v
Copy link

I solved it. Check my answer here - solution

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants