pull/1171/head
gedoor 3 years ago
parent 6d3df46a20
commit 20fa2bfc19
  1. 6
      app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
  2. 15
      app/src/main/java/io/legado/app/ui/association/ImportBookSourceDialog.kt
  3. 15
      app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleDialog.kt
  4. 15
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
  5. 12
      app/src/main/java/io/legado/app/ui/association/OnLineImportActivity.kt

@ -21,15 +21,15 @@ class FileAssociationActivity :
binding.rotateLoading.show()
viewModel.importBookSourceLive.observe(this) {
binding.rotateLoading.hide()
ImportBookSourceDialog.start(supportFragmentManager, it)
ImportBookSourceDialog.start(supportFragmentManager, it, true)
}
viewModel.importRssSourceLive.observe(this) {
binding.rotateLoading.hide()
ImportRssSourceDialog.start(supportFragmentManager, it)
ImportRssSourceDialog.start(supportFragmentManager, it, true)
}
viewModel.importReplaceRuleLive.observe(this) {
binding.rotateLoading.hide()
ImportReplaceRuleDialog.start(supportFragmentManager, it)
ImportReplaceRuleDialog.start(supportFragmentManager, it, true)
}
viewModel.errorLiveData.observe(this, {
binding.rotateLoading.hide()

@ -2,6 +2,7 @@ package io.legado.app.ui.association
import android.annotation.SuppressLint
import android.content.Context
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MenuItem
@ -37,10 +38,15 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
companion object {
fun start(fragmentManager: FragmentManager, source: String) {
fun start(
fragmentManager: FragmentManager,
source: String,
finishOnDismiss: Boolean = false
) {
ImportBookSourceDialog().apply {
arguments = Bundle().apply {
putString("source", source)
putBoolean("finishOnDismiss", finishOnDismiss)
}
}.show(fragmentManager, "importBookSource")
}
@ -67,6 +73,13 @@ class ImportBookSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickList
return inflater.inflate(R.layout.dialog_recycler_view, container)
}
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
if (arguments?.getBoolean("finishOnDismiss") == true) {
activity?.finish()
}
}
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
binding.toolBar.setTitle(R.string.import_book_source)
binding.rotateLoading.show()

@ -1,6 +1,7 @@
package io.legado.app.ui.association
import android.content.Context
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
@ -24,10 +25,15 @@ import io.legado.app.utils.visible
class ImportReplaceRuleDialog : BaseDialogFragment() {
companion object {
fun start(fragmentManager: FragmentManager, source: String) {
fun start(
fragmentManager: FragmentManager,
source: String,
finishOnDismiss: Boolean = false
) {
ImportReplaceRuleDialog().apply {
arguments = Bundle().apply {
putString("source", source)
putBoolean("finishOnDismiss", finishOnDismiss)
}
}.show(fragmentManager, "importReplaceRule")
}
@ -45,6 +51,13 @@ class ImportReplaceRuleDialog : BaseDialogFragment() {
)
}
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
if (arguments?.getBoolean("finishOnDismiss") == true) {
activity?.finish()
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,

@ -2,6 +2,7 @@ package io.legado.app.ui.association
import android.annotation.SuppressLint
import android.content.Context
import android.content.DialogInterface
import android.os.Bundle
import android.view.LayoutInflater
import android.view.MenuItem
@ -35,10 +36,15 @@ import io.legado.app.utils.viewbindingdelegate.viewBinding
class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
companion object {
fun start(fragmentManager: FragmentManager, source: String) {
fun start(
fragmentManager: FragmentManager,
source: String,
finishOnDismiss: Boolean = false
) {
ImportRssSourceDialog().apply {
arguments = Bundle().apply {
putString("source", source)
putBoolean("finishOnDismiss", finishOnDismiss)
}
}.show(fragmentManager, "importRssSource")
}
@ -56,6 +62,13 @@ class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListe
)
}
override fun onDismiss(dialog: DialogInterface) {
super.onDismiss(dialog)
if (arguments?.getBoolean("finishOnDismiss") == true) {
activity?.finish()
}
}
override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,

@ -27,17 +27,17 @@ class OnLineImportActivity :
return
}
when (it.path) {
"/bookSource" -> ImportBookSourceDialog.start(supportFragmentManager, url)
"/rssSource" -> ImportRssSourceDialog.start(supportFragmentManager, url)
"/replaceRule" -> ImportReplaceRuleDialog.start(supportFragmentManager, url)
"/bookSource" -> ImportBookSourceDialog.start(supportFragmentManager, url, true)
"/rssSource" -> ImportRssSourceDialog.start(supportFragmentManager, url, true)
"/replaceRule" -> ImportReplaceRuleDialog.start(supportFragmentManager, url, true)
"/textTocRule" -> viewModel.importTextTocRule(url, this::finallyDialog)
"/httpTTS" -> viewModel.importHttpTTS(url, this::finallyDialog)
"/theme" -> viewModel.importTheme(url, this::finallyDialog)
"/readConfig" -> viewModel.importReadConfig(url, this::finallyDialog)
"/importonline" -> when (it.host) {
"booksource" -> ImportBookSourceDialog.start(supportFragmentManager, url)
"rsssource" -> ImportRssSourceDialog.start(supportFragmentManager, url)
"replace" -> ImportReplaceRuleDialog.start(supportFragmentManager, url)
"booksource" -> ImportBookSourceDialog.start(supportFragmentManager, url, true)
"rsssource" -> ImportRssSourceDialog.start(supportFragmentManager, url, true)
"replace" -> ImportReplaceRuleDialog.start(supportFragmentManager, url, true)
else -> {
toastOnUi("url error")
finish()

Loading…
Cancel
Save