diff --git a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt index bf942b36d..4f45f4b23 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleActivity.kt @@ -145,7 +145,7 @@ class ReplaceRuleActivity : VMBaseActivity(R.layout.activi viewModel.toTop(rule) } - override fun upOrder(rules: List) { - viewModel.upOrder(rules) + override fun upOrder() { + viewModel.upOrder() } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleAdapter.kt b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleAdapter.kt index 6f41abc5a..4386996f9 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleAdapter.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleAdapter.kt @@ -50,7 +50,7 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) : val targetItem = getItem(targetPosition) if (srcItem != null && targetItem != null) { if (srcItem.order == targetItem.order) { - callBack.upOrder(getItems()) + callBack.upOrder() } else { val srcOrder = srcItem.order srcItem.order = targetItem.order @@ -70,6 +70,6 @@ class ReplaceRuleAdapter(context: Context, var callBack: CallBack) : fun delete(rule: ReplaceRule) fun edit(rule: ReplaceRule) fun toTop(rule: ReplaceRule) - fun upOrder(rules: List) + fun upOrder() } } diff --git a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt index 755befb75..ed566ab14 100644 --- a/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/replacerule/ReplaceRuleViewModel.kt @@ -29,8 +29,9 @@ class ReplaceRuleViewModel(application: Application) : BaseViewModel(application } } - fun upOrder(rules: List) { + fun upOrder() { execute { + val rules = App.db.replaceRuleDao().all for ((index: Int, rule: ReplaceRule) in rules.withIndex()) { rule.order = index + 1 }