mirror of
https://github.com/tuskyapp/Tusky
synced 2025-02-09 20:20:43 +01:00
Found this crash in the Google Play reports: ``` Exception java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0 at jdk.internal.util.Preconditions.outOfBounds (Preconditions.java:64) at jdk.internal.util.Preconditions.outOfBoundsCheckIndex (Preconditions.java:70) at jdk.internal.util.Preconditions.checkIndex (Preconditions.java:266) at java.util.Objects.checkIndex (Objects.java:359) at java.util.ArrayList.get (ArrayList.java:434) at java.util.Collections$UnmodifiableList.get (Collections.java:1394) at com.keylesspalace.tusky.components.compose.MediaPreviewAdapter.onMediaClick (MediaPreviewAdapter.java:45) at com.keylesspalace.tusky.components.compose.MediaPreviewAdapter.access$onMediaClick (MediaPreviewAdapter.java:32) at com.keylesspalace.tusky.components.compose.MediaPreviewAdapter$PreviewViewHolder._init_$lambda$0 (MediaPreviewAdapter.java:144) at android.view.View.performClick (View.java:7535) at android.view.View.performClickInternal (View.java:7512) at android.view.View.-$$Nest$mperformClickInternal at android.view.View$PerformClick.run (View.java:29488) at android.os.Handler.handleCallback (Handler.java:984) at android.os.Handler.dispatchMessage (Handler.java:104) at android.os.Looper.loopOnce (Looper.java:238) at android.os.Looper.loop (Looper.java:357) at android.app.ActivityThread.main (ActivityThread.java:8118) at java.lang.reflect.Method.invoke at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:957) ``` Can't reproduce, but seems to be some kind of race condition where the view is clicked at the same time as it is being removed from the `RecyclerView`. Not using the index in the click listener should resolve the problem. Also refactored to `ListAdapter` to not deal with the `AsyncListDiffer` manually.