pull/90/head^2
kunfei 5 years ago
parent 83c2be867d
commit 8892da5468
  1. 12
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssActivity.kt
  2. 3
      app/src/main/java/io/legado/app/ui/rss/read/ReadRssViewModel.kt

@ -40,15 +40,19 @@ class ReadRssActivity : VMBaseActivity<ReadRssViewModel>(R.layout.activity_rss_r
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.rss_read, menu) menuInflater.inflate(R.menu.rss_read, menu)
starMenuItem = menu.findItem(R.id.menu_rss_star)
ttsMenuItem = menu.findItem(R.id.menu_aloud)
upStarMenu()
return super.onCompatCreateOptionsMenu(menu) return super.onCompatCreateOptionsMenu(menu)
} }
override fun onPrepareOptionsMenu(menu: Menu?): Boolean {
starMenuItem = menu?.findItem(R.id.menu_rss_star)
ttsMenuItem = menu?.findItem(R.id.menu_aloud)
upStarMenu()
return super.onPrepareOptionsMenu(menu)
}
override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { override fun onCompatOptionsItemSelected(item: MenuItem): Boolean {
when (item.itemId) { when (item.itemId) {
R.id.menu_rss_star -> viewModel.star() R.id.menu_rss_star -> viewModel.favorite()
R.id.menu_share_it -> viewModel.rssArticle?.let { R.id.menu_share_it -> viewModel.rssArticle?.let {
shareText("链接分享", it.link) shareText("链接分享", it.link)
} }

@ -70,7 +70,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application),
} }
} }
fun star() { fun favorite() {
execute { execute {
rssArticle?.let { rssArticle?.let {
if (star) { if (star) {
@ -78,6 +78,7 @@ class ReadRssViewModel(application: Application) : BaseViewModel(application),
} else { } else {
App.db.rssStarDao().insert(it.toStar()) App.db.rssStarDao().insert(it.toStar())
} }
star = !star
} }
}.onSuccess { }.onSuccess {
callBack?.upStarMenu() callBack?.upStarMenu()

Loading…
Cancel
Save