Skip to content
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

Updates AmbientAware to avoid recreating whole tree #2050

Merged
merged 2 commits into from
Feb 20, 2024
Merged

Conversation

garanj
Copy link
Collaborator

@garanj garanj commented Feb 20, 2024

WHAT

Updates AmbientAware to avoid recreating whole tree (see issue #2041) - thanks to @marcin-adamczewski

WHY

Current implementation recreates whole tree when isAlwaysOnScreen boolean changes

HOW

Follow best practice for remembering always-on state

Checklist 📋

  • Add explicit visibility modifier and explicit return types for public declarations
  • Run spotless check
  • Run tests
  • Update metalava's signature text files

@garanj garanj requested a review from yschimke February 20, 2024 10:27

override fun onExitAmbient() {
ambientUpdate = AmbientStateUpdate(AmbientState.Interactive)
AmbientLifecycleObserver(activity, callback).also {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the future, there is a comment that AmbientLifecycleObserver being mocked out.

Something we should consider for testing and previews.

https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:wear/wear/src/main/java/androidx/wear/ambient/AmbientLifecycleObserver.kt;l=109?q=AmbientLifecycleObserver

@yschimke yschimke merged commit 492231f into main Feb 20, 2024
4 checks passed
@yschimke yschimke deleted the ambient-aware branch February 20, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants