RSS阅读页添加刷新按钮以应对页面内容过期失效的BUG

pull/1184/head
NineWorlds 3 years ago
parent d183ba07c7
commit e83285e691
  1. 1
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  2. 16
      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)

@ -47,8 +47,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application),
rssSource = appDb.rssSourceDao.getByKey(origin)
if (link != null) {
rssStar = appDb.rssStarDao.get(origin, link)
rssArticle = appDb.rssArticleDao.get(origin, link)
//rssArticle = rssStar?.toRssArticle() ?: appDb.rssArticleDao.get(origin, link)
rssArticle = rssStar?.toRssArticle() ?: appDb.rssArticleDao.get(origin, link)
rssArticle?.let { rssArticle ->
if (!rssArticle.description.isNullOrBlank()) {
contentLiveData.postValue(rssArticle.description!!)
@ -106,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