pull/1738/head
kunfei 3 years ago
parent d61ce47648
commit 694389ca2e
  1. 11
      app/src/main/java/io/legado/app/ui/book/info/BookInfoActivity.kt
  2. 31
      app/src/main/java/io/legado/app/ui/book/read/PhotoDialog.kt

@ -30,6 +30,7 @@ import io.legado.app.ui.book.changecover.ChangeCoverDialog
import io.legado.app.ui.book.changesource.ChangeBookSourceDialog import io.legado.app.ui.book.changesource.ChangeBookSourceDialog
import io.legado.app.ui.book.group.GroupSelectDialog import io.legado.app.ui.book.group.GroupSelectDialog
import io.legado.app.ui.book.info.edit.BookInfoEditActivity import io.legado.app.ui.book.info.edit.BookInfoEditActivity
import io.legado.app.ui.book.read.PhotoDialog
import io.legado.app.ui.book.read.ReadBookActivity import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.search.SearchActivity import io.legado.app.ui.book.search.SearchActivity
import io.legado.app.ui.book.source.edit.BookSourceEditActivity import io.legado.app.ui.book.source.edit.BookSourceEditActivity
@ -104,7 +105,7 @@ class BookInfoActivity :
viewModel.bookData.observe(this) { showBook(it) } viewModel.bookData.observe(this) { showBook(it) }
viewModel.chapterListData.observe(this) { upLoading(false, it) } viewModel.chapterListData.observe(this) { upLoading(false, it) }
viewModel.initData(intent) viewModel.initData(intent)
initOnClick() initViewEvent()
} }
override fun onCompatCreateOptionsMenu(menu: Menu): Boolean { override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
@ -263,7 +264,7 @@ class BookInfoActivity :
} }
} }
private fun initOnClick() = binding.run { private fun initViewEvent() = binding.run {
ivCover.setOnClickListener { ivCover.setOnClickListener {
viewModel.bookData.value?.let { viewModel.bookData.value?.let {
showDialogFragment( showDialogFragment(
@ -271,6 +272,12 @@ class BookInfoActivity :
) )
} }
} }
ivCover.setOnLongClickListener {
viewModel.bookData.value?.getDisplayCover()?.let { path ->
showDialogFragment(PhotoDialog(path))
}
true
}
tvRead.setOnClickListener { tvRead.setOnClickListener {
viewModel.bookData.value?.let { viewModel.bookData.value?.let {
readBook(it) readBook(it)

@ -5,6 +5,7 @@ import android.view.View
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.BaseDialogFragment import io.legado.app.base.BaseDialogFragment
import io.legado.app.databinding.DialogPhotoViewBinding import io.legado.app.databinding.DialogPhotoViewBinding
import io.legado.app.model.BookCover
import io.legado.app.model.ReadBook import io.legado.app.model.ReadBook
import io.legado.app.ui.book.read.page.provider.ImageProvider import io.legado.app.ui.book.read.page.provider.ImageProvider
import io.legado.app.utils.setLayout import io.legado.app.utils.setLayout
@ -22,6 +23,12 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) {
} }
} }
constructor(path: String) : this() {
arguments = Bundle().apply {
putString("path", path)
}
}
private val binding by viewBinding(DialogPhotoViewBinding::bind) private val binding by viewBinding(DialogPhotoViewBinding::bind)
override fun onStart() { override fun onStart() {
@ -31,18 +38,24 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) {
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
arguments?.let { arguments?.let {
val chapterIndex = it.getInt("chapterIndex") val path = it.getString("path")
val src = it.getString("src") if (path.isNullOrEmpty()) {
ReadBook.book?.let { book -> val chapterIndex = it.getInt("chapterIndex")
src?.let { val src = it.getString("src")
execute { ReadBook.book?.let { book ->
ImageProvider.getImage(book, chapterIndex, src, ReadBook.bookSource) src?.let {
}.onSuccess { bitmap -> execute {
if (bitmap != null) { ImageProvider.getImage(book, chapterIndex, src, ReadBook.bookSource)
binding.photoView.setImageBitmap(bitmap) }.onSuccess { bitmap ->
if (bitmap != null) {
binding.photoView.setImageBitmap(bitmap)
}
} }
} }
} }
} else {
BookCover.load(requireContext(), path = path)
.into(binding.photoView)
} }
} }

Loading…
Cancel
Save