pull/84/head
kunfei 5 years ago
parent 1503fadbee
commit 6c92f21a26
  1. 4
      app/src/main/java/io/legado/app/ui/changecover/ChangeCoverDialog.kt
  2. 11
      app/src/main/java/io/legado/app/ui/changecover/ChangeCoverViewModel.kt
  3. 3
      app/src/main/java/io/legado/app/ui/changecover/CoverAdapter.kt
  4. 6
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceDialog.kt
  5. 4
      app/src/main/java/io/legado/app/ui/changesource/ChangeSourceViewModel.kt

@ -13,7 +13,7 @@ import io.legado.app.utils.getViewModel
import kotlinx.android.synthetic.main.dialog_change_source.* import kotlinx.android.synthetic.main.dialog_change_source.*
class ChangeCoverDialog : DialogFragment() { class ChangeCoverDialog : DialogFragment(), ChangeCoverViewModel.CallBack {
companion object { companion object {
const val tag = "changeCoverDialog" const val tag = "changeCoverDialog"
@ -32,7 +32,7 @@ class ChangeCoverDialog : DialogFragment() {
private var callBack: CallBack? = null private var callBack: CallBack? = null
private lateinit var viewModel: ChangeCoverViewModel private lateinit var viewModel: ChangeCoverViewModel
private lateinit var adapter: CoverAdapter override lateinit var adapter: CoverAdapter
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()

@ -1,6 +1,7 @@
package io.legado.app.ui.changecover package io.legado.app.ui.changecover
import android.app.Application import android.app.Application
import io.legado.app.App
import io.legado.app.base.BaseViewModel import io.legado.app.base.BaseViewModel
class ChangeCoverViewModel(application: Application) : BaseViewModel(application) { class ChangeCoverViewModel(application: Application) : BaseViewModel(application) {
@ -8,5 +9,15 @@ class ChangeCoverViewModel(application: Application) : BaseViewModel(application
var name: String = "" var name: String = ""
var author: String = "" var author: String = ""
fun initData() {
execute {
App.db.searchBookDao().getByNameAuthorEnable(name, author).let {
} }
}
}
interface CallBack {
var adapter: CoverAdapter
}
}

@ -22,4 +22,7 @@ class CoverAdapter(context: Context) :
} }
} }
interface CallBack {
fun changeTo()
}
} }

@ -40,7 +40,7 @@ class ChangeSourceDialog : DialogFragment(),
private var callBack: CallBack? = null private var callBack: CallBack? = null
private lateinit var viewModel: ChangeSourceViewModel private lateinit var viewModel: ChangeSourceViewModel
private lateinit var changeSourceAdapter: ChangeSourceAdapter override lateinit var changeSourceAdapter: ChangeSourceAdapter
override fun onStart() { override fun onStart() {
super.onStart() super.onStart()
@ -139,10 +139,6 @@ class ChangeSourceDialog : DialogFragment(),
override val bookUrl: String? override val bookUrl: String?
get() = callBack?.oldBook?.bookUrl get() = callBack?.oldBook?.bookUrl
override fun adapter(): ChangeSourceAdapter {
return changeSourceAdapter
}
interface CallBack { interface CallBack {
val oldBook: Book? val oldBook: Book?
fun changeTo(book: Book) fun changeTo(book: Book)

@ -40,7 +40,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
private fun upAdapter() { private fun upAdapter() {
execute { execute {
callBack?.adapter()?.let { callBack?.changeSourceAdapter?.let {
val books = searchBooks.toList() val books = searchBooks.toList()
books.sorted() books.sorted()
val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), books)) val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), books))
@ -131,7 +131,7 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio
} }
interface CallBack { interface CallBack {
fun adapter(): ChangeSourceAdapter var changeSourceAdapter: ChangeSourceAdapter
} }
override fun onCleared() { override fun onCleared() {

Loading…
Cancel
Save