Fixed
Status Update
Comments
sh...@google.com <sh...@google.com>
ap...@google.com <ap...@google.com> #2
since these are in public API (:/) we need to do this in 1.2
sh...@google.com <sh...@google.com> #3
since it is already marked as deprecated, we can probably do it by now.
ge...@deliveroo.co.uk <ge...@deliveroo.co.uk> #4
Opening diff shortly
Description
Code to reproduce:
The Android ItemTouchHelper class can crash when overriding clearView() in the ItemTouchHelper.Callback because the restore animations are not cancelled when detaching the the touch helper from the RecyclerView. When the restore animation completes, it attempts to invoke clearView() on the callback and calls the method with a null RecyclerView. The RecyclerView parameter is annotated as @NonNull and Kotlin expects a non-nullable value.
This issue was discovered because with new gesture based navigation on Android 10 is it easy to start swiping a list item while attempting to swipe to go back. Our application detaches the touch helper from the RecyclerView whenever a fragment's view is destroyed.
See the Github link for code to reproduce this issue.
Stack trace
------------
java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter recyclerView
at com.victorrendina.touchhelpercrash.SampleItemTouchHelperCallback.clearView(Unknown Source:2)
at androidx.recyclerview.widget.ItemTouchHelper$3.onAnimationEnd(ItemTouchHelper.java:644)
at android.animation.Animator$AnimatorListener.onAnimationEnd(Animator.java:554)
...