From 1c74f48d5398997e78a4caa861239b889886df88 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 3 Oct 2019 16:15:12 +0800 Subject: [PATCH] up --- .../app/ui/rss/article/RssArticlesViewModel.kt | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt index bd82bdda4..b24445785 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt @@ -6,6 +6,7 @@ import io.legado.app.App import io.legado.app.base.BaseViewModel import io.legado.app.data.entities.RssSource import io.legado.app.model.Rss +import kotlinx.coroutines.Dispatchers.IO class RssArticlesViewModel(application: Application) : BaseViewModel(application) { @@ -20,15 +21,16 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application } else { titleLiveData.postValue(rssSource.sourceName) } - Rss.getArticles(rssSource, this).onSuccess { - it?.let { - App.db.rssArtivleDao().insert(*it.toTypedArray()) + Rss.getArticles(rssSource, this) + .onSuccess(IO) { + it?.let { + App.db.rssArtivleDao().insert(*it.toTypedArray()) + } + }.onError { + toast(it.localizedMessage) + }.onFinally { + onFinally() } - }.onError { - toast(it.localizedMessage) - }.onFinally { - onFinally() - } } }