summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Darrell Shi <darrellshi@google.com> 2023-12-26 18:40:12 -0800
committer Darrell Shi <darrellshi@google.com> 2023-12-26 18:40:12 -0800
commitb0dd8b11da8e6afcb89ef4e6df5d856775482a9d (patch)
tree1b169255680db99a366845eeecdaeb6f85e4f21a
parent32669c5beeb187a15c1441491d422bde45ce811d (diff)
Reuse compositions only when content key matching
This change declares the content type in the lazy grid so that it only reuses compositions when the content types are identical. Bug: 312052098 Bug: 317269504 Fix: 317269504 Test: add 10 widgets in the grid and ensure compositions are reused correctly Test: start/pause/unpause smartspace timers and ensure remote views are recomposed as the key changes Flag: ACONFIG com.android.systemui.communal_hub DEVELOPMENT Change-Id: I4e347285916cfec09a9c2a266d715231ac10bafb
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt5
1 files changed, 4 insertions, 1 deletions
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt
index 2a9cf0fdc507..d1072aa1755e 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/communal/ui/compose/CommunalHub.kt
@@ -178,6 +178,7 @@ private fun CommunalHubLazyGrid(
items(
count = list.size,
key = { index -> list[index].key },
+ contentType = { index -> list[index].key },
span = { index -> GridItemSpan(list[index].size.span) },
) { index ->
val cardModifier = Modifier.width(Dimensions.CardWidth)
@@ -333,6 +334,8 @@ private fun WidgetContent(
.createView(context, model.appWidgetId, model.providerInfo)
.apply { updateAppWidgetSize(Bundle.EMPTY, listOf(size)) }
},
+ // For reusing composition in lazy lists.
+ onReset = {},
)
}
}
@@ -348,7 +351,7 @@ private fun SmartspaceContent(
FrameLayout(context).apply { addView(model.remoteViews.apply(context, this)) }
},
// For reusing composition in lazy lists.
- onReset = {}
+ onReset = {},
)
}