diff --git a/src/main/kotlin/com/looker/droidify/content/ProductPreferences.kt b/src/main/kotlin/com/looker/droidify/content/ProductPreferences.kt index eb7b6dfa..c20df0b0 100644 --- a/src/main/kotlin/com/looker/droidify/content/ProductPreferences.kt +++ b/src/main/kotlin/com/looker/droidify/content/ProductPreferences.kt @@ -30,20 +30,13 @@ object ProductPreferences { db.lockDao.insert(*preferences.all.keys .mapNotNull { pName -> this@ProductPreferences[pName].databaseVersionCode?.let { - Lock().apply { - package_name = pName - version_code = it - } + Lock(pName, it) } } .toTypedArray() ) subject.collect { (packageName, versionCode) -> - if (versionCode != null) db.lockDao.insert(Lock().apply { - package_name = packageName - version_code = versionCode - } - ) + if (versionCode != null) db.lockDao.insert(Lock(packageName, versionCode)) else db.lockDao.delete(packageName) } } diff --git a/src/main/kotlin/com/looker/droidify/database/entity/Lock.kt b/src/main/kotlin/com/looker/droidify/database/entity/Lock.kt index 6ddaafb4..98cabd93 100644 --- a/src/main/kotlin/com/looker/droidify/database/entity/Lock.kt +++ b/src/main/kotlin/com/looker/droidify/database/entity/Lock.kt @@ -4,8 +4,8 @@ import androidx.room.Entity import androidx.room.PrimaryKey @Entity(tableName = "memory_lock") -class Lock { +data class Lock( @PrimaryKey - var package_name = "" - var version_code = 0L -} \ No newline at end of file + var package_name: String = "", + var version_code: Long = 0L +) \ No newline at end of file