Raghav
08/21/2023, 9:01 AMRaghav
08/21/2023, 9:02 AMRaghav
08/21/2023, 9:02 AMxoangon
08/21/2023, 9:10 AMState<T>
wrapper in the ViewModel
. The ViewModel
should only contain data that will then be turned into a Compose State
by using StateFlow::collectAsState
or StateFlow::collectAsStateWithLifecycle
2. As the List
Kotlin type is not immutable, but a read-only collection, it’s not treated as stable. You should be using a PersistentList
or ImmutableList
Raghav
08/21/2023, 9:14 AMxoangon
08/21/2023, 9:18 AMRaghav
08/21/2023, 9:18 AMxoangon
08/21/2023, 9:19 AMxoangon
08/21/2023, 9:20 AMList
as part of the state. It won’t be treated as stableRaghav
08/21/2023, 9:22 AMRaghav
08/21/2023, 9:24 AMxoangon
08/21/2023, 9:26 AMListState.Content
as an argument to a Composable function. As this ListState.Content
has a List
property, it will be treated as unstable by the compiler.
In the picture, the change that will make your state stable for ComposeRaghav
08/21/2023, 9:30 AMxoangon
08/21/2023, 9:35 AMRaghav
08/21/2023, 9:35 AMxoangon
08/21/2023, 9:37 AMRaghav
08/21/2023, 9:39 AMRaghav
08/21/2023, 9:40 AMxoangon
08/21/2023, 9:42 AMxoangon
08/21/2023, 9:47 AMascii
08/21/2023, 1:14 PMSwipeRefreshLayout
nor RecylerView
have their own background in your code, so they don't redraw over the already-existing window background (from Theme.AppCompat
).
On the other hand, LazyColumnActivity
is supplied the same AppCompat
theme, which means window background has already been drawn, but then you're also putting Compose's own theming on top of it.
The whole point of Compose is to move away from traditional concepts and resource bloat. You should move away from AppCompat
themes anyway, but if you can't, just use this override and you'll no longer see the additional overdraw:
<item name="android:windowBackground">@android:color/transparent</item>
ascii
08/21/2023, 1:18 PMstable
parameters wherever possible, and that they're restartable skippable
. See https://github.com/androidx/androidx/blob/androidx-main/compose/compiler/design/compiler-metrics.md for more info.romainguy
08/21/2023, 3:11 PMromainguy
08/21/2023, 3:11 PMSurface
somewhere (in your Scaffold
?)romainguy
08/21/2023, 3:12 PMromainguy
08/21/2023, 3:12 PMromainguy
08/21/2023, 3:12 PMxoangon
08/21/2023, 8:55 PMRaghav
08/22/2023, 5:08 AMRaghav
08/22/2023, 5:19 AMromainguy
08/22/2023, 5:21 AMRaghav
08/22/2023, 5:27 AMRaghav
08/22/2023, 5:30 AM