Add profiles gestion
This commit is contained in:
parent
5f373a19d7
commit
54a57b65ab
@ -21,10 +21,18 @@ class ProfileDao(private val path: String, private val configRepository: ConfigR
|
|||||||
fun getProfiles(): LiveData<List<Profile>> =
|
fun getProfiles(): LiveData<List<Profile>> =
|
||||||
_profile as LiveData<List<Profile>>
|
_profile as LiveData<List<Profile>>
|
||||||
|
|
||||||
fun addProfile(profile: Profile) {
|
fun getProfile(id: Int): Profile? =
|
||||||
|
_profile.value?.get(id)
|
||||||
|
|
||||||
|
fun getProfileId(profile: Profile): Int? =
|
||||||
|
_profile.value?.indexOf(profile)
|
||||||
|
|
||||||
|
fun addProfile(profile: Profile): Int {
|
||||||
_profile.value?.add(profile)
|
_profile.value?.add(profile)
|
||||||
_profile.value = _profile.value
|
_profile.value = _profile.value
|
||||||
save()
|
save()
|
||||||
|
|
||||||
|
return _profile.value?.indexOf(profile)!!
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
@ -3,5 +3,6 @@ package fr.sanchezm.attestationsCovid19.data.db.entity
|
|||||||
data class Config(
|
data class Config(
|
||||||
var dbVersion: Int,
|
var dbVersion: Int,
|
||||||
var versionName: String,
|
var versionName: String,
|
||||||
var versionCode: Int
|
var versionCode: Int,
|
||||||
|
var selectProfileId: Int
|
||||||
)
|
)
|
@ -9,7 +9,10 @@ class ProfileRepository private constructor(private val profileDao: ProfileDao)
|
|||||||
fun getProfiles(): LiveData<List<Profile>> =
|
fun getProfiles(): LiveData<List<Profile>> =
|
||||||
profileDao.getProfiles()
|
profileDao.getProfiles()
|
||||||
|
|
||||||
fun insertProfile(profile: Profile) =
|
fun getProfile(id: Int): Profile? =
|
||||||
|
profileDao.getProfile(id)
|
||||||
|
|
||||||
|
fun insertProfile(profile: Profile): Int =
|
||||||
profileDao.addProfile(profile)
|
profileDao.addProfile(profile)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
Loading…
Reference in New Issue
Block a user