Skip to content
Snippets Groups Projects
Unverified Commit 489dc64a authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

wip: add hilt

parent 7856f87c
No related branches found
No related tags found
No related merge requests found
......@@ -25,16 +25,6 @@ plugins {
}
dependencies {
implementation(libs.kotlin.stdlib)
implementation(libs.kotlinx.coroutines.core)
testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.kotlin.test)
testImplementation(libs.junit.api)
testImplementation(libs.junit.params)
testRuntimeOnly(libs.junit.engine)
implementation(libs.kotlinx.datetime)
implementation(libs.okhttp)
......
......@@ -21,6 +21,9 @@
plugins {
id("justjanne.android.app")
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotlin.ksp)
alias(libs.plugins.dagger.hilt)
}
android {
......@@ -85,6 +88,10 @@ dependencies {
implementation(libs.okhttp)
implementation(libs.kotlinx.serialization.json)
implementation(libs.coil.compose)
implementation(libs.hilt.android)
ksp(libs.hilt.compiler)
implementation(project(":api"))
implementation(project(":persistence"))
......
......@@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<application
android:name=".MeteroidApplication"
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/application_name"
......
/*
* The MIT License (MIT)
*
* Copyright (c) 2013-2023 Chaosdorf e.V.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package de.chaosdorf.meteroid
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import de.chaosdorf.meteroid.di.RootViewModel
import de.chaosdorf.meteroid.routes.RootRouter
@Composable
fun App(viewModel: RootViewModel) {
val route by viewModel.route.collectAsState()
RootRouter(route)
}
......@@ -27,16 +27,14 @@ package de.chaosdorf.meteroid
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import dagger.hilt.android.AndroidEntryPoint
import de.chaosdorf.meteroid.di.RootViewModel
import de.chaosdorf.meteroid.di.RootViewModelFactory
import de.chaosdorf.meteroid.routes.RootRouter
import de.chaosdorf.meteroid.ui.theme.MeteroidTheme
import kotlinx.coroutines.MainScope
@AndroidEntryPoint
class MainActivity : ComponentActivity() {
private val rootViewModelFactory = object : RootViewModelFactory {}
private lateinit var rootViewModel: RootViewModel
......@@ -54,10 +52,3 @@ class MainActivity : ComponentActivity() {
}
}
}
@Composable
fun App(viewModel: RootViewModel) {
val route by viewModel.route.collectAsState()
RootRouter(route)
}
/*
* The MIT License (MIT)
*
* Copyright (c) 2013-2023 Chaosdorf e.V.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package de.chaosdorf.meteroid
import android.app.Application
import dagger.hilt.android.HiltAndroidApp
@HiltAndroidApp
class MeteroidApplication : Application()
......@@ -11,4 +11,6 @@ plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.jvm) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.kotlin.ksp) apply false
alias(libs.plugins.dagger.hilt) apply false
}
......@@ -11,6 +11,7 @@ androidx-compose-tooling = "1.6.0-alpha08"
androidx-navigation = "2.7.4"
androidx-room = "2.6.0"
coil = "2.4.0"
dagger-hilt = "2.48.1"
kotlin = "1.9.10"
kotlin-ksp = "1.9.10-1.0.13"
kotlinxCoroutines = "1.7.1"
......@@ -49,6 +50,8 @@ androidx-room-paging = { module = "androidx.room:room-paging", version.ref = "an
coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
hilt-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "dagger-hilt" }
hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "dagger-hilt" }
okhttp = { module = "com.squareup.okhttp3:okhttp", version = "4.12.0" }
retrofit-core = { module = "com.squareup.retrofit2:retrofit", version = "2.9.0" }
retrofit-converter-kotlinx = { module = "com.jakewharton.retrofit:retrofit2-kotlinx-serialization-converter", version = "1.0.0" }
......@@ -75,6 +78,7 @@ kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-pl
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
android-test = { id = "com.android.test", version.ref = "androidGradlePlugin" }
dagger-hilt = { id = "com.google.dagger.hilt.android", version.ref = "dagger-hilt" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kotlin-ksp = { id = "com.google.devtools.ksp", version.ref = "kotlin.ksp" }
......@@ -23,6 +23,7 @@ plugins {
id("justjanne.android.library")
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.kotlin.ksp)
alias(libs.plugins.dagger.hilt)
}
android {
......@@ -50,6 +51,9 @@ dependencies {
implementation(libs.androidx.room.ktx)
implementation(libs.androidx.room.paging)
implementation(libs.hilt.android)
ksp(libs.hilt.compiler)
implementation(libs.kotlinx.datetime)
implementation(libs.kotlinx.serialization.json)
implementation(project(":api"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment