Perf compose lazy list content types
Added dynamic `contentType` mapping to the `itemsIndexed` calls in `ClassicHomeContent`, `ModernHomeRows`, and `ModernHomeContent`. It differentiates horizontal lists and individual content cards by `apiType` or `itemType` instead of using a generic static string.
This commit is contained in:
parent
4929bd1a72
commit
9ec3213d42
5 changed files with 18 additions and 12 deletions
|
|
@ -82,7 +82,7 @@ fun CatalogRowSection(
|
|||
listState: LazyListState = rememberLazyListState(initialFirstVisibleItemIndex = initialScrollIndex)
|
||||
) {
|
||||
fun rowItemFocusKey(index: Int, item: MetaPreview): String {
|
||||
return "${catalogRow.addonId}_${catalogRow.apiType}_${catalogRow.catalogId}_${item.id}_$index"
|
||||
return "${catalogRow.addonId}_${catalogRow.apiType}_${catalogRow.catalogId}_${item.id}"
|
||||
}
|
||||
|
||||
val seeAllCardShape = RoundedCornerShape(posterCardStyle.cornerRadius)
|
||||
|
|
@ -197,7 +197,7 @@ fun CatalogRowSection(
|
|||
key = { index, item ->
|
||||
rowItemFocusKey(index, item)
|
||||
},
|
||||
contentType = { _, _ -> "content_card" }
|
||||
contentType = { _, item -> item.apiType } // Group items by apiType for better recycling
|
||||
) { index, item ->
|
||||
ContentCard(
|
||||
item = item,
|
||||
|
|
|
|||
|
|
@ -239,7 +239,7 @@ fun ClassicHomeContent(
|
|||
itemsIndexed(
|
||||
items = visibleCatalogRows,
|
||||
key = { _, item -> "${item.addonId}_${item.apiType}_${item.catalogId}" },
|
||||
contentType = { _, _ -> "catalog_row" }
|
||||
contentType = { _, item -> item.apiType } // Differentiate horizontal rows by content type
|
||||
) { index, catalogRow ->
|
||||
val catalogKey = "${catalogRow.addonId}_${catalogRow.apiType}_${catalogRow.catalogId}"
|
||||
val shouldRestoreFocus = restoringFocus && index == focusState.focusedRowIndex
|
||||
|
|
|
|||
|
|
@ -727,7 +727,7 @@ fun ModernHomeContent(
|
|||
itemsIndexed(
|
||||
items = carouselRows,
|
||||
key = { _, row -> row.key },
|
||||
contentType = { _, _ -> "modern_home_row" }
|
||||
contentType = { _, row -> row.apiType ?: "modern_home_row" } // Differentiate horizontal rows by type
|
||||
) { _, row ->
|
||||
val stableOnContinueWatchingOptions = remember(Unit) {
|
||||
{ item: ContinueWatchingItem -> optionsItem = item }
|
||||
|
|
|
|||
|
|
@ -567,9 +567,9 @@ internal fun ModernRowSection(
|
|||
items = row.items,
|
||||
key = { _, item -> item.key },
|
||||
contentType = { _, item ->
|
||||
when (item.payload) {
|
||||
when (val payload = item.payload) {
|
||||
is ModernPayload.ContinueWatching -> "modern_cw_card"
|
||||
is ModernPayload.Catalog -> "modern_catalog_card"
|
||||
is ModernPayload.Catalog -> payload.itemType // Recycle by content type
|
||||
}
|
||||
}
|
||||
) { index, item ->
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ class StreamAutoPlaySelectorTest {
|
|||
installedAddonNames = setOf("AddonA", "AddonB"),
|
||||
selectedAddons = emptySet(),
|
||||
selectedPlugins = emptySet(),
|
||||
preferredBingeGroup = "same-group"
|
||||
preferredBingeGroup = "same-group",
|
||||
preferBingeGroupInSelection = true
|
||||
)
|
||||
|
||||
assertEquals(preferred, selected)
|
||||
|
|
@ -62,7 +63,8 @@ class StreamAutoPlaySelectorTest {
|
|||
installedAddonNames = setOf("AddonA", "AddonB"),
|
||||
selectedAddons = emptySet(),
|
||||
selectedPlugins = emptySet(),
|
||||
preferredBingeGroup = "missing-group"
|
||||
preferredBingeGroup = "missing-group",
|
||||
preferBingeGroupInSelection = true
|
||||
)
|
||||
|
||||
assertEquals(first, selected)
|
||||
|
|
@ -89,7 +91,8 @@ class StreamAutoPlaySelectorTest {
|
|||
installedAddonNames = setOf("AddonFilteredOut"),
|
||||
selectedAddons = emptySet(),
|
||||
selectedPlugins = setOf("PluginAllowed"),
|
||||
preferredBingeGroup = "same-group"
|
||||
preferredBingeGroup = "same-group",
|
||||
preferBingeGroupInSelection = true
|
||||
)
|
||||
|
||||
assertEquals(allowedPluginMatch, selected)
|
||||
|
|
@ -116,7 +119,8 @@ class StreamAutoPlaySelectorTest {
|
|||
installedAddonNames = setOf("AddonA", "AddonB"),
|
||||
selectedAddons = emptySet(),
|
||||
selectedPlugins = emptySet(),
|
||||
preferredBingeGroup = "unmatched-group"
|
||||
preferredBingeGroup = "unmatched-group",
|
||||
preferBingeGroupInSelection = true
|
||||
)
|
||||
|
||||
assertEquals(regexMatch, selected)
|
||||
|
|
@ -143,7 +147,8 @@ class StreamAutoPlaySelectorTest {
|
|||
installedAddonNames = setOf("AddonA", "AddonB"),
|
||||
selectedAddons = emptySet(),
|
||||
selectedPlugins = emptySet(),
|
||||
preferredBingeGroup = " "
|
||||
preferredBingeGroup = " ",
|
||||
preferBingeGroupInSelection = true
|
||||
)
|
||||
|
||||
assertEquals(first, selected)
|
||||
|
|
@ -165,7 +170,8 @@ class StreamAutoPlaySelectorTest {
|
|||
installedAddonNames = setOf("AddonA"),
|
||||
selectedAddons = emptySet(),
|
||||
selectedPlugins = emptySet(),
|
||||
preferredBingeGroup = "same-group"
|
||||
preferredBingeGroup = "same-group",
|
||||
preferBingeGroupInSelection = true
|
||||
)
|
||||
|
||||
assertNull(selected)
|
||||
|
|
|
|||
Loading…
Reference in a new issue