From e83285e6914a9c759e1a712e49f0805b58269a5b Mon Sep 17 00:00:00 2001 From: NineWorlds <1365887550@qq.com> Date: Thu, 29 Jul 2021 13:07:44 +0800 Subject: [PATCH] =?UTF-8?q?RSS=E9=98=85=E8=AF=BB=E9=A1=B5=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E5=88=B7=E6=96=B0=E6=8C=89=E9=92=AE=E4=BB=A5=E5=BA=94?= =?UTF-8?q?=E5=AF=B9=E9=A1=B5=E9=9D=A2=E5=86=85=E5=AE=B9=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E5=A4=B1=E6=95=88=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/legado/app/ui/rss/read/ReadRssActivity.kt | 1 + .../legado/app/ui/rss/read/ReadRssViewModel.kt | 16 ++++++++++++++-- app/src/main/res/menu/rss_read.xml | 5 +++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt index 939c4dbec..1728f7320 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt @@ -85,6 +85,7 @@ class ReadRssActivity : VMBaseActivity 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) diff --git a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt index 56a70bb79..1badb5706 100644 --- a/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt @@ -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 { diff --git a/app/src/main/res/menu/rss_read.xml b/app/src/main/res/menu/rss_read.xml index 41280b275..062830439 100644 --- a/app/src/main/res/menu/rss_read.xml +++ b/app/src/main/res/menu/rss_read.xml @@ -1,6 +1,11 @@ +