File tree Expand file tree Collapse file tree 6 files changed +43
-82
lines changed
java/com/haroldadmin/whatthestack Expand file tree Collapse file tree 6 files changed +43
-82
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ buildscript {
2626 " espressoCore" : " 3.2.0" ,
2727 " mockk" : " 1.9.3" ,
2828 " robolectric" : " 4.3.1" ,
29+ " startup" : " 1.0.0-alpha01" ,
2930 ]
3031
3132 ext. libs = [
@@ -36,6 +37,7 @@ buildscript {
3637 " materialComponents" : " com.google.android.material:material:${ versions.materialComponents} " ,
3738 " constraintLayout" : " androidx.constraintlayout:constraintlayout:${ versions.constraintLayout} " ,
3839 " fragmentKtx" : " androidx.fragment:fragment-ktx:${ versions.fragment} " ,
40+ " startup" : " androidx.startup:startup-runtime:${ versions.startup} " ,
3941 " insetter" : " dev.chrisbanes:insetter-ktx:${ versions.insetter} " ,
4042
4143 " junit" : " junit:junit:${ versions.junit} " ,
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ dependencies {
4747 implementation libs. fragmentKtx
4848 implementation libs. constraintLayout
4949 implementation libs. materialComponents
50+ implementation libs. startup
5051 implementation libs. insetter
5152
5253 testImplementation libs. junit
Original file line number Diff line number Diff line change 11<manifest xmlns : android =" http://schemas.android.com/apk/res/android"
2+ xmlns : tools =" http://schemas.android.com/tools"
23 package =" com.haroldadmin.whatthestack" >
34 <application >
45 <provider
5- android : name =" .WhatTheStackInitProvider "
6- android : authorities =" ${applicationId}.WhatTheStackInitProvider "
6+ android : name =" androidx.startup.InitializationProvider "
7+ android : authorities =" ${applicationId}.androidx-startup "
78 android : exported =" false"
8- android : enabled =" true" />
9+ tools : node =" merge" >
10+ <meta-data android : name =" com.haroldadmin.whatthestack.WhatTheStackInitializer"
11+ android : value =" androidx.startup" />
12+ </provider >
13+
914 <service
1015 android : name =" .WhatTheStackService"
1116 android : process =" :what_the_stack_process" />
Original file line number Diff line number Diff line change @@ -21,11 +21,11 @@ class WhatTheStack(private val applicationContext: Context) {
2121
2222 @Suppress(" unused" )
2323 fun init () {
24- WhatTheStackInitializer .init (applicationContext)
24+ InitializationManager .init (applicationContext)
2525 }
2626}
2727
28- internal object WhatTheStackInitializer {
28+ internal object InitializationManager {
2929
3030 private var isInitialized: Boolean = false
3131
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ package com.haroldadmin.whatthestack
2+
3+ import android.content.Context
4+ import androidx.startup.Initializer
5+ import java.lang.Class
6+
7+ /* *
8+ * WhatTheStackInitializer is an [androidx.startup.Initializer] for WhatTheStack
9+ *
10+ * This particular initializer does not need to return anything, but it is required to return
11+ * a sensible value here so we return an instance of a dummy class [WhatTheStackInitializedToken]
12+ * instead.
13+ */
14+ class WhatTheStackInitializer : Initializer <WhatTheStackInitializedToken > {
15+
16+ override fun create (context : Context ): WhatTheStackInitializedToken {
17+ InitializationManager .init (context)
18+ return WhatTheStackInitializedToken ()
19+ }
20+
21+ override fun dependencies (): List <Class <out Initializer <* >>> {
22+ return emptyList()
23+ }
24+ }
25+
26+ /* *
27+ * A dummy class that does nothing but represent a type that can be returned by
28+ * [WhatTheStackInitializer]
29+ */
30+ class WhatTheStackInitializedToken
You can’t perform that action at this time.
0 commit comments