优化刷新按钮

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 { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { 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_rss_star -> viewModel.favorite()
R.id.menu_share_it -> viewModel.rssArticle?.let { R.id.menu_share_it -> viewModel.rssArticle?.let {
share(it.link) share(it.link)

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

Loading…
Cancel
Save