Moving APIs in PreviewViewModel to Callbacks data classes#482
Moving APIs in PreviewViewModel to Callbacks data classes#482davidjiagoogle wants to merge 1 commit intomainfrom
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
/gemini review |
There was a problem hiding this comment.
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.
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.