diff --git a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt index d28050509..8f11b3c09 100644 --- a/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/article/RssArticlesActivity.kt @@ -39,7 +39,9 @@ class RssArticlesActivity : VMBaseActivity(R.layout.activi title_bar.title = it }) initView() - refresh_recycler_view.startLoading() + viewModel.initData(intent) { + refresh_recycler_view.startLoading() + } } override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { 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 5ad2a3ef2..3c18a5abc 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 @@ -20,7 +20,7 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application var page = 1 var hasMore = true - fun initData(intent: Intent) { + fun initData(intent: Intent, finally: () -> Unit) { execute { url = intent.getStringExtra("url") url?.let { url -> @@ -31,6 +31,8 @@ class RssArticlesViewModel(application: Application) : BaseViewModel(application rssSource = RssSource(sourceUrl = url) } } + }.onFinally { + finally() } }