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
import java.io.File | |
val path = "path/to/project/directory" // TODO: change here | |
println("Processing in folder: $path") | |
println() | |
fun writeDependenciesFromVersionCatalog(path: String) { | |
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
sealed interface Item { | |
val weight: Int | |
val stringRepresentation: String | |
} | |
class Box(override val weight: Int) : Item { | |
override val stringRepresentation: String = "Box" | |
} |
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
android { | |
defaultConfig { | |
// Todo(hilt): Remove this when migrated to hilt completely | |
javaCompileOptions.annotationProcessorOptions { | |
arguments['dagger.hilt.disableModulesHaveInstallInCheck'] = 'true' | |
} | |
} | |
} |
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
@HiltAndroidApp | |
class MyApplication : Application(), Configuration.Provider { | |
@Inject | |
lateinit var hiltWorkerFactory: HiltWorkerFactory | |
private val workerProviders = | |
HashMap<Class<out ListenableWorker>, Provider<AssistedWorkerFactory>>() |
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
@HiltAndroidApp | |
class MyApplication : Application(), Configuration.Provider { | |
@Inject | |
lateinit var hiltWorkerFactory: HiltWorkerFactory | |
override fun getWorkManagerConfiguration(): Configuration { | |
return Configuration.Builder() | |
.setWorkerFactory(hiltWorkerFactory) |
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
/** | |
* This class aggregates hilt and dagger worker providers. | |
* TODO: This class can get removed when fully migrated to hilt | |
*/ | |
class AggregatorWorkerFactory( | |
private val hiltWorkerFactory: HiltWorkerFactory, | |
private val daggerWorkerFactory: DaggerWorkerFactory | |
) : WorkerFactory() { | |
override fun createWorker( |
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
class DaggerWorkerFactory(private val workerFactories: WorkerProviders) : WorkerFactory() { | |
override fun createWorker( | |
context: Context, | |
workerClassName: String, | |
workerParameters: WorkerParameters | |
): ListenableWorker? { | |
return try { | |
val factoryEntry = workerFactories.entries | |
.find { Class.forName(workerClassName).isAssignableFrom(it.key) } |
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
plugins { | |
// ... | |
id 'dagger.hilt.android.plugin' | |
} |
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
implementation "androidx.hilt:hilt-work:$hilt-work-latest-version" | |
kapt "androidx.hilt:hilt-compiler:$hilt-work-latest-version" |
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
@HiltAndroidApp | |
class MyApplication : Application() { | |
// ... | |
} |
NewerOlder