|
|
@ -18,8 +18,10 @@ import io.legado.app.ui.association.ImportReplaceRuleActivity |
|
|
|
import io.legado.app.ui.association.ImportRssSourceActivity |
|
|
|
import io.legado.app.ui.association.ImportRssSourceActivity |
|
|
|
import io.legado.app.ui.widget.recycler.ItemTouchCallback |
|
|
|
import io.legado.app.ui.widget.recycler.ItemTouchCallback |
|
|
|
import io.legado.app.utils.startActivity |
|
|
|
import io.legado.app.utils.startActivity |
|
|
|
|
|
|
|
import io.legado.app.utils.toastOnUi |
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import kotlinx.coroutines.launch |
|
|
|
|
|
|
|
import kotlinx.coroutines.withContext |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 规则订阅界面 |
|
|
|
* 规则订阅界面 |
|
|
@ -100,11 +102,20 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(), |
|
|
|
} |
|
|
|
} |
|
|
|
customView { alertBinding.root } |
|
|
|
customView { alertBinding.root } |
|
|
|
okButton { |
|
|
|
okButton { |
|
|
|
ruleSub.type = alertBinding.spType.selectedItemPosition |
|
|
|
launch { |
|
|
|
ruleSub.name = alertBinding.etName.text?.toString() ?: "" |
|
|
|
ruleSub.type = alertBinding.spType.selectedItemPosition |
|
|
|
ruleSub.url = alertBinding.etUrl.text?.toString() ?: "" |
|
|
|
ruleSub.name = alertBinding.etName.text?.toString() ?: "" |
|
|
|
launch(IO) { |
|
|
|
ruleSub.url = alertBinding.etUrl.text?.toString() ?: "" |
|
|
|
appDb.ruleSubDao.insert(ruleSub) |
|
|
|
val rs = withContext(IO) { |
|
|
|
|
|
|
|
appDb.ruleSubDao.findByUrl(ruleSub.url) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (rs != null && rs.id != ruleSub.id) { |
|
|
|
|
|
|
|
toastOnUi(R.string.url_already) |
|
|
|
|
|
|
|
return@launch |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
withContext(IO) { |
|
|
|
|
|
|
|
appDb.ruleSubDao.insert(ruleSub) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
cancelButton() |
|
|
|
cancelButton() |
|
|
|