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