|
|
@ -9,6 +9,7 @@ import io.legado.app.data.entities.Book |
|
|
|
import io.legado.app.data.entities.SearchBook |
|
|
|
import io.legado.app.data.entities.SearchBook |
|
|
|
import io.legado.app.model.WebBook |
|
|
|
import io.legado.app.model.WebBook |
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
import kotlinx.coroutines.Dispatchers |
|
|
|
|
|
|
|
import kotlinx.coroutines.launch |
|
|
|
import org.jetbrains.anko.debug |
|
|
|
import org.jetbrains.anko.debug |
|
|
|
|
|
|
|
|
|
|
|
class ChangeSourceViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
class ChangeSourceViewModel(application: Application) : BaseViewModel(application) { |
|
|
@ -30,10 +31,14 @@ class ChangeSourceViewModel(application: Application) : BaseViewModel(applicatio |
|
|
|
|
|
|
|
|
|
|
|
private fun upAdapter() { |
|
|
|
private fun upAdapter() { |
|
|
|
callBack?.adapter()?.let { |
|
|
|
callBack?.adapter()?.let { |
|
|
|
|
|
|
|
val books = searchBooks.toList() |
|
|
|
val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), searchBooks.toList())) |
|
|
|
val diffResult = DiffUtil.calculateDiff(DiffCallBack(it.getItems(), searchBooks.toList())) |
|
|
|
|
|
|
|
launch { |
|
|
|
|
|
|
|
it.setItemsNoNotify(books) |
|
|
|
diffResult.dispatchUpdatesTo(it) |
|
|
|
diffResult.dispatchUpdatesTo(it) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun search() { |
|
|
|
fun search() { |
|
|
|
execute { |
|
|
|
execute { |
|
|
|