Add plugin settings screen
This commit is contained in:
@@ -4,12 +4,18 @@ import de.mm20.launcher2.database.daos.PluginDao
|
||||
import de.mm20.launcher2.plugin.Plugin
|
||||
import de.mm20.launcher2.plugin.PluginRepository
|
||||
import de.mm20.launcher2.plugin.PluginType
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
internal class PluginRepositoryImpl(
|
||||
private val dao: PluginDao,
|
||||
): PluginRepository {
|
||||
) : PluginRepository {
|
||||
|
||||
private val scope = CoroutineScope(Job() + Dispatchers.IO)
|
||||
override fun findMany(
|
||||
type: PluginType?,
|
||||
enabled: Boolean?,
|
||||
@@ -28,19 +34,27 @@ internal class PluginRepositoryImpl(
|
||||
return dao.get(authority).map { Plugin(it) }
|
||||
}
|
||||
|
||||
override fun insertMany(plugins: List<Plugin>) {
|
||||
TODO("Not yet implemented")
|
||||
override fun insertMany(plugins: List<Plugin>): Job {
|
||||
return scope.launch {
|
||||
dao.insertMany(plugins.map { PluginEntity(it) })
|
||||
}
|
||||
}
|
||||
|
||||
override fun insert(plugin: Plugin) {
|
||||
dao.insert(PluginEntity(plugin))
|
||||
override fun insert(plugin: Plugin): Job {
|
||||
return scope.launch {
|
||||
dao.insert(PluginEntity(plugin))
|
||||
}
|
||||
}
|
||||
|
||||
override fun update(plugin: Plugin) {
|
||||
dao.update(PluginEntity(plugin))
|
||||
override fun update(plugin: Plugin): Job {
|
||||
return scope.launch {
|
||||
dao.update(PluginEntity(plugin))
|
||||
}
|
||||
}
|
||||
|
||||
override fun deleteMany() {
|
||||
dao.deleteMany()
|
||||
override fun deleteMany(): Job {
|
||||
return scope.launch {
|
||||
dao.deleteMany()
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user