优化
This commit is contained in:
@@ -23,6 +23,9 @@ interface DictRuleDao {
|
||||
@Insert(onConflict = OnConflictStrategy.REPLACE)
|
||||
fun insert(vararg dictRule: DictRule)
|
||||
|
||||
@Update
|
||||
fun update(vararg dictRule: DictRule)
|
||||
|
||||
@Delete
|
||||
fun delete(vararg dictRule: DictRule)
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ class DictRuleActivity : VMBaseActivity<ActivityDictRuleBinding, DictRuleViewMod
|
||||
}
|
||||
|
||||
override fun update(vararg rule: DictRule) {
|
||||
viewModel.upsert(*rule)
|
||||
viewModel.update(*rule)
|
||||
}
|
||||
|
||||
override fun delete(rule: DictRule) {
|
||||
|
||||
@@ -2,22 +2,30 @@ package io.legado.app.ui.dict.rule
|
||||
|
||||
import android.app.Application
|
||||
import io.legado.app.base.BaseViewModel
|
||||
import io.legado.app.constant.AppLog
|
||||
import io.legado.app.data.appDb
|
||||
import io.legado.app.data.entities.DictRule
|
||||
import io.legado.app.help.DefaultData
|
||||
import io.legado.app.utils.toastOnUi
|
||||
|
||||
class DictRuleViewModel(application: Application) : BaseViewModel(application) {
|
||||
|
||||
|
||||
fun upsert(vararg dictRule: DictRule) {
|
||||
fun update(vararg dictRule: DictRule) {
|
||||
execute {
|
||||
appDb.dictRuleDao.insert(*dictRule)
|
||||
}.onError {
|
||||
AppLog.put(it.localizedMessage, it)
|
||||
context.toastOnUi(it.localizedMessage)
|
||||
}
|
||||
}
|
||||
|
||||
fun delete(vararg dictRule: DictRule) {
|
||||
execute {
|
||||
appDb.dictRuleDao.delete(*dictRule)
|
||||
}.onError {
|
||||
AppLog.put(it.localizedMessage, it)
|
||||
context.toastOnUi(it.localizedMessage)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,13 @@
|
||||
android:icon="@drawable/ic_cfg_source"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<io.legado.app.lib.prefs.Preference
|
||||
android:key="txtTocRegexManage"
|
||||
android:title="@string/txt_toc_regex"
|
||||
android:summary="@string/config_txt_toc_regex"
|
||||
android:icon="@drawable/ic_cfg_source"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<io.legado.app.lib.prefs.Preference
|
||||
android:key="replaceManage"
|
||||
android:title="@string/replace_purify"
|
||||
@@ -26,13 +33,6 @@
|
||||
android:icon="@drawable/ic_translate"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<io.legado.app.lib.prefs.Preference
|
||||
android:key="txtTocRegexManage"
|
||||
android:title="@string/txt_toc_regex"
|
||||
android:summary="@string/config_txt_toc_regex"
|
||||
android:icon="@drawable/ic_cfg_source"
|
||||
app:iconSpaceReserved="false" />
|
||||
|
||||
<io.legado.app.lib.prefs.NameListPreference
|
||||
android:defaultValue="0"
|
||||
android:entries="@array/theme_mode"
|
||||
|
||||
Reference in New Issue
Block a user