diff --git a/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt b/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt index 4f2c6e4ca..ae92e78f6 100644 --- a/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt +++ b/app/src/main/java/io/legado/app/ui/association/FileAssociationActivity.kt @@ -31,7 +31,9 @@ class FileAssociationActivity : } viewModel.importRssSourceLive.observe(this) { binding.rotateLoading.hide() - ImportRssSourceDialog.start(supportFragmentManager, it, true) + supportFragmentManager.showDialog( + ImportRssSourceDialog(it, true) + ) } viewModel.importReplaceRuleLive.observe(this) { binding.rotateLoading.hide() diff --git a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt index 5143322d4..25fad832e 100644 --- a/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt +++ b/app/src/main/java/io/legado/app/ui/association/ImportRssSourceDialog.kt @@ -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 @@ -27,27 +26,22 @@ import io.legado.app.help.AppConfig 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 /** * 导入rss源弹出窗口 */ -class ImportRssSourceDialog : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { +class ImportRssSourceDialog() : BaseDialogFragment(), Toolbar.OnMenuItemClickListener { - companion object { - - fun start( - fragmentManager: FragmentManager, - source: String, - finishOnDismiss: Boolean = false - ) { - fragmentManager.showDialog { - 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) diff --git a/app/src/main/java/io/legado/app/ui/association/OnLineImportActivity.kt b/app/src/main/java/io/legado/app/ui/association/OnLineImportActivity.kt index 3ddfbd65a..8e485b8ca 100644 --- a/app/src/main/java/io/legado/app/ui/association/OnLineImportActivity.kt +++ b/app/src/main/java/io/legado/app/ui/association/OnLineImportActivity.kt @@ -26,8 +26,9 @@ class OnLineImportActivity : "bookSource" -> supportFragmentManager.showDialog( ImportBookSourceDialog(it.second, true) ) - "rssSource" -> ImportRssSourceDialog - .start(supportFragmentManager, it.second, true) + "rssSource" -> supportFragmentManager.showDialog( + ImportRssSourceDialog(it.second, true) + ) "replaceRule" -> supportFragmentManager.showDialog( ImportReplaceRuleDialog(it.second, true) ) @@ -46,7 +47,9 @@ class OnLineImportActivity : "/bookSource" -> supportFragmentManager.showDialog( ImportBookSourceDialog(url, true) ) - "/rssSource" -> ImportRssSourceDialog.start(supportFragmentManager, url, true) + "/rssSource" -> supportFragmentManager.showDialog( + ImportRssSourceDialog(url, true) + ) "/replaceRule" -> supportFragmentManager.showDialog( ImportReplaceRuleDialog(url, true) ) @@ -66,7 +69,9 @@ class OnLineImportActivity : "booksource" -> supportFragmentManager.showDialog( ImportBookSourceDialog(url, true) ) - "rsssource" -> ImportRssSourceDialog.start(supportFragmentManager, url, true) + "rsssource" -> supportFragmentManager.showDialog( + ImportRssSourceDialog(url, true) + ) "replace" -> supportFragmentManager.showDialog( ImportReplaceRuleDialog(url, true) ) diff --git a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt index 61ca9c95a..a8337b57a 100644 --- a/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/source/manage/RssSourceActivity.kt @@ -53,12 +53,16 @@ class RssSourceActivity : VMBaseActivity kotlin.runCatching { uri?.readText(this)?.let { - ImportRssSourceDialog.start(supportFragmentManager, it) + supportFragmentManager.showDialog( + ImportRssSourceDialog(it) + ) } }.onFailure { toastOnUi("readTextError:${it.localizedMessage}") @@ -286,7 +290,9 @@ class RssSourceActivity : VMBaseActivity(), override fun openSubscription(ruleSub: RuleSub) { when (ruleSub.type) { - 0 -> supportFragmentManager.showDialog(ImportBookSourceDialog(ruleSub.url)) - 1 -> { - ImportRssSourceDialog.start(supportFragmentManager, ruleSub.url) - } + 0 -> supportFragmentManager.showDialog( + ImportBookSourceDialog(ruleSub.url) + ) + 1 -> supportFragmentManager.showDialog( + ImportRssSourceDialog(ruleSub.url) + ) 2 -> supportFragmentManager.showDialog( ImportReplaceRuleDialog(ruleSub.url) )