pull/1319/head
gedoor 3 years ago
parent e24f62186a
commit 38d278f46c
  1. 2
      app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
  2. 24
      app/src/main/java/io/legado/app/ui/association/ImportReplaceRuleDialog.kt
  3. 13
      app/src/main/java/io/legado/app/ui/association/OnLineImportActivity.kt
  4. 12
      app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt
  5. 6
      app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt

@ -35,7 +35,7 @@ class FileAssociationActivity :
}
viewModel.importReplaceRuleLive.observe(this) {
binding.rotateLoading.hide()
ImportReplaceRuleDialog.start(supportFragmentManager, it, true)
supportFragmentManager.showDialog(ImportReplaceRuleDialog(it, true))
}
viewModel.errorLiveData.observe(this, {
binding.rotateLoading.hide()

@ -9,7 +9,6 @@ import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R
@ -26,24 +25,19 @@ import io.legado.app.databinding.ItemSourceImportBinding
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.dialog.WaitDialog
import io.legado.app.utils.*
import io.legado.app.utils.dp
import io.legado.app.utils.putPrefBoolean
import io.legado.app.utils.splitNotBlank
import io.legado.app.utils.viewbindingdelegate.viewBinding
import io.legado.app.utils.visible
class ImportReplaceRuleDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
class ImportReplaceRuleDialog() : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
companion object {
fun start(
fragmentManager: FragmentManager,
source: String,
finishOnDismiss: Boolean = false
) {
fragmentManager.showDialog<ImportReplaceRuleDialog> {
putString("source", source)
putBoolean("finishOnDismiss", finishOnDismiss)
}
constructor(source: String, finishOnDismiss: Boolean = false) : this() {
arguments = Bundle().apply {
putString("source", source)
putBoolean("finishOnDismiss", finishOnDismiss)
}
}
private val binding by viewBinding(DialogRecyclerViewBinding::bind)

@ -28,8 +28,9 @@ class OnLineImportActivity :
)
"rssSource" -> ImportRssSourceDialog
.start(supportFragmentManager, it.second, true)
"replaceRule" -> ImportReplaceRuleDialog
.start(supportFragmentManager, it.second, true)
"replaceRule" -> supportFragmentManager.showDialog(
ImportReplaceRuleDialog(it.second, true)
)
}
}
viewModel.errorLive.observe(this) {
@ -46,7 +47,9 @@ class OnLineImportActivity :
ImportBookSourceDialog(url, true)
)
"/rssSource" -> ImportRssSourceDialog.start(supportFragmentManager, url, true)
"/replaceRule" -> ImportReplaceRuleDialog.start(supportFragmentManager, url, true)
"/replaceRule" -> supportFragmentManager.showDialog(
ImportReplaceRuleDialog(url, true)
)
"/textTocRule" -> viewModel.getText(url) { json ->
viewModel.importTextTocRule(json, this::finallyDialog)
}
@ -64,7 +67,9 @@ class OnLineImportActivity :
ImportBookSourceDialog(url, true)
)
"rsssource" -> ImportRssSourceDialog.start(supportFragmentManager, url, true)
"replace" -> ImportReplaceRuleDialog.start(supportFragmentManager, url, true)
"replace" -> supportFragmentManager.showDialog(
ImportReplaceRuleDialog(url, true)
)
else -> {
toastOnUi("url error")
finish()

@ -61,7 +61,9 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
private var dataInit = false
private val qrCodeResult = registerForActivityResult(QrCodeResult()) {
it ?: return@registerForActivityResult
ImportReplaceRuleDialog.start(supportFragmentManager, it)
supportFragmentManager.showDialog(
ImportReplaceRuleDialog(it)
)
}
private val editActivity =
registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
@ -72,7 +74,9 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
private val importDoc = registerForActivityResult(HandleFileContract()) { uri ->
kotlin.runCatching {
uri?.readText(this)?.let {
ImportReplaceRuleDialog.start(supportFragmentManager, it)
supportFragmentManager.showDialog(
ImportReplaceRuleDialog(it)
)
}
}.onFailure {
toastOnUi("readTextError:${it.localizedMessage}")
@ -279,7 +283,9 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
cacheUrls.add(0, it)
aCache.put(importRecordKey, cacheUrls.joinToString(","))
}
ImportReplaceRuleDialog.start(supportFragmentManager, it)
supportFragmentManager.showDialog(
ImportReplaceRuleDialog(it)
)
}
}
cancelButton()

@ -75,9 +75,9 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(),
1 -> {
ImportRssSourceDialog.start(supportFragmentManager, ruleSub.url)
}
2 -> {
ImportReplaceRuleDialog.start(supportFragmentManager, ruleSub.url)
}
2 -> supportFragmentManager.showDialog(
ImportReplaceRuleDialog(ruleSub.url)
)
}
}

Loading…
Cancel
Save