Skip to content

Comments

Moving APIs in PreviewViewModel to Callbacks data classes#482

Open
davidjiagoogle wants to merge 1 commit intomainfrom
david/previewViewModelCallbacks
Open

Moving APIs in PreviewViewModel to Callbacks data classes#482
davidjiagoogle wants to merge 1 commit intomainfrom
david/previewViewModelCallbacks

Conversation

@davidjiagoogle
Copy link
Collaborator

QuickSettingsCallbacks, CaptureCallbacks, SnackBarCallbacks, and DebugCallbacks are created. They contain callbacks that handle UI events as well as helper methods so that the view model can be simplified. To implement a view model similar to PreviewViewModel, an app only needs invoke the getter methods for these callback and supply the appropriate arguments instead of writing logics from scratch.

PreviewViewModel now only contains the APIs for start/stop camera and image/video capture.

@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@temcguir
Copy link
Collaborator

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request successfully refactors the PreviewViewModel by extracting various UI event handling logic into dedicated callback data classes: QuickSettingsCallbacks, CaptureCallbacks, SnackBarCallbacks, and DebugCallbacks. This significantly simplifies the PreviewViewModel and improves modularity, making the code easier to understand and maintain. The changes are well-implemented, and the new callback structures enhance code organization and reusability. The test file PreviewViewModelTest.kt has also been updated to reflect these changes, ensuring continued test coverage.

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