nowinandroid
nowinandroid copied to clipboard
Optimize startup by preventing whole screen recomposing twice
What I have done and why
I reworked the way how we set up the MainActivity wrt to theming and user settings.
This includes:
- reacting to
uiMode
config change (before, the whole activity would be recreated when theme changed) - encapsulate the state logic into its class
- prevent calling
enableEdgeToEdge
twice with different settings
This way I can get rid of one whole-screen recomposition, which is ~12ms on a Pixel 6.
Do tests pass?
- [x] Run local tests on
DemoDebug
variant:./gradlew testDemoDebug
- [x] Check formatting:
./gradlew --init-script gradle/init.gradle.kts spotlessApply
Combined test coverage report
Overall Project | 39.98% -0.25% |
:x: |
---|---|---|
Files changed | 64.57% | :green_apple: |
Module | Coverage | |
---|---|---|
data | 59.65% -5.52% |
:x: |
app | 28.33% -0.25% |
:green_apple: |
Files
Module | File | Coverage | |
---|---|---|---|
data | ConnectivityManagerNetworkMonitor.kt | 0% -60.65% |
:x: |
app | MainActivityViewModel.kt | 90.38% -9.62% |
:green_apple: |
UiExtensions.kt | 81.93% -18.07% |
:green_apple: | |
MainActivity.kt | 81.83% -1.23% |
:green_apple: |
Combined test coverage report
Overall Project | 40.01% -0.05% |
:green_apple: |
---|---|---|
Files changed | 90.27% | :green_apple: |
Module | Coverage | |
---|---|---|
app | 28.33% -0.25% |
:green_apple: |
Files
Module | File | Coverage | |
---|---|---|---|
app | MainActivityViewModel.kt | 90.38% -9.62% |
:green_apple: |
UiExtensions.kt | 81.93% -18.07% |
:green_apple: | |
MainActivity.kt | 81.83% -1.23% |
:green_apple: |
Combined test coverage report
Overall Project | 40.05% -0.06% |
:green_apple: |
---|---|---|
Files changed | 89.58% | :green_apple: |
Module | Coverage | |
---|---|---|
app | 28.55% -0.28% |
:green_apple: |
Files
Module | File | Coverage | |
---|---|---|---|
app | MainActivityViewModel.kt | 90.38% -9.62% |
:green_apple: |
UiExtensions.kt | 81.93% -18.07% |
:green_apple: | |
MainActivity.kt | 81.82% -2.02% |
:green_apple: |
Combined test coverage report
Overall Project | 40.02% -0.06% |
:green_apple: |
---|---|---|
Files changed | 89.58% | :green_apple: |
Module | Coverage | |
---|---|---|
app | 28.55% -0.28% |
:green_apple: |
Files
Module | File | Coverage | |
---|---|---|---|
app | MainActivityViewModel.kt | 90.38% -9.62% |
:green_apple: |
UiExtensions.kt | 81.93% -18.07% |
:green_apple: | |
MainActivity.kt | 81.82% -2.02% |
:green_apple: |