You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Removed direct static usages of database from app
This commit is contained in:
@@ -14,8 +14,8 @@ class SettingsDao : BaseDao() {
|
||||
values(key to value.toString())
|
||||
}.ignoreElement()
|
||||
|
||||
fun fetch(key: String) = query<Select> {
|
||||
fun fetch(key: String, default: Int = -1) = query<Select> {
|
||||
condition { equals("key", key) }
|
||||
}.map { it.first().values.first().toIntOrNull() ?: -1 }
|
||||
}.map { it.firstOrNull()?.values?.firstOrNull()?.toIntOrNull() ?: default }
|
||||
|
||||
}
|
||||
@@ -31,6 +31,8 @@ class LogRepository(
|
||||
.toSingle()
|
||||
.map { it.exec() }
|
||||
|
||||
fun put(log: MagiskLog) = logDao.put(log)
|
||||
|
||||
private fun List<MagiskLog>.wrap(): List<WrappedMagiskLog> {
|
||||
val day = TimeUnit.DAYS.toMillis(1)
|
||||
return groupBy { it.date.time / day }
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.topjohnwu.magisk.data.database.SettingsDao
|
||||
|
||||
class SettingRepository(private val settingsDao: SettingsDao) {
|
||||
|
||||
fun fetch(key: String) = settingsDao.fetch(key)
|
||||
fun fetch(key: String, default: Int) = settingsDao.fetch(key, default)
|
||||
fun put(key: String, value: Int) = settingsDao.put(key, value)
|
||||
fun delete(key: String) = settingsDao.delete(key)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.topjohnwu.magisk.data.database.StringDao
|
||||
|
||||
class StringRepository(private val stringDao: StringDao) {
|
||||
|
||||
fun fetch(key: String) = stringDao.fetch(key)
|
||||
fun fetch(key: String, default: String) = stringDao.fetch(key, default)
|
||||
fun put(key: String, value: String) = stringDao.put(key, value)
|
||||
fun delete(key: String) = stringDao.delete(key)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user