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

@ -5,6 +5,7 @@ import android.view.View
import io.legado.app.R
import io.legado.app.base.BaseDialogFragment
import io.legado.app.databinding.DialogPhotoViewBinding
import io.legado.app.model.BookCover
import io.legado.app.model.ReadBook
import io.legado.app.ui.book.read.page.provider.ImageProvider
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)
override fun onStart() {
@ -31,6 +38,8 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) {
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
arguments?.let {
val path = it.getString("path")
if (path.isNullOrEmpty()) {
val chapterIndex = it.getInt("chapterIndex")
val src = it.getString("src")
ReadBook.book?.let { book ->
@ -44,6 +53,10 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) {
}
}
}
} else {
BookCover.load(requireContext(), path = path)
.into(binding.photoView)
}
}
}

Loading…
Cancel
Save