pull/35/head^2
kunfei 5 years ago
parent ff2800ce0a
commit 1c74f48d53
  1. 18
      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.base.BaseViewModel
import io.legado.app.data.entities.RssSource import io.legado.app.data.entities.RssSource
import io.legado.app.model.Rss import io.legado.app.model.Rss
import kotlinx.coroutines.Dispatchers.IO
class RssArticlesViewModel(application: Application) : BaseViewModel(application) { class RssArticlesViewModel(application: Application) : BaseViewModel(application) {
@ -20,15 +21,16 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
} else { } else {
titleLiveData.postValue(rssSource.sourceName) titleLiveData.postValue(rssSource.sourceName)
} }
Rss.getArticles(rssSource, this).onSuccess { Rss.getArticles(rssSource, this)
it?.let { .onSuccess(IO) {
App.db.rssArtivleDao().insert(*it.toTypedArray()) it?.let {
App.db.rssArtivleDao().insert(*it.toTypedArray())
}
}.onError {
toast(it.localizedMessage)
}.onFinally {
onFinally()
} }
}.onError {
toast(it.localizedMessage)
}.onFinally {
onFinally()
}
} }
} }

Loading…
Cancel
Save