源订阅重复提醒

pull/951/head
gedoor 4 years ago
parent 1499ad5408
commit 185ee8da61
  1. 3
      app/src/main/java/io/legado/app/data/dao/RuleSubDao.kt
  2. 21
      app/src/main/java/io/legado/app/ui/rss/subscription/RuleSubActivity.kt
  3. 1
      app/src/main/res/values-zh-rHK/strings.xml
  4. 1
      app/src/main/res/values-zh-rTW/strings.xml
  5. 1
      app/src/main/res/values-zh/strings.xml
  6. 1
      app/src/main/res/values/strings.xml

@ -16,6 +16,9 @@ interface RuleSubDao {
@get:Query("select customOrder from ruleSubs order by customOrder limit 0,1")
val maxOrder: Int
@Query("select * from ruleSubs where url = :url")
fun findByUrl(url: String): RuleSub?
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg ruleSub: RuleSub)

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

@ -819,5 +819,6 @@
<string name="toc_src">目录源码</string>
<string name="content_src">正文源码</string>
<string name="list_src">列表源码</string>
<string name="url_already">此url已订阅</string>
</resources>

@ -821,5 +821,6 @@
<string name="toc_src">目录源码</string>
<string name="content_src">正文源码</string>
<string name="list_src">列表源码</string>
<string name="url_already">此url已订阅</string>
</resources>

@ -823,5 +823,6 @@
<string name="toc_src">目录源码</string>
<string name="content_src">正文源码</string>
<string name="list_src">列表源码</string>
<string name="url_already">此url已订阅</string>
</resources>

@ -826,5 +826,6 @@
<string name="toc_src">目录源码</string>
<string name="content_src">正文源码</string>
<string name="list_src">列表源码</string>
<string name="url_already">此url已订阅</string>
</resources>

Loading…
Cancel
Save