-
Notifications
You must be signed in to change notification settings - Fork 98
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
Network awareness #168
Network awareness #168
Conversation
Network Awareness module
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.
few comments that can be iterated over in subsequent prs
network-awareness/src/main/java/com/google/android/horologist/networks/data/NetworkType.kt
Show resolved
Hide resolved
...awareness/src/main/java/com/google/android/horologist/networks/data/DataRequestRepository.kt
Outdated
Show resolved
Hide resolved
network-awareness/src/main/java/com/google/android/horologist/networks/data/NetworkType.kt
Outdated
Show resolved
Hide resolved
sample/src/main/java/com/google/android/horologist/navsample/NavActivity.kt
Show resolved
Hide resolved
fun inject(mainActivity: MainActivity) { | ||
mainActivity.mediaPlayerScreenViewModelFactory = | ||
getMediaPlayerScreenViewModelFactory(getPlayerRepositoryImplFactory(getMediaDataSource())) | ||
} | ||
|
||
fun inject(navActivity: NavActivity) { | ||
navActivity.dataRequestRepository = getDataRequestRepository() | ||
navActivity.networkRepository = getNetworkRepository(navActivity, navActivity.lifecycleScope) |
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.
shouldn't the NetworkRepository use the ViewModel scope instead? so in case of activity recreation, any request in progress wouldn't be stopped/started again
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.
Yep - damn that's a nasty bug. Thanks for spotting.
NetworkRepository is likely application scoped in practice. A single OkHttp client shared by activities and services. But this sample is just working with the SampleAppDI. It's not a hilt/koin killer yet...
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.
Going to put this as a TODO/Comment. Without adding Application Scope to your sample DI system, not sure I can do much here. But you are right, it's a bug as it stands, not so critical for the sample. I'll change the CoroutineScope to an application instance however.
...k-awareness/src/main/java/com/google/android/horologist/networks/status/NetworkRepository.kt
Show resolved
Hide resolved
network-awareness/src/main/java/com/google/android/horologist/networks/data/NetworkType.kt
Outdated
Show resolved
Hide resolved
network-awareness/src/main/java/com/google/android/horologist/networks/data/NetworkType.kt
Outdated
Show resolved
Hide resolved
network-awareness/src/main/java/com/google/android/horologist/networks/ui/CurveDataUsage.kt
Outdated
Show resolved
Hide resolved
network-awareness/src/main/java/com/google/android/horologist/networks/ui/CurveDataUsage.kt
Outdated
Show resolved
Hide resolved
|
||
public open class DelegatingEventListener( | ||
private val delegate: EventListener | ||
) : EventListener() { |
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.
might be able to make this class simpler using delegation:
public open class DelegatingEventListener(
private val delegate: EventListener
) : EventListener() by delegate
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.
Damn, only works for interfaces.
# Conflicts: # settings.gradle
@wrkben will follow up with any comments and document the existing TODOs in the github issue, but would like to work in smaller PRs. |
WHAT
First import of network awareness module.
#128
WHY
Get a build in place and replace the in place code in the Media libraries.
Checklist 📋