From 28e348c1948b115c035c37f6f83afd2ff5a21c6a Mon Sep 17 00:00:00 2001 From: Mathieu Sanchez Date: Sat, 18 Apr 2020 10:15:02 +0200 Subject: [PATCH] Good update --- app/build.gradle | 5 +++-- .../java/fr/sanchezm/attestationsCovid19/MainActivity.kt | 1 - .../sanchezm/attestationsCovid19/data/db/MyDatabase.kt | 9 +++++---- .../fr/sanchezm/attestationsCovid19/utilities/Event.kt | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 9da2caf..97379d7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,6 +39,7 @@ android { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } + kotlinOptions { jvmTarget = "1.8" } @@ -52,11 +53,11 @@ dependencies { implementation 'androidx.core:core-ktx:1.2.0' implementation 'com.google.android.material:material:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' + + implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1' implementation 'androidx.navigation:navigation-fragment:2.2.1' implementation 'androidx.navigation:navigation-ui:2.2.1' - implementation 'androidx.navigation:navigation-fragment-ktx:2.2.1' - implementation 'androidx.navigation:navigation-ui-ktx:2.2.1' // Room // implementation 'androidx.room:room-runtime:2.2.5' diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/MainActivity.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/MainActivity.kt index 51364ae..fd32af5 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/MainActivity.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/MainActivity.kt @@ -25,5 +25,4 @@ class MainActivity : AppCompatActivity() { navView.setBackgroundColor(resources.getColor(R.color.itemBackground, theme)) } - } \ No newline at end of file diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/MyDatabase.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/MyDatabase.kt index 7c3785f..a3cec7a 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/MyDatabase.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/data/db/MyDatabase.kt @@ -6,12 +6,13 @@ import fr.sanchezm.attestationsCovid19.data.db.dao.ProfileDao class MyDatabase private constructor(private val path: String) { - private val _profileDao: ProfileDao? = null - private val _attestationDao: AttestationDao? = null + private var _profileDao: ProfileDao? = null + private var _attestationDao: AttestationDao? = null - fun profileDao() : ProfileDao = _profileDao ?: ProfileDao(path) + fun profileDao(): ProfileDao = _profileDao ?: ProfileDao(path).also { _profileDao = it } - fun attestationDao() : AttestationDao = _attestationDao ?: AttestationDao(path) + fun attestationDao(): AttestationDao = + _attestationDao ?: AttestationDao(path).also { _attestationDao = it } companion object { @Volatile diff --git a/app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/Event.kt b/app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/Event.kt index 5a5fe43..1752b2a 100644 --- a/app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/Event.kt +++ b/app/src/main/java/fr/sanchezm/attestationsCovid19/utilities/Event.kt @@ -1,7 +1,7 @@ package fr.sanchezm.attestationsCovid19.utilities open class Event(private val content: T) { - var hasBeenHandled = false + private var hasBeenHandled = false private set fun getContentIfNotHandled(): T? {