Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b0dd8b11 authored by Darrell Shi's avatar Darrell Shi
Browse files

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
parent 32669c5b
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -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 = {},
    )
}