Fixed
Status Update
Comments
sh...@google.com <sh...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 7a5dbef71e63eabf376dbd9e7f9d16aa36f5ba14
Author: Shep Shapard <shepshapard@google.com>
Date: Thu Nov 14 17:16:34 2019
ItemTouchHelper animations now stopped when RV is detached.
Previously, an RV could be detached from ItemTouchHelper
during ItemTouchHelper animations, and when they finished
they would assume the RV was not null.
Now the animations themselves are stopped when an RV
is detached.
Bug: 140447176
Test: ./gradlew recyclerview:recyclerview:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=androidx.recyclerview.widget.ItemTouchHelperTest
Change-Id: Ib9a5a124875704bd55ea60872e5638b5a9b74b49
M recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/ItemTouchHelperTest.java
M recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/TouchUtils.java
M recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/ItemTouchHelper.java
https://android-review.googlesource.com/1167575
Branch: androidx-master-dev
commit 7a5dbef71e63eabf376dbd9e7f9d16aa36f5ba14
Author: Shep Shapard <shepshapard@google.com>
Date: Thu Nov 14 17:16:34 2019
ItemTouchHelper animations now stopped when RV is detached.
Previously, an RV could be detached from ItemTouchHelper
during ItemTouchHelper animations, and when they finished
they would assume the RV was not null.
Now the animations themselves are stopped when an RV
is detached.
Bug: 140447176
Test: ./gradlew recyclerview:recyclerview:connectedCheck --info --daemon -Pandroid.testInstrumentationRunnerArguments.class=androidx.recyclerview.widget.ItemTouchHelperTest
Change-Id: Ib9a5a124875704bd55ea60872e5638b5a9b74b49
M recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/ItemTouchHelperTest.java
M recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/TouchUtils.java
M recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/ItemTouchHelper.java
sh...@google.com <sh...@google.com> #3
The fix will be available in the next release of RecyclerView (post 1.1.0).
ge...@deliveroo.co.uk <ge...@deliveroo.co.uk> #4
We still receive this crash with version 1.2.1 of recyclerview. Is this fix verified that it works?
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)
...