From 3b77b4ef55ee3b5e42b31c45e97b2270926c1307 Mon Sep 17 00:00:00 2001 From: gedoor Date: Sat, 8 Aug 2020 18:10:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E9=98=85=E8=A7=84=E5=88=99=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E9=A1=B5=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/model/Rss.kt | 2 ++ .../io/legado/app/ui/rss/article/RssArticlesViewModel.kt | 6 ++++-- 2 files changed, 6 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 8b29913d9..26cf159b8 100644 --- a/app/src/main/java/io/legado/app/model/Rss.kt +++ b/app/src/main/java/io/legado/app/model/Rss.kt @@ -19,12 +19,14 @@ object Rss { sortUrl: String, rssSource: RssSource, pageUrl: String? = null, + page: Int, scope: CoroutineScope = Coroutine.DEFAULT, context: CoroutineContext = Dispatchers.IO ): Coroutine { return Coroutine.async(scope, context) { val analyzeUrl = AnalyzeUrl( pageUrl ?: sortUrl, + page = page, headerMapF = rssSource.getHeaderMap() ) val body = analyzeUrl.getResponseAwait(rssSource.sourceUrl).body 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 8d2d06df8..b2020aea9 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 @@ -18,6 +18,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application private var nextPageUrl: String? = null var sortName: String = "" var sortUrl: String = "" + var page = 1 fun init(bundle: Bundle?) { bundle?.let { @@ -29,7 +30,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application fun loadContent(rssSource: RssSource) { isLoading = true - Rss.getArticles(sortName, sortUrl, rssSource, null) + Rss.getArticles(sortName, sortUrl, rssSource, null, 1) .onSuccess(Dispatchers.IO) { nextPageUrl = it.nextPageUrl it.articles.let { list -> @@ -54,9 +55,10 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application fun loadMore(rssSource: RssSource) { isLoading = true + page++ val pageUrl = nextPageUrl if (!pageUrl.isNullOrEmpty()) { - Rss.getArticles(sortName, pageUrl, rssSource, pageUrl) + Rss.getArticles(sortName, pageUrl, rssSource, pageUrl, page) .onSuccess(Dispatchers.IO) { nextPageUrl = it.nextPageUrl loadMoreSuccess(it.articles)