File tree Expand file tree Collapse file tree 3 files changed +48
-1
lines changed
java/com/whyranoid/mogakrun
presentation/src/main/java/com/whyranoid/presentation/running Expand file tree Collapse file tree 3 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 13
13
android : theme =" @style/Theme.MoGakRun"
14
14
android : name =" .MogakrunApplication"
15
15
tools : targetApi =" 31" >
16
+ <provider
17
+ android : name =" androidx.startup.InitializationProvider"
18
+ android : authorities =" ${applicationId}.androidx-startup"
19
+ tools : node =" remove" >
20
+ </provider >
16
21
<activity
17
22
android : name =" com.whyranoid.signin.SignInActivity"
18
23
android : theme =" @style/Theme.MoGakRun.Splash"
Original file line number Diff line number Diff line change 1
1
package com.whyranoid.mogakrun
2
2
3
3
import android.app.Application
4
+ import androidx.hilt.work.HiltWorkerFactory
5
+ import androidx.work.Configuration
4
6
import com.whyranoid.mogakrun.util.TimberDebugTree
5
7
import dagger.hilt.android.HiltAndroidApp
6
8
import timber.log.Timber
9
+ import javax.inject.Inject
7
10
8
11
@HiltAndroidApp
9
- class MogakrunApplication : Application () {
12
+ class MogakrunApplication : Application (), Configuration.Provider {
13
+
14
+ @Inject
15
+ lateinit var workerFactory: HiltWorkerFactory
16
+
10
17
override fun onCreate () {
11
18
super .onCreate()
12
19
13
20
if (BuildConfig .DEBUG ) {
14
21
Timber .plant(TimberDebugTree ())
15
22
}
16
23
}
24
+
25
+ override fun getWorkManagerConfiguration () =
26
+ Configuration .Builder ()
27
+ .setWorkerFactory(workerFactory)
28
+ .setMinimumLoggingLevel(android.util.Log .DEBUG )
29
+ .build()
17
30
}
Original file line number Diff line number Diff line change
1
+ package com.whyranoid.presentation.running
2
+
3
+ import android.content.Context
4
+ import androidx.startup.Initializer
5
+ import androidx.work.Configuration
6
+ import androidx.work.WorkManager
7
+ import dagger.Module
8
+ import dagger.Provides
9
+ import dagger.hilt.InstallIn
10
+ import dagger.hilt.android.qualifiers.ApplicationContext
11
+ import dagger.hilt.components.SingletonComponent
12
+ import javax.inject.Singleton
13
+
14
+ @Module
15
+ @InstallIn(SingletonComponent ::class )
16
+ class WorkManagerInitializer : Initializer <WorkManager > {
17
+
18
+ @Provides
19
+ @Singleton
20
+ override fun create (@ApplicationContext context : Context ): WorkManager {
21
+ val configuration = Configuration .Builder ().build()
22
+ WorkManager .initialize(context, configuration)
23
+ return WorkManager .getInstance(context)
24
+ }
25
+
26
+ override fun dependencies (): MutableList <Class <out Initializer <* >>> {
27
+ return mutableListOf ()
28
+ }
29
+ }
You can’t perform that action at this time.
0 commit comments