|
|
@ -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,8 +46,10 @@ 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)) { |
|
|
|
|
|
|
|
withContext(Main) { |
|
|
|
adapter.addItem(searchBook) |
|
|
|
adapter.addItem(searchBook) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -54,6 +58,7 @@ class ChangeCoverViewModel(application: Application) : BaseViewModel(application |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
task?.invokeOnCompletion { |
|
|
|
task?.invokeOnCompletion { |
|
|
|
searchStateData.postValue(false) |
|
|
|
searchStateData.postValue(false) |
|
|
|