pull/84/head
kunfei 5 years ago
parent 85dfd30274
commit bed1bc8f7a
  1. 7
      app/src/main/java/io/legado/app/ui/changecover/ChangeCoverViewModel.kt

@ -8,7 +8,9 @@ import io.legado.app.help.AppConfig
import io.legado.app.help.coroutine.Coroutine import io.legado.app.help.coroutine.Coroutine
import io.legado.app.model.WebBook import io.legado.app.model.WebBook
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.asCoroutineDispatcher import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.withContext
import java.util.concurrent.Executors import java.util.concurrent.Executors
class ChangeCoverViewModel(application: Application) : BaseViewModel(application) { class ChangeCoverViewModel(application: Application) : BaseViewModel(application) {
@ -44,9 +46,12 @@ class ChangeCoverViewModel(application: Application) : BaseViewModel(application
if (it != null && it.isNotEmpty()) { if (it != null && it.isNotEmpty()) {
val searchBook = it[0] val searchBook = it[0]
if (searchBook.name == name && searchBook.author == author) { if (searchBook.name == name && searchBook.author == author) {
App.db.searchBookDao().insert(searchBook)
callBack?.adapter?.let { adapter -> callBack?.adapter?.let { adapter ->
if (!adapter.getItems().contains(searchBook)) { if (!adapter.getItems().contains(searchBook)) {
adapter.addItem(searchBook) withContext(Main) {
adapter.addItem(searchBook)
}
} }
} }
} }

Loading…
Cancel
Save