-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/my shiny feature n 7 #8
base: main
Are you sure you want to change the base?
Conversation
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.
🐜 Code Review from PRagmatic
📝 Overall Feedback
The changes made to the codebase include modifications to the main activity and its view model, as well as updates to user data handling. These changes appear to be intended to improve the functionality and possibly performance of the application.
This review was automatically generated by 🐜 PRagmatic! While I strive for accuracy, please review all suggestions carefully.
app/src/main/kotlin/com/google/samples/apps/nowinandroid/MainActivityViewModel.kt
Show resolved
Hide resolved
...src/main/kotlin/com/google/samples/apps/nowinandroid/core/domain/GetSearchContentsUseCase.kt
Show resolved
Hide resolved
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.
🐜 Code Review from PRagmatic
📝 Overall Feedback
The overall changes introduce a few new features and modifications. The dispatcher of activities, logging through logs, and changing the coroutine context are all positive additions. However, there are some areas where improvements can be made to ensure better code practices and maintainability.
_ This review was automatically generated by 🐜 PRagmatic! While I strive for accuracy, please review all suggestions carefully._
@@ -92,6 +92,8 @@ class MainActivity : ComponentActivity() { | |||
} | |||
} | |||
|
|||
viewModel.saveActivity(this) | |||
|
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.
Changing the dispatcher from IO to Default might not be ideal for UI-related work. It's generally recommended to use IO for background tasks that involve disk or network operations.
@@ -16,6 +16,7 @@ | |||
|
|||
package com.google.samples.apps.nowinandroid | |||
|
|||
import android.content.Context | |||
import androidx.lifecycle.ViewModel |
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.
Adding logging is a good practice, but it would be beneficial to have more context about the logs, such as timestamps and log levels (INFO, DEBUG, ERROR). Additionally, consider using a logging library that provides more flexibility.
val uiState: StateFlow<MainActivityUiState> = userDataRepository.userData.map { | ||
Success(it) | ||
}.stateIn( | ||
scope = viewModelScope, | ||
initialValue = Loading, | ||
started = SharingStarted.WhileSubscribed(5_000), | ||
) | ||
|
||
fun saveActivity(context: Context) { | ||
_context = context |
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 usage of lateinit for _context can lead to potential null pointer exceptions if the context is not set before use. It's safer to either pass the context through constructor injection or handle it in a more controlled manner.
LaunchedEffect(Unit) { | ||
Log.e("#####","info message - App UI") | ||
} | ||
|
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 saveActivity method simply assigns the context to a private variable without performing any action. It's unclear what the intended functionality is. Consider adding comments or documentation explaining why this method exists and how it should be used.
DO NOT CREATE A PULL REQUEST WITHOUT READING THESE INSTRUCTIONS
Instructions
Thanks for submitting a pull request. To accept your pull request we need you do a few things:
If this is your first pull request
Ensure tests pass and code is formatted correctly
DemoDebug
variant by running./gradlew testDemoDebug
./gradlew --init-script gradle/init.gradle.kts spotlessApply
Add a description
We need to know what you've done and why you've done it. Include a summary of what your pull request contains, and why you have made these changes. Include links to any relevant issues which it fixes.
Here's an example.
NOW DELETE THIS LINE AND EVERYTHING ABOVE IT
What I have done and why
<add your PR description here>