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