Horis 4 lat temu
rodzic
commit
8e6cc3956d

+ 2 - 4
app/src/main/java/io/legado/app/ui/rss/article/RssArticlesFragment.kt

@@ -125,11 +125,9 @@ class RssArticlesFragment() : VMBaseFragment<RssArticlesViewModel>(R.layout.frag
         viewModel.loadErrorLiveData.observe(viewLifecycleOwner) {
         viewModel.loadErrorLiveData.observe(viewLifecycleOwner) {
             loadMoreView.error(it)
             loadMoreView.error(it)
         }
         }
-        viewModel.loadFinallyLiveData.observe(viewLifecycleOwner) {
+        viewModel.loadFinallyLiveData.observe(viewLifecycleOwner) { hasMore ->
             binding.refreshLayout.isRefreshing = false
             binding.refreshLayout.isRefreshing = false
-            if (it) {
-                loadMoreView.stopLoad()
-            } else {
+            if (!hasMore) {
                 loadMoreView.noMore()
                 loadMoreView.noMore()
             }
             }
         }
         }

+ 3 - 5
app/src/main/java/io/legado/app/ui/rss/article/RssArticlesViewModel.kt

@@ -35,6 +35,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
     fun loadContent(rssSource: RssSource) {
     fun loadContent(rssSource: RssSource) {
         isLoading = true
         isLoading = true
         page = 1
         page = 1
+        order = System.currentTimeMillis()
         Rss.getArticles(viewModelScope, sortName, sortUrl, rssSource, page)
         Rss.getArticles(viewModelScope, sortName, sortUrl, rssSource, page)
             .onSuccess(Dispatchers.IO) {
             .onSuccess(Dispatchers.IO) {
                 nextPageUrl = it.second
                 nextPageUrl = it.second
@@ -45,12 +46,9 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application
                     appDb.rssArticleDao.insert(*list.toTypedArray())
                     appDb.rssArticleDao.insert(*list.toTypedArray())
                     if (!rssSource.ruleNextPage.isNullOrEmpty()) {
                     if (!rssSource.ruleNextPage.isNullOrEmpty()) {
                         appDb.rssArticleDao.clearOld(rssSource.sourceUrl, sortName, order)
                         appDb.rssArticleDao.clearOld(rssSource.sourceUrl, sortName, order)
-                        loadFinallyLiveData.postValue(true)
-                    } else {
-                        withContext(Dispatchers.Main) {
-                            loadFinallyLiveData.postValue(false)
-                        }
                     }
                     }
+                    val hasMore = list.isNotEmpty() && !rssSource.ruleNextPage.isNullOrEmpty()
+                    loadFinallyLiveData.postValue(hasMore)
                     isLoading = false
                     isLoading = false
                 }
                 }
             }.onError {
             }.onError {