Skip to content

Commit 5ca7f54

Browse files
authored
Prevent redrawing twice and running timer when compositions =0 (#304)
1 parent e3ee4b2 commit 5ca7f54

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

compose/recomposehighlighter/src/main/java/com/example/android/compose/recomposehighlighter/RecomposeHighlighter.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ private class RecomposeHighlighterModifier : Modifier.Node(), DrawModifierNode {
7373
private var totalCompositions: Long = 0
7474
set(value) {
7575
if (field == value) return
76-
restartTimer()
76+
if (value > 0) restartTimer()
7777
field = value
7878
invalidateDraw()
7979
}
@@ -103,7 +103,6 @@ private class RecomposeHighlighterModifier : Modifier.Node(), DrawModifierNode {
103103
timerJob = coroutineScope.launch {
104104
delay(3000)
105105
totalCompositions = 0
106-
invalidateDraw()
107106
}
108107
}
109108

0 commit comments

Comments
 (0)