|
|
@ -11,7 +11,7 @@ import io.legado.app.R |
|
|
|
import io.legado.app.base.BaseActivity |
|
|
|
import io.legado.app.base.BaseActivity |
|
|
|
import io.legado.app.data.entities.RuleSub |
|
|
|
import io.legado.app.data.entities.RuleSub |
|
|
|
import io.legado.app.databinding.ActivityRuleSubBinding |
|
|
|
import io.legado.app.databinding.ActivityRuleSubBinding |
|
|
|
import io.legado.app.databinding.DialogSourceSubEditBinding |
|
|
|
import io.legado.app.databinding.DialogRuleSubEditBinding |
|
|
|
import io.legado.app.lib.dialogs.alert |
|
|
|
import io.legado.app.lib.dialogs.alert |
|
|
|
import io.legado.app.ui.association.ImportBookSourceActivity |
|
|
|
import io.legado.app.ui.association.ImportBookSourceActivity |
|
|
|
import io.legado.app.ui.association.ImportRssSourceActivity |
|
|
|
import io.legado.app.ui.association.ImportRssSourceActivity |
|
|
@ -20,6 +20,9 @@ import kotlinx.coroutines.Dispatchers.IO |
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import org.jetbrains.anko.startActivity |
|
|
|
import org.jetbrains.anko.startActivity |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 规则订阅界面 |
|
|
|
|
|
|
|
*/ |
|
|
|
class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(), |
|
|
|
class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(), |
|
|
|
RuleSubAdapter.Callback { |
|
|
|
RuleSubAdapter.Callback { |
|
|
|
|
|
|
|
|
|
|
@ -69,7 +72,7 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(), |
|
|
|
|
|
|
|
|
|
|
|
override fun openSubscription(ruleSub: RuleSub) { |
|
|
|
override fun openSubscription(ruleSub: RuleSub) { |
|
|
|
when (ruleSub.type) { |
|
|
|
when (ruleSub.type) { |
|
|
|
RuleSub.Type.RssSource.ordinal -> { |
|
|
|
1 -> { |
|
|
|
startActivity<ImportRssSourceActivity>("source" to ruleSub.url) |
|
|
|
startActivity<ImportRssSourceActivity>("source" to ruleSub.url) |
|
|
|
} |
|
|
|
} |
|
|
|
else -> { |
|
|
|
else -> { |
|
|
@ -80,20 +83,14 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(), |
|
|
|
|
|
|
|
|
|
|
|
override fun editSubscription(ruleSub: RuleSub) { |
|
|
|
override fun editSubscription(ruleSub: RuleSub) { |
|
|
|
alert(R.string.rule_subscription) { |
|
|
|
alert(R.string.rule_subscription) { |
|
|
|
val alertBinding = DialogSourceSubEditBinding.inflate(layoutInflater).apply { |
|
|
|
val alertBinding = DialogRuleSubEditBinding.inflate(layoutInflater).apply { |
|
|
|
when (ruleSub.type) { |
|
|
|
spType.setSelection(ruleSub.type) |
|
|
|
RuleSub.Type.RssSource.ordinal -> rgType.check(R.id.rb_rss_source) |
|
|
|
|
|
|
|
else -> rgType.check(R.id.rb_book_source) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
etName.setText(ruleSub.name) |
|
|
|
etName.setText(ruleSub.name) |
|
|
|
etUrl.setText(ruleSub.url) |
|
|
|
etUrl.setText(ruleSub.url) |
|
|
|
} |
|
|
|
} |
|
|
|
customView = alertBinding.root |
|
|
|
customView = alertBinding.root |
|
|
|
okButton { |
|
|
|
okButton { |
|
|
|
when (alertBinding.rgType.checkedRadioButtonId) { |
|
|
|
ruleSub.type = alertBinding.spType.selectedItemPosition |
|
|
|
R.id.rb_rss_source -> ruleSub.setType(RuleSub.Type.RssSource) |
|
|
|
|
|
|
|
else -> ruleSub.setType(RuleSub.Type.BookSource) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
ruleSub.name = alertBinding.etName.text?.toString() ?: "" |
|
|
|
ruleSub.name = alertBinding.etName.text?.toString() ?: "" |
|
|
|
ruleSub.url = alertBinding.etUrl.text?.toString() ?: "" |
|
|
|
ruleSub.url = alertBinding.etUrl.text?.toString() ?: "" |
|
|
|
launch(IO) { |
|
|
|
launch(IO) { |
|
|
|