pull/517/head
gedoor 4 years ago
parent 251c141bd2
commit 65890f5d91
  1. 38
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt

@ -135,20 +135,20 @@ class BookInfoActivity :
return super.onMenuOpened(featureId, menu) return super.onMenuOpened(featureId, menu)
} }
private fun showBook(book: Book) { private fun showBook(book: Book) = with(binding) {
showCover(book) showCover(book)
binding.tvName.text = book.name tvName.text = book.name
binding.tvAuthor.text = getString(R.string.author_show, book.getRealAuthor()) tvAuthor.text = getString(R.string.author_show, book.getRealAuthor())
binding.tvOrigin.text = getString(R.string.origin_show, book.originName) tvOrigin.text = getString(R.string.origin_show, book.originName)
binding.tvLasted.text = getString(R.string.lasted_show, book.latestChapterTitle) tvLasted.text = getString(R.string.lasted_show, book.latestChapterTitle)
binding.tvIntro.text = book.getDisplayIntro() tvIntro.text = book.getDisplayIntro()
upTvBookshelf() upTvBookshelf()
val kinds = book.getKindList() val kinds = book.getKindList()
if (kinds.isEmpty()) { if (kinds.isEmpty()) {
binding.lbKind.gone() lbKind.gone()
} else { } else {
binding.lbKind.visible() lbKind.visible()
binding.lbKind.setLabels(kinds) lbKind.setLabels(kinds)
} }
upGroup(book.group) upGroup(book.group)
} }
@ -206,18 +206,18 @@ class BookInfoActivity :
} }
} }
private fun initOnClick() { private fun initOnClick() = with(binding) {
binding.ivCover.onClick { ivCover.onClick {
viewModel.bookData.value?.let { viewModel.bookData.value?.let {
ChangeCoverDialog.show(supportFragmentManager, it.name, it.author) ChangeCoverDialog.show(supportFragmentManager, it.name, it.author)
} }
} }
binding.tvRead.onClick { tvRead.onClick {
viewModel.bookData.value?.let { viewModel.bookData.value?.let {
readBook(it) readBook(it)
} }
} }
binding.tvShelf.onClick { tvShelf.onClick {
if (viewModel.inBookshelf) { if (viewModel.inBookshelf) {
deleteBook() deleteBook()
} else { } else {
@ -226,17 +226,17 @@ class BookInfoActivity :
} }
} }
} }
binding.tvOrigin.onClick { tvOrigin.onClick {
viewModel.bookData.value?.let { viewModel.bookData.value?.let {
startActivity<BookSourceEditActivity>(Pair("data", it.origin)) startActivity<BookSourceEditActivity>(Pair("data", it.origin))
} }
} }
binding.tvChangeSource.onClick { tvChangeSource.onClick {
viewModel.bookData.value?.let { viewModel.bookData.value?.let {
ChangeSourceDialog.show(supportFragmentManager, it.name, it.author) ChangeSourceDialog.show(supportFragmentManager, it.name, it.author)
} }
} }
binding.tvTocView.onClick { tvTocView.onClick {
if (!viewModel.inBookshelf) { if (!viewModel.inBookshelf) {
viewModel.saveBook { viewModel.saveBook {
viewModel.saveChapterList { viewModel.saveChapterList {
@ -247,15 +247,15 @@ class BookInfoActivity :
openChapterList() openChapterList()
} }
} }
binding.tvChangeGroup.onClick { tvChangeGroup.onClick {
viewModel.bookData.value?.let { viewModel.bookData.value?.let {
GroupSelectDialog.show(supportFragmentManager, it.group) GroupSelectDialog.show(supportFragmentManager, it.group)
} }
} }
binding.tvAuthor.onClick { tvAuthor.onClick {
startActivity<SearchActivity>(Pair("key", viewModel.bookData.value?.author)) startActivity<SearchActivity>(Pair("key", viewModel.bookData.value?.author))
} }
binding.tvName.onClick { tvName.onClick {
startActivity<SearchActivity>(Pair("key", viewModel.bookData.value?.name)) startActivity<SearchActivity>(Pair("key", viewModel.bookData.value?.name))
} }
} }

Loading…
Cancel
Save