Skip to content

Commit b9f3d65

Browse files
authored
Merge pull request #453 from android/mlykotom/fix-perf-codelab-constraints
Fix performance codelab end state
2 parents 92c0744 + bb8cdbc commit b9f3d65

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

PerformanceCodelab/app/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ composeCompiler {
6969
// This settings enables strong-skipping mode for all module in this project.
7070
// As an effect, Compose can skip a composable even if it's unstable by comparing it's instance equality (===).
7171
// TODO Codelab task: Enable Strong Skipping Mode
72-
enableStrongSkippingMode = false
72+
enableStrongSkippingMode = true
7373

7474
// TODO Codelab task: Enable Stability Configuration file
75+
stabilityConfigurationFile = project.rootDir.resolve("stability_config.conf")
7576
}
7677

7778
dependencies {

PerformanceCodelab/app/src/main/java/com/compose/performance/phases/PhasesAnimatedShape.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ fun MyShape(size: () -> Dp, modifier: Modifier = Modifier) = trace("MyShape") {
7979
val sizePx = size()
8080
.roundToPx()
8181
.coerceAtLeast(0)
82-
val constraints = Constraints(
83-
minWidth = sizePx,
84-
maxWidth = sizePx,
85-
minHeight = sizePx,
86-
maxHeight = sizePx
82+
83+
val constraints = Constraints.fixed(
84+
width = sizePx,
85+
height = sizePx,
8786
)
87+
8888
val placeable = measurable.measure(constraints)
8989
layout(sizePx, sizePx) {
9090
placeable.place(0, 0)

PerformanceCodelab/app/src/main/java/com/compose/performance/stability/StabilityViewModel.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.compose.performance.stability
1717

18+
import androidx.compose.runtime.Immutable
1819
import androidx.compose.runtime.getValue
1920
import androidx.compose.runtime.mutableStateOf
2021
import androidx.compose.runtime.neverEqualPolicy
@@ -32,6 +33,7 @@ import kotlinx.coroutines.flow.onEach
3233
import kotlinx.coroutines.flow.stateIn
3334

3435
// TODO Codelab task: make this class Stable
36+
@Immutable
3537
data class StabilityItem(
3638
val id: Int,
3739
val type: StabilityItemType,
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
// TODO Codelab task: Make a java.time.LocalDate class stable.
2+
3+
java.time.LocalDate

0 commit comments

Comments
 (0)