pull/1319/head
gedoor 3 years ago
parent 38d278f46c
commit 6eba220292
  1. 4
      app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt
  2. 20
      app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt
  3. 13
      app/src/main/java/io/legado/app/ui/association/OnLineImportActivity.kt
  4. 12
      app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt
  5. 10
      app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt

@ -31,7 +31,9 @@ class FileAssociationActivity :
} }
viewModel.importRssSourceLive.observe(this) { viewModel.importRssSourceLive.observe(this) {
binding.rotateLoading.hide() binding.rotateLoading.hide()
ImportRssSourceDialog.start(supportFragmentManager, it, true) supportFragmentManager.showDialog(
ImportRssSourceDialog(it, true)
)
} }
viewModel.importReplaceRuleLive.observe(this) { viewModel.importReplaceRuleLive.observe(this) {
binding.rotateLoading.hide() binding.rotateLoading.hide()

@ -9,7 +9,6 @@ import android.view.MenuItem
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.viewModels import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import io.legado.app.R import io.legado.app.R
@ -27,29 +26,24 @@ import io.legado.app.help.AppConfig
import io.legado.app.lib.dialogs.alert import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.widget.dialog.WaitDialog 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.viewbindingdelegate.viewBinding
import io.legado.app.utils.visible
/** /**
* 导入rss源弹出窗口 * 导入rss源弹出窗口
*/ */
class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { class ImportRssSourceDialog() : BaseDialogFragment(), Toolbar.OnMenuItemClickListener {
companion object { constructor(source: String, finishOnDismiss: Boolean = false) : this() {
arguments = Bundle().apply {
fun start(
fragmentManager: FragmentManager,
source: String,
finishOnDismiss: Boolean = false
) {
fragmentManager.showDialog<ImportRssSourceDialog> {
putString("source", source) putString("source", source)
putBoolean("finishOnDismiss", finishOnDismiss) putBoolean("finishOnDismiss", finishOnDismiss)
} }
} }
}
private val binding by viewBinding(DialogRecyclerViewBinding::bind) private val binding by viewBinding(DialogRecyclerViewBinding::bind)
private val viewModel by viewModels<ImportRssSourceViewModel>() private val viewModel by viewModels<ImportRssSourceViewModel>()
private val adapter by lazy { SourcesAdapter(requireContext()) } private val adapter by lazy { SourcesAdapter(requireContext()) }

@ -26,8 +26,9 @@ class OnLineImportActivity :
"bookSource" -> supportFragmentManager.showDialog( "bookSource" -> supportFragmentManager.showDialog(
ImportBookSourceDialog(it.second, true) ImportBookSourceDialog(it.second, true)
) )
"rssSource" -> ImportRssSourceDialog "rssSource" -> supportFragmentManager.showDialog(
.start(supportFragmentManager, it.second, true) ImportRssSourceDialog(it.second, true)
)
"replaceRule" -> supportFragmentManager.showDialog( "replaceRule" -> supportFragmentManager.showDialog(
ImportReplaceRuleDialog(it.second, true) ImportReplaceRuleDialog(it.second, true)
) )
@ -46,7 +47,9 @@ class OnLineImportActivity :
"/bookSource" -> supportFragmentManager.showDialog( "/bookSource" -> supportFragmentManager.showDialog(
ImportBookSourceDialog(url, true) ImportBookSourceDialog(url, true)
) )
"/rssSource" -> ImportRssSourceDialog.start(supportFragmentManager, url, true) "/rssSource" -> supportFragmentManager.showDialog(
ImportRssSourceDialog(url, true)
)
"/replaceRule" -> supportFragmentManager.showDialog( "/replaceRule" -> supportFragmentManager.showDialog(
ImportReplaceRuleDialog(url, true) ImportReplaceRuleDialog(url, true)
) )
@ -66,7 +69,9 @@ class OnLineImportActivity :
"booksource" -> supportFragmentManager.showDialog( "booksource" -> supportFragmentManager.showDialog(
ImportBookSourceDialog(url, true) ImportBookSourceDialog(url, true)
) )
"rsssource" -> ImportRssSourceDialog.start(supportFragmentManager, url, true) "rsssource" -> supportFragmentManager.showDialog(
ImportRssSourceDialog(url, true)
)
"replace" -> supportFragmentManager.showDialog( "replace" -> supportFragmentManager.showDialog(
ImportReplaceRuleDialog(url, true) ImportReplaceRuleDialog(url, true)
) )

@ -53,12 +53,16 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
private var groupMenu: SubMenu? = null private var groupMenu: SubMenu? = null
private val qrCodeResult = registerForActivityResult(QrCodeResult()) { private val qrCodeResult = registerForActivityResult(QrCodeResult()) {
it ?: return@registerForActivityResult it ?: return@registerForActivityResult
ImportRssSourceDialog.start(supportFragmentManager, it) supportFragmentManager.showDialog(
ImportRssSourceDialog(it)
)
} }
private val importDoc = registerForActivityResult(HandleFileContract()) { uri -> private val importDoc = registerForActivityResult(HandleFileContract()) { uri ->
kotlin.runCatching { kotlin.runCatching {
uri?.readText(this)?.let { uri?.readText(this)?.let {
ImportRssSourceDialog.start(supportFragmentManager, it) supportFragmentManager.showDialog(
ImportRssSourceDialog(it)
)
} }
}.onFailure { }.onFailure {
toastOnUi("readTextError:${it.localizedMessage}") toastOnUi("readTextError:${it.localizedMessage}")
@ -286,7 +290,9 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
cacheUrls.add(0, it) cacheUrls.add(0, it)
aCache.put(importRecordKey, cacheUrls.joinToString(",")) aCache.put(importRecordKey, cacheUrls.joinToString(","))
} }
ImportRssSourceDialog.start(supportFragmentManager, it) supportFragmentManager.showDialog(
ImportRssSourceDialog(it)
)
} }
} }
cancelButton() cancelButton()

@ -71,10 +71,12 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(),
override fun openSubscription(ruleSub: RuleSub) { override fun openSubscription(ruleSub: RuleSub) {
when (ruleSub.type) { when (ruleSub.type) {
0 -> supportFragmentManager.showDialog(ImportBookSourceDialog(ruleSub.url)) 0 -> supportFragmentManager.showDialog(
1 -> { ImportBookSourceDialog(ruleSub.url)
ImportRssSourceDialog.start(supportFragmentManager, ruleSub.url) )
} 1 -> supportFragmentManager.showDialog(
ImportRssSourceDialog(ruleSub.url)
)
2 -> supportFragmentManager.showDialog( 2 -> supportFragmentManager.showDialog(
ImportReplaceRuleDialog(ruleSub.url) ImportReplaceRuleDialog(ruleSub.url)
) )

Loading…
Cancel
Save