|
|
|
@ -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() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|