Merge pull request #1184 from JiuZhouWorlds/master

RSS阅读页添加刷新按钮以应对页面内容过期失效的BUG
pull/1185/head
kunfei 3 years ago committed by GitHub
commit afdcb6a44f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  2. 13
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt
  3. 5
      app/src/main/res/menu/rss_read.xml

@ -85,6 +85,7 @@ 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_star -> viewModel.favorite()
R.id.menu_share_it -> viewModel.rssArticle?.let {
share(it.link)
@ -156,13 +157,13 @@ class ReadRssActivity : VMBaseActivity<ActivityRssReadBinding, ReadRssViewModel>
private fun saveImage() {
val path = ACache.get(this@ReadRssActivity).getAsString(imagePathKey)
if (path.isNullOrEmpty()) {
selectExportFolder()
selectSaveFolder()
} else {
viewModel.saveImage(webPic, path)
}
}
private fun selectExportFolder() {
private fun selectSaveFolder() {
val default = arrayListOf<String>()
val path = ACache.get(this@ReadRssActivity).getAsString(imagePathKey)
if (!path.isNullOrEmpty()) {

@ -105,6 +105,19 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application),
}
}
fun refresh() {
rssArticle?.let { rssArticle ->
rssSource?.let {
val ruleContent = it.ruleContent
if (!ruleContent.isNullOrBlank()) {
loadContent(rssArticle, ruleContent)
} else {
loadUrl(rssArticle.link, rssArticle.origin)
}
} ?: loadUrl(rssArticle.link, rssArticle.origin)
}
}
fun favorite() {
execute {
rssStar?.let {

@ -1,6 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/menu_rss_refresh"
android:title="@string/refresh"
android:icon="@drawable/ic_refresh_black_24dp"
app:showAsAction="always" />
<item
android:id="@+id/menu_rss_star"

Loading…
Cancel
Save