From 91a56b294318bcfd1fec38f19e2ad0aed42b050b Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 19 Nov 2019 19:41:17 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/model/Rss.kt | 3 ++- .../java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/Rss.kt b/app/src/main/java/io/legado/app/model/Rss.kt index b73a48fab..5075e5b1e 100644 --- a/app/src/main/java/io/legado/app/model/Rss.kt +++ b/app/src/main/java/io/legado/app/model/Rss.kt @@ -15,11 +15,12 @@ object Rss { fun getArticles( rssSource: RssSource, + page: Int, scope: CoroutineScope = Coroutine.DEFAULT, context: CoroutineContext = Dispatchers.IO ): Coroutine> { return Coroutine.async(scope, context) { - val analyzeUrl = AnalyzeUrl(rssSource.sourceUrl) + val analyzeUrl = AnalyzeUrl(rssSource.sourceUrl, page = page) val body = analyzeUrl.getResponseAwait(rssSource.sourceUrl).body RssParserByRule.parseXML(body, rssSource) } 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 74fc81bd1..4640909e1 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 @@ -14,6 +14,7 @@ import kotlinx.coroutines.withContext class RssArticlesViewModel(application: Application) : BaseViewModel(application) { var rssSource: RssSource? = null val titleLiveData = MutableLiveData() + var page = 1 fun loadContent(url: String, onFinally: () -> Unit, loadMore: (() -> Unit)? = null) { execute { @@ -24,7 +25,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application rssSource = RssSource(sourceUrl = url) } rssSource?.let { rssSource -> - Rss.getArticles(rssSource, this) + Rss.getArticles(rssSource, page, this) .onSuccess { it?.let { withContext(IO) { @@ -51,6 +52,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application fun clear(url: String, onFinally: () -> Unit) { execute { App.db.rssArticleDao().delete(url) + page = 1 loadContent(url, onFinally) } }