diff --git a/app/src/main/java/io/legado/app/data/repository/ExploreRepository.kt b/app/src/main/java/io/legado/app/data/repository/ExploreRepository.kt index 1d912ab2e..7f2be3ab5 100644 --- a/app/src/main/java/io/legado/app/data/repository/ExploreRepository.kt +++ b/app/src/main/java/io/legado/app/data/repository/ExploreRepository.kt @@ -5,8 +5,10 @@ import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.SearchBook import io.legado.app.help.book.isNotShelf import io.legado.app.model.webBook.WebBook +import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.map +import kotlinx.coroutines.withContext interface ExploreRepository { fun getBookshelfItems(): Flow> @@ -31,11 +33,14 @@ class ExploreRepositoryImpl( } override suspend fun exploreBook(source: BookSource, url: String, page: Int): Result> { - return try { - val books = WebBook.exploreBookSuspend(source, url, page) - Result.success(books) - } catch (e: Exception) { - Result.failure(e) + return withContext(Dispatchers.IO) { + try { + val books = WebBook.exploreBookSuspend(source, url, page) + Result.success(books) + } catch (e: Exception) { + e.printStackTrace() + Result.failure(e) + } } }