[XR] add in XR device lifecycle snippets#846
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces foundational code for managing the lifecycle of XR devices within an Android application. By integrating with the Android Lifecycle, it provides a standardized and clear mechanism to monitor device state changes, which is crucial for optimizing performance and user experience in XR applications. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds a code snippet for the XR device lifecycle. My review identifies an opportunity to make the example more robust. The current implementation for checking the device's active state is incomplete. I've provided a suggestion to correctly handle all relevant lifecycle states, which will improve the clarity and correctness of the code snippet for developers who use it.
| when (state) { | ||
| Lifecycle.State.STARTED -> { /* Device is ACTIVE (worn) */ } | ||
| Lifecycle.State.CREATED -> { /* Device is INACTIVE (not worn) */ } | ||
| else -> { /* Handle other states */ } | ||
| } |
There was a problem hiding this comment.
The current logic for determining if the device is active only checks for Lifecycle.State.STARTED. However, a component in the STARTED state will typically transition to RESUMED. The RESUMED state would also be considered 'active', but it falls into the else block in the current implementation. To make this example more robust and accurate, it's better to check if the state is at least STARTED.
| when (state) { | |
| Lifecycle.State.STARTED -> { /* Device is ACTIVE (worn) */ } | |
| Lifecycle.State.CREATED -> { /* Device is INACTIVE (not worn) */ } | |
| else -> { /* Handle other states */ } | |
| } | |
| when { | |
| state.isAtLeast(Lifecycle.State.STARTED) -> { /* Device is ACTIVE (worn) */ } | |
| state == Lifecycle.State.CREATED -> { /* Device is INACTIVE (not worn) */ } | |
| else -> { /* Handle other states */ } | |
| } |
There was a problem hiding this comment.
RESUMED isn't in the list of supported states for XR device.
|
Here is the summary of changes. You are about to add 1 region tag.
This comment is generated by snippet-bot.
|
Add in XR device lifecycle to track transitions between active and inactive device states using the standard Android Lifecycle.State values. This makes it seamless to determine exactly when to start projecting and when to expect user input.