google-developer-training / basic-android-kotlin-compose-training-dessert-release

Apache License 2.0
29 stars 22 forks source link

Showing the default preference setting in split second on time while start the app #13

Open BitMavrick opened 1 year ago

BitMavrick commented 1 year ago

In the ViewModel there's code ,

data class DessertReleaseUiState( val isLinearLayout: Boolean = true, val toggleContentDescription: Int = if (isLinearLayout) R.string.grid_layout_toggle else R.string.linear_layout_toggle, val toggleIcon: Int = if (isLinearLayout) R.drawable.ic_grid_layout else R.drawable.ic_linear_layout )

which shows the default settings, after in very short delay the preference setting restored. I think it would be nice to showing any splash screen or some loading animation in the meantime that moment of time

Derrick-Mwendwa commented 8 months ago

I've noticed this too. When you change the layout to grid and the preference is stored, when relaunching the app it will display the linear layout for a split second before switching to grid (it may not be visible in release configuration but I am not sure).

I am not sure of the exact cause of this but I think it occurs when we convert our cold flow to a hot one in the viewmodel, it could have something to do with the initialValue parameter.

Jaehwa-Noh commented 7 months ago

I also noticed it. It is because of DataStore feature, which supports fully asynchronous work, not synchronous.