diff --git a/PerformanceCodelab/app/build.gradle.kts b/PerformanceCodelab/app/build.gradle.kts index b1ba4c99d..18ba60b03 100644 --- a/PerformanceCodelab/app/build.gradle.kts +++ b/PerformanceCodelab/app/build.gradle.kts @@ -69,9 +69,10 @@ composeCompiler { // This settings enables strong-skipping mode for all module in this project. // As an effect, Compose can skip a composable even if it's unstable by comparing it's instance equality (===). // TODO Codelab task: Enable Strong Skipping Mode - enableStrongSkippingMode = false + enableStrongSkippingMode = true // TODO Codelab task: Enable Stability Configuration file + stabilityConfigurationFile = project.rootDir.resolve("stability_config.conf") } dependencies { diff --git a/PerformanceCodelab/app/src/main/java/com/compose/performance/phases/PhasesAnimatedShape.kt b/PerformanceCodelab/app/src/main/java/com/compose/performance/phases/PhasesAnimatedShape.kt index 1ce218bf8..5310c67c7 100644 --- a/PerformanceCodelab/app/src/main/java/com/compose/performance/phases/PhasesAnimatedShape.kt +++ b/PerformanceCodelab/app/src/main/java/com/compose/performance/phases/PhasesAnimatedShape.kt @@ -79,12 +79,12 @@ fun MyShape(size: () -> Dp, modifier: Modifier = Modifier) = trace("MyShape") { val sizePx = size() .roundToPx() .coerceAtLeast(0) - val constraints = Constraints( - minWidth = sizePx, - maxWidth = sizePx, - minHeight = sizePx, - maxHeight = sizePx + + val constraints = Constraints.fixed( + width = sizePx, + height = sizePx, ) + val placeable = measurable.measure(constraints) layout(sizePx, sizePx) { placeable.place(0, 0) diff --git a/PerformanceCodelab/app/src/main/java/com/compose/performance/stability/StabilityViewModel.kt b/PerformanceCodelab/app/src/main/java/com/compose/performance/stability/StabilityViewModel.kt index 2adef7aba..76e690192 100644 --- a/PerformanceCodelab/app/src/main/java/com/compose/performance/stability/StabilityViewModel.kt +++ b/PerformanceCodelab/app/src/main/java/com/compose/performance/stability/StabilityViewModel.kt @@ -15,6 +15,7 @@ */ package com.compose.performance.stability +import androidx.compose.runtime.Immutable import androidx.compose.runtime.getValue import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.neverEqualPolicy @@ -32,6 +33,7 @@ import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.stateIn // TODO Codelab task: make this class Stable +@Immutable data class StabilityItem( val id: Int, val type: StabilityItemType, diff --git a/PerformanceCodelab/stability_config.conf b/PerformanceCodelab/stability_config.conf index 68fd0b7fe..5f96adb3f 100644 --- a/PerformanceCodelab/stability_config.conf +++ b/PerformanceCodelab/stability_config.conf @@ -1 +1,3 @@ // TODO Codelab task: Make a java.time.LocalDate class stable. + +java.time.LocalDate