|
|
|
@ -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,18 +38,24 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) { |
|
|
|
|
|
|
|
|
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
|
arguments?.let { |
|
|
|
|
val chapterIndex = it.getInt("chapterIndex") |
|
|
|
|
val src = it.getString("src") |
|
|
|
|
ReadBook.book?.let { book -> |
|
|
|
|
src?.let { |
|
|
|
|
execute { |
|
|
|
|
ImageProvider.getImage(book, chapterIndex, src, ReadBook.bookSource) |
|
|
|
|
}.onSuccess { bitmap -> |
|
|
|
|
if (bitmap != null) { |
|
|
|
|
binding.photoView.setImageBitmap(bitmap) |
|
|
|
|
val path = it.getString("path") |
|
|
|
|
if (path.isNullOrEmpty()) { |
|
|
|
|
val chapterIndex = it.getInt("chapterIndex") |
|
|
|
|
val src = it.getString("src") |
|
|
|
|
ReadBook.book?.let { book -> |
|
|
|
|
src?.let { |
|
|
|
|
execute { |
|
|
|
|
ImageProvider.getImage(book, chapterIndex, src, ReadBook.bookSource) |
|
|
|
|
}.onSuccess { bitmap -> |
|
|
|
|
if (bitmap != null) { |
|
|
|
|
binding.photoView.setImageBitmap(bitmap) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
BookCover.load(requireContext(), path = path) |
|
|
|
|
.into(binding.photoView) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|