|
|
@@ -3,7 +3,9 @@ package io.legado.app.ui.association
|
|
|
import android.app.Application
|
|
|
import android.os.Bundle
|
|
|
import io.legado.app.base.BaseViewModel
|
|
|
+import io.legado.app.constant.SourceType
|
|
|
import io.legado.app.data.appDb
|
|
|
+import io.legado.app.help.source.SourceHelp
|
|
|
|
|
|
class OpenUrlConfirmViewModel(app: Application): BaseViewModel(app) {
|
|
|
|
|
|
@@ -11,17 +13,19 @@ class OpenUrlConfirmViewModel(app: Application): BaseViewModel(app) {
|
|
|
var mimeType: String? = null
|
|
|
var sourceOrigin = ""
|
|
|
var sourceName = ""
|
|
|
+ var sourceType = SourceType.book
|
|
|
|
|
|
fun initData(arguments: Bundle) {
|
|
|
uri = arguments.getString("uri") ?: ""
|
|
|
mimeType = arguments.getString("mimeType")
|
|
|
sourceName = arguments.getString("sourceName") ?: ""
|
|
|
sourceOrigin = arguments.getString("sourceOrigin") ?: ""
|
|
|
+ sourceType = arguments.getInt("sourceType", SourceType.book)
|
|
|
}
|
|
|
|
|
|
fun disableSource(block: () -> Unit) {
|
|
|
execute {
|
|
|
- appDb.bookSourceDao.enable(sourceOrigin, false)
|
|
|
+ SourceHelp.enableSource(sourceOrigin, sourceType, false)
|
|
|
}.onSuccess {
|
|
|
block.invoke()
|
|
|
}
|
|
|
@@ -29,7 +33,7 @@ class OpenUrlConfirmViewModel(app: Application): BaseViewModel(app) {
|
|
|
|
|
|
fun deleteSource(block: () -> Unit) {
|
|
|
execute {
|
|
|
- appDb.bookSourceDao.delete(sourceOrigin)
|
|
|
+ SourceHelp.deleteSource(sourceOrigin, sourceType)
|
|
|
}.onSuccess {
|
|
|
block.invoke()
|
|
|
}
|