-
-
Notifications
You must be signed in to change notification settings - Fork 879
Add loading indicator to Android Auto favorites screen #6335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…en while fetching entities (Fixes home-assistant#6313)
…en while fetching entities (Fixes home-assistant#6313)
| modifier = Modifier.padding(horizontal = 16.dp).padding(bottom = 16.dp), | ||
| ) | ||
|
|
||
| if (androidAutoViewModel.isLoading) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, after looking at the commits before the last one I prefer this approach as well. Keep the state in the ViewModel instead of 'hacking' it with Compose. The other approach also would fail to hide the loading indicator once loading has completed but there are no compatible entities.
fb0d873 to
14f6542
Compare
|
@TimoPtr Thanks for the feedback! I agree that hiding the server selection during loading is cleaner. |
jpelgrom
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest commit appears to remove all UI. Please fix this and make sure you test before submitting for review again.
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
|
Okay, yes, I'm working on it. |
22a785a to
716aeb9
Compare
...ain/kotlin/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt
Outdated
Show resolved
Hide resolved
dd3dc0b to
af9602b
Compare
jpelgrom
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest commit removes UI again
...ain/kotlin/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt
Outdated
Show resolved
Hide resolved
087b3ec to
4719f11
Compare
| val fromIndex = favoritesList.indexOfFirst { it == fromItem.key } | ||
| if (fromIndex == -1) return | ||
| val item = favoritesList.removeAt(fromIndex) | ||
|
|
||
| val toIndex = favoritesList.indexOfFirst { it == toItem.key } | ||
| if (toIndex == -1) { | ||
| favoritesList.add(fromIndex, item) | ||
| return | ||
| } | ||
|
|
||
| if (fromItem.index < toItem.index) { | ||
| favoritesList.add(toIndex + 1, item) | ||
| } else { | ||
| favoritesList.add(toIndex, item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is new, why doing this on the PR? If you want to address another issue please open another PR with a proper description of the error.
5ef2b49 to
b453559
Compare
|
Hi @TimoPtr @jpelgrom, Kept loading indicator via isLoading in ViewModel Looks good? Ready to move forward. If tweaks needed, let me know. |
|
Out of interest, could you clarify:
|
...ain/kotlin/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt
Fixed
Show fixed
Hide fixed
...ain/kotlin/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt
Fixed
Show fixed
Hide fixed
...ain/kotlin/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt
Fixed
Show fixed
Hide fixed
...ain/kotlin/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt
Fixed
Show fixed
Hide fixed
...kotlin/io/homeassistant/companion/android/settings/vehicle/views/AndroidAutoFavoritesView.kt
Fixed
Show fixed
Hide fixed
...kotlin/io/homeassistant/companion/android/settings/vehicle/views/AndroidAutoFavoritesView.kt
Fixed
Show fixed
Hide fixed
|
Hi @jpelgrom, I used AI help in Android Studio to make these changes. But every time I try to force-push the updated commit to replace the old one, GitHub says there's a problem/conflict that needs to be resolved. Locally everything is fine, but the push always fails like this. Thanks! |
|
Maybe it would be better to close and cancel this pull request and create a new one?? |
|
I tried it again now – this time without force push and it went through normally. |
...ain/kotlin/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt
Fixed
Show fixed
Hide fixed
...ain/kotlin/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt
Fixed
Show fixed
Hide fixed
jpelgrom
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But every time I try to force-push the updated commit to replace the old one, GitHub says there's a problem/conflict that needs to be resolved.
Locally everything is fine, but the push always fails like this.
Any idea why this keeps happening only during force-push?
Force pushing isn't necessary if you only add new commits, on top of an existing branch. Once review has started, it's also preferred to not force push so we can easily review changes instead of having to check all code again.
Not sure how that manages to overwrite the view file with the viewmodel though, never seen that happen before.
...ain/kotlin/io/homeassistant/companion/android/settings/vehicle/ManageAndroidAutoViewModel.kt
Outdated
Show resolved
Hide resolved
| launch { entityRegistries[serverId] = loadEntityRegistry(serverId) } | ||
| launch { deviceRegistries[serverId] = loadDeviceRegistry(serverId) } | ||
| launch { areaRegistries[serverId] = loadAreaRegistry(serverId) } | ||
| listOf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change this to a list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for pointing that out! My intention was to run the tasks in parallel but ensure we wait for all of them to finish before hiding the loading indicator. I realized that collecting them into a list was unnecessary. I have refactored the code to use coroutineScope, which handles the waiting automatically and is much cleaner
…s/vehicle/ManageAndroidAutoViewModel.kt Co-authored-by: Joris Pelgröm <[email protected]>
TimoPtr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please stick to the goal of the PR. You should probably not using AI for something that simple it creates more issues than it solves in this specific cases.
| coroutineScope { | ||
| servers.forEach { server -> | ||
| val serverId = server.id | ||
| launch { entities[serverId] = loadEntitiesForServer(serverId) } | ||
| launch { entityRegistries[serverId] = loadEntityRegistry(serverId) } | ||
| launch { deviceRegistries[serverId] = loadDeviceRegistry(serverId) } | ||
| launch { areaRegistries[serverId] = loadAreaRegistry(serverId) } | ||
| } | ||
| }.awaitAll() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The old behavior was correct. We want all of network calls to happen in // and wait for all to finish once it is done set isLoading to false. With your change we are doing all the call sequentially.
Summary
This PR adds a
CircularProgressIndicatorloading spinner to the Android Auto favorites configuration screen.Motivation
Previously, the screen appeared completely empty for several seconds while entities were being fetched from the server. This felt broken or unresponsive to the user. This change addresses the UX issue reported in #6313.
Changes
CircularProgressIndicatorthat shows while entities are loading.Impact
Testing
Checklist
Any other notes
Fixes #6313