diff --git a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt index 3e091cded..87fa9de07 100644 --- a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleActivity.kt @@ -294,27 +294,32 @@ class ReplaceRuleActivity : } override fun update(vararg rule: ReplaceRule) { - setResult(Activity.RESULT_OK) + setResult(RESULT_OK) viewModel.update(*rule) } override fun delete(rule: ReplaceRule) { - setResult(Activity.RESULT_OK) + setResult(RESULT_OK) viewModel.delete(rule) } override fun edit(rule: ReplaceRule) { - setResult(Activity.RESULT_OK) + setResult(RESULT_OK) ReplaceEditActivity.show(this, rule.id) } override fun toTop(rule: ReplaceRule) { - setResult(Activity.RESULT_OK) + setResult(RESULT_OK) viewModel.toTop(rule) } + override fun toBottom(rule: ReplaceRule) { + setResult(RESULT_OK) + viewModel.toBottom(rule) + } + override fun upOrder() { - setResult(Activity.RESULT_OK) + setResult(RESULT_OK) viewModel.upOrder() } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt index 31d0eb59f..193a82f77 100644 --- a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleAdapter.kt @@ -121,6 +121,7 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) : popupMenu.setOnMenuItemClickListener { menuItem -> when (menuItem.itemId) { R.id.menu_top -> callBack.toTop(item) + R.id.menu_bottom -> callBack.toBottom(item) R.id.menu_del -> callBack.delete(item) } true @@ -187,6 +188,7 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) : fun delete(rule: ReplaceRule) fun edit(rule: ReplaceRule) fun toTop(rule: ReplaceRule) + fun toBottom(rule: ReplaceRule) fun upOrder() fun upCountView() } diff --git a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt index a14647c82..219f4bc88 100644 --- a/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/replace/ReplaceRuleViewModel.kt @@ -34,6 +34,13 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application } } + fun toBottom(rule: ReplaceRule) { + execute { + rule.order = App.db.replaceRuleDao().maxOrder + 1 + App.db.replaceRuleDao().update(rule) + } + } + fun upOrder() { execute { val rules = App.db.replaceRuleDao().all diff --git a/app/src/main/res/menu/replace_rule_item.xml b/app/src/main/res/menu/replace_rule_item.xml index 17483eeec..77c3a18cd 100644 --- a/app/src/main/res/menu/replace_rule_item.xml +++ b/app/src/main/res/menu/replace_rule_item.xml @@ -5,6 +5,10 @@ android:id="@+id/menu_top" android:title="@string/to_top" /> + +