优化刷新按钮

pull/1576/head^2
kunfei 3 years ago
parent 69243cad76
commit 952a51f47e
  1. 4
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  2. 8
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt

@ -91,7 +91,9 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) {
R.id.menu_rss_refresh -> viewModel.refresh()
R.id.menu_rss_refresh -> viewModel.refresh {
binding.webView.reload()
}
R.id.menu_rss_star -> viewModel.favorite()
R.id.menu_share_it -> viewModel.rssArticle?.let {
share(it.link)

@ -104,17 +104,17 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application),
}
}
fun refresh() {
fun refresh(finish: () -> Unit) {
rssArticle?.let { rssArticle ->
rssSource?.let {
val ruleContent = it.ruleContent
if (!ruleContent.isNullOrBlank()) {
loadContent(rssArticle, ruleContent)
} else {
loadUrl(rssArticle.link, rssArticle.origin)
finish.invoke()
}
} ?: loadUrl(rssArticle.link, rssArticle.origin)
}
} ?: finish.invoke()
} ?: finish.invoke()
}
fun favorite() {

Loading…
Cancel
Save