|
|
@ -1,12 +1,15 @@ |
|
|
|
package io.legado.app.ui.widget.dialog |
|
|
|
package io.legado.app.ui.widget.dialog |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.annotation.SuppressLint |
|
|
|
import android.os.Bundle |
|
|
|
import android.os.Bundle |
|
|
|
import android.view.View |
|
|
|
import android.view.View |
|
|
|
|
|
|
|
import com.bumptech.glide.request.RequestOptions |
|
|
|
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.help.BookHelp |
|
|
|
import io.legado.app.help.BookHelp |
|
|
|
import io.legado.app.help.glide.ImageLoader |
|
|
|
import io.legado.app.help.glide.ImageLoader |
|
|
|
|
|
|
|
import io.legado.app.help.glide.OkHttpModelLoader |
|
|
|
import io.legado.app.model.BookCover |
|
|
|
import io.legado.app.model.BookCover |
|
|
|
import io.legado.app.model.ReadBook |
|
|
|
import io.legado.app.model.ReadBook |
|
|
|
import io.legado.app.utils.setLayout |
|
|
|
import io.legado.app.utils.setLayout |
|
|
@ -17,9 +20,10 @@ import io.legado.app.utils.viewbindingdelegate.viewBinding |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) { |
|
|
|
class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) { |
|
|
|
|
|
|
|
|
|
|
|
constructor(src: String) : this() { |
|
|
|
constructor(src: String, sourceOrigin: String? = null) : this() { |
|
|
|
arguments = Bundle().apply { |
|
|
|
arguments = Bundle().apply { |
|
|
|
putString("src", src) |
|
|
|
putString("src", src) |
|
|
|
|
|
|
|
putString("sourceOrigin", sourceOrigin) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -30,8 +34,10 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) { |
|
|
|
setLayout(1f, 1f) |
|
|
|
setLayout(1f, 1f) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressLint("CheckResult") |
|
|
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) { |
|
|
|
arguments?.getString("src")?.let { src -> |
|
|
|
arguments?.let { arguments -> |
|
|
|
|
|
|
|
arguments.getString("src")?.let { src -> |
|
|
|
val file = ReadBook.book?.let { book -> |
|
|
|
val file = ReadBook.book?.let { book -> |
|
|
|
BookHelp.getImage(book, src) |
|
|
|
BookHelp.getImage(book, src) |
|
|
|
} |
|
|
|
} |
|
|
@ -40,11 +46,20 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) { |
|
|
|
.error(R.drawable.image_loading_error) |
|
|
|
.error(R.drawable.image_loading_error) |
|
|
|
.into(binding.photoView) |
|
|
|
.into(binding.photoView) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
ImageLoader.load(requireContext(), src) |
|
|
|
ImageLoader.load(requireContext(), src).apply { |
|
|
|
.error(BookCover.defaultDrawable) |
|
|
|
arguments.getString("sourceOrigin")?.let { sourceOrigin -> |
|
|
|
|
|
|
|
apply( |
|
|
|
|
|
|
|
RequestOptions().set( |
|
|
|
|
|
|
|
OkHttpModelLoader.sourceOriginOption, |
|
|
|
|
|
|
|
sourceOrigin |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.error(BookCover.defaultDrawable) |
|
|
|
.into(binding.photoView) |
|
|
|
.into(binding.photoView) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|