diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt index 4f8c4351c..f77c31e02 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexDialog.kt @@ -24,6 +24,7 @@ import io.legado.app.lib.dialogs.alert import io.legado.app.lib.theme.backgroundColor import io.legado.app.lib.theme.primaryColor import io.legado.app.model.ReadBook +import io.legado.app.ui.association.ImportTxtTocRuleDialog import io.legado.app.ui.widget.recycler.ItemTouchCallback import io.legado.app.ui.widget.recycler.VerticalDivider import io.legado.app.utils.* @@ -153,9 +154,7 @@ class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex), cacheUrls.add(0, it) aCache.put(importTocRuleKey, cacheUrls.joinToString(",")) } - viewModel.importOnLine(it) { msg -> - toastOnUi(msg) - } + showDialogFragment(ImportTxtTocRuleDialog(it)) } } cancelButton() diff --git a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt index 7846d4426..aabb38983 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/config/TocRegexViewModel.kt @@ -5,11 +5,6 @@ import io.legado.app.base.BaseViewModel import io.legado.app.data.appDb import io.legado.app.data.entities.TxtTocRule import io.legado.app.help.DefaultData -import io.legado.app.help.http.newCallResponseBody -import io.legado.app.help.http.okHttpClient -import io.legado.app.help.http.text -import io.legado.app.utils.GSON -import io.legado.app.utils.fromJsonArray class TocRegexViewModel(application: Application) : BaseViewModel(application) { @@ -28,20 +23,4 @@ class TocRegexViewModel(application: Application) : BaseViewModel(application) { } } - fun importOnLine(url: String, finally: (msg: String) -> Unit) { - execute { - okHttpClient.newCallResponseBody { - url(url) - }.text("utf-8").let { json -> - GSON.fromJsonArray(json).getOrThrow()?.let { - appDb.txtTocRuleDao.insert(*it.toTypedArray()) - } - } - }.onSuccess { - finally("导入成功") - }.onError { - finally("导入失败\n${it.localizedMessage}") - } - } - } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index 2b417240c..17cee29dd 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -183,7 +183,7 @@ abstract class PageDelegate(protected val readView: ReadView) { } open fun onDestroy() { - + // run on destroy } }