pull/1434/head
gedoor 3 years ago
parent f125aa8bc3
commit e54166f707
  1. 39
      app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleActivity.kt
  2. 13
      app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleAdapter.kt
  3. 18
      app/src/main/java/io/legado/app/ui/book/local/rule/TxtTocRuleViewModel.kt
  4. 2
      build.gradle

@ -3,22 +3,53 @@ package io.legado.app.ui.book.local.rule
import android.os.Bundle
import androidx.activity.viewModels
import io.legado.app.base.VMBaseActivity
import io.legado.app.data.entities.TxtTocRule
import io.legado.app.databinding.ActivityTxtTocRuleBinding
import io.legado.app.utils.viewbindingdelegate.viewBinding
class TxtTocRuleActivity : VMBaseActivity<ActivityTxtTocRuleBinding, TxtTocRuleViewModel>() {
class TxtTocRuleActivity : VMBaseActivity<ActivityTxtTocRuleBinding, TxtTocRuleViewModel>(),
TxtTocRuleAdapter.Callback {
override val viewModel: TxtTocRuleViewModel by viewModels()
override val binding: ActivityTxtTocRuleBinding by viewBinding(ActivityTxtTocRuleBinding::inflate)
private val adapter: TxtTocRuleAdapter by lazy {
TxtTocRuleAdapter(this)
TxtTocRuleAdapter(this, this)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
TODO("Not yet implemented")
initView()
}
private fun initView() {
private fun initView() = binding.run {
recyclerView.adapter = adapter
}
override fun del(source: TxtTocRule) {
viewModel.del(source)
}
override fun edit(source: TxtTocRule) {
}
override fun update(vararg source: TxtTocRule) {
}
override fun toTop(source: TxtTocRule) {
}
override fun toBottom(source: TxtTocRule) {
}
override fun upOrder() {
}
override fun upCountView() {
}

@ -7,7 +7,7 @@ import io.legado.app.base.adapter.RecyclerAdapter
import io.legado.app.data.entities.TxtTocRule
import io.legado.app.databinding.ItemTxtTocRuleBinding
class TxtTocRuleAdapter(context: Context) :
class TxtTocRuleAdapter(context: Context, private val callback: Callback) :
RecyclerAdapter<TxtTocRule, ItemTxtTocRuleBinding>(context) {
private val selected = linkedSetOf<TxtTocRule>()
@ -35,6 +35,7 @@ class TxtTocRuleAdapter(context: Context) :
} else {
selected.remove(it)
}
callback.upCountView()
}
}
}
@ -50,4 +51,14 @@ class TxtTocRuleAdapter(context: Context) :
}
}
interface Callback {
fun del(source: TxtTocRule)
fun edit(source: TxtTocRule)
fun update(vararg source: TxtTocRule)
fun toTop(source: TxtTocRule)
fun toBottom(source: TxtTocRule)
fun upOrder()
fun upCountView()
}
}

@ -2,5 +2,21 @@ package io.legado.app.ui.book.local.rule
import android.app.Application
import io.legado.app.base.BaseViewModel
import io.legado.app.data.appDb
import io.legado.app.data.entities.TxtTocRule
class TxtTocRuleViewModel(app: Application) : BaseViewModel(app)
class TxtTocRuleViewModel(app: Application) : BaseViewModel(app) {
fun del(txtTocRule: TxtTocRule) {
execute {
appDb.txtTocRuleDao.delete(txtTocRule)
}
}
fun update(txtTocRule: TxtTocRule) {
execute {
appDb.txtTocRuleDao.update(txtTocRule)
}
}
}

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.5.31'
ext.kotlin_version = '1.6.0'
repositories {
google()
mavenCentral()

Loading…
Cancel
Save