0

I got a RecyclerView with an ItemTouchHelper implemented. The app crashes when swiping an item and changing the current fragment in the same time (Yeah I got a crashlytics about that and could reproduce it).

The following crash exception is from ItemTouchHelper class. The crash happens at this method postDispatchSwipe, the RecyclerView is null. As the method is called after the swipe gesture, I'm wondering if there is something I can do from my side or fill an google issue.

If you guys have any idea... Thanks :)

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean androidx.recyclerview.widget.RecyclerView.post(java.lang.Runnable)' on a null object reference
        at androidx.recyclerview.widget.ItemTouchHelper.postDispatchSwipe(ItemTouchHelper.java:700)
        at androidx.recyclerview.widget.ItemTouchHelper$3.onAnimationEnd(ItemTouchHelper.java:653)
        at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:552)
        at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1232)
        at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1474)
        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:1063)
        at android.view.Choreographer.doCallbacks(Choreographer.java:877)
        at android.view.Choreographer.doFrame(Choreographer.java:805)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1051)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:201)
        at android.app.ActivityThread.main(ActivityThread.java:6806)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Toubap
  • 29
  • 7
  • Your problem lacks of information. Could You provide some of the code? – deadfish Mar 27 '19 at 10:45
  • I don't see what code could be provided. It's android side. You execute a swipe gesture, at the end of the animation the method `postDispatchSwipe` is called but if you have change the fragment in the meantime the RecyclerView gets null. From my code the ÌtemTouchHelper.SimpleCallback` is properly detached in the fragment onDestroy() method which makes the RecyclerView null whereas there is no null check after the animation in the ÌtemTouchHelper code. Hope my comment will help explain a bit more – Toubap Mar 27 '19 at 10:58
  • It explains a bit. But how can I help You if I can't check the code? – deadfish Mar 27 '19 at 12:43
  • @T Any update on whether you found a fix for this androidx specific error? – lini sax Jun 18 '19 at 23:08
  • Yes, I opened an issue. Google seems to be looking into it : https://issuetracker.google.com/issues/129362598 – Toubap Jun 27 '19 at 12:52

0 Answers0