From 5a2948bf8a14e607bc07d57d35cedc354a69d9b4 Mon Sep 17 00:00:00 2001 From: Ray Ryan Date: Thu, 16 Mar 2023 13:34:01 -0700 Subject: [PATCH] Fixes bad readSparseArray call in WorkflowLayout Crash on restore on Tiramisu / 33 or later --- .../main/java/com/squareup/workflow1/ui/WorkflowLayout.kt | 2 +- .../com/squareup/workflow1/ui/container/ViewStateFrame.kt | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/workflow-ui/core-android/src/main/java/com/squareup/workflow1/ui/WorkflowLayout.kt b/workflow-ui/core-android/src/main/java/com/squareup/workflow1/ui/WorkflowLayout.kt index 904313ce6..b230ef2c0 100644 --- a/workflow-ui/core-android/src/main/java/com/squareup/workflow1/ui/WorkflowLayout.kt +++ b/workflow-ui/core-android/src/main/java/com/squareup/workflow1/ui/WorkflowLayout.kt @@ -252,7 +252,7 @@ public class WorkflowLayout( constructor(source: Parcel) : super(source) { this.childState = if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) { - source.readSparseArray(SavedState::class.java.classLoader, SavedState::class.java)!! + source.readSparseArray(SavedState::class.java.classLoader, Parcelable::class.java)!! } else { @Suppress("DEPRECATION") source.readSparseArray(SavedState::class.java.classLoader)!! diff --git a/workflow-ui/core-android/src/main/java/com/squareup/workflow1/ui/container/ViewStateFrame.kt b/workflow-ui/core-android/src/main/java/com/squareup/workflow1/ui/container/ViewStateFrame.kt index 5447f134a..ea439918d 100644 --- a/workflow-ui/core-android/src/main/java/com/squareup/workflow1/ui/container/ViewStateFrame.kt +++ b/workflow-ui/core-android/src/main/java/com/squareup/workflow1/ui/container/ViewStateFrame.kt @@ -32,10 +32,7 @@ internal data class ViewStateFrame( override fun createFromParcel(parcel: Parcel): ViewStateFrame { val key = parcel.readString()!! val viewState = if (VERSION.SDK_INT >= VERSION_CODES.TIRAMISU) { - parcel.readSparseArray( - ViewStateFrame::class.java.classLoader, - Parcelable::class.java - )!! + parcel.readSparseArray(ViewStateFrame::class.java.classLoader, Parcelable::class.java)!! } else { @Suppress("DEPRECATION") parcel.readSparseArray(ViewStateFrame::class.java.classLoader)!!