-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Add custom work manager initialization
- Loading branch information
1 parent
1f23de0
commit f381646
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 20 additions & 2 deletions
22
app/src/main/java/com/example/mymusic/MyMusicApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,33 @@ | ||
package com.example.mymusic | ||
|
||
import android.app.Application | ||
import androidx.hilt.work.HiltWorkerFactory | ||
import androidx.work.Configuration | ||
import com.example.mymusic.sync.Sync | ||
import dagger.hilt.EntryPoint | ||
import dagger.hilt.EntryPoints | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.HiltAndroidApp | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@HiltAndroidApp | ||
class MyMusicApplication : Application() { | ||
class MyMusicApplication : Application(), Configuration.Provider { | ||
|
||
@EntryPoint | ||
@InstallIn(SingletonComponent::class) | ||
interface HiltWorkerFactoryEntryPoint { | ||
fun workerFactory(): HiltWorkerFactory | ||
} | ||
|
||
override val workManagerConfiguration: Configuration = | ||
Configuration.Builder() | ||
.setWorkerFactory(EntryPoints.get(this, HiltWorkerFactoryEntryPoint::class.java).workerFactory()) | ||
.setMinimumLoggingLevel(android.util.Log.INFO) | ||
.build() | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
// Initialize Sync; the system responsible for keeping data in the app up to date. | ||
com.example.mymusic.sync.Sync.initialize(context = this) | ||
Sync.initialize(context = this) | ||
} | ||
} |