修复图片显示

This commit is contained in:
HapeLee
2025-09-18 02:12:58 +08:00
parent f521219cbe
commit 2ecd2507b7
5 changed files with 61 additions and 19 deletions
@@ -1412,6 +1412,7 @@ class ReadBookActivity : BaseReadBookActivity(),
*/
@SuppressLint("RtlHardcoded")
override fun onImageLongPress(x: Float, y: Float, src: String) {
binding.root.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS)
popupAction.setItems(
listOf(
SelectItem(getString(R.string.show), "show"),
@@ -3,6 +3,7 @@ package io.legato.kazusa.ui.widget
import android.content.Context
import android.view.ViewGroup
import android.widget.PopupWindow
import io.legato.kazusa.R
import io.legato.kazusa.base.adapter.ItemViewHolder
import io.legato.kazusa.base.adapter.RecyclerAdapter
import io.legato.kazusa.databinding.ItemTextBinding
@@ -22,6 +23,7 @@ class PopupAction(private val context: Context) :
var onActionClick: ((action: String) -> Unit)? = null
init {
animationStyle = R.style.TextActionMenuAnimation
contentView = binding.root
isTouchable = true
@@ -8,6 +8,7 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.resource.bitmap.DownsampleStrategy
import com.bumptech.glide.request.RequestOptions
import io.legato.kazusa.R
import io.legato.kazusa.base.BaseBottomSheetDialogFragment
import io.legato.kazusa.base.BaseDialogFragment
import io.legato.kazusa.databinding.DialogPhotoViewBinding
import io.legato.kazusa.help.book.BookHelp
@@ -22,7 +23,7 @@ import io.legato.kazusa.utils.viewbindingdelegate.viewBinding
/**
* 显示图片
*/
class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) {
class PhotoDialog() : BaseBottomSheetDialogFragment(R.layout.dialog_photo_view) {
constructor(src: String, sourceOrigin: String? = null) : this() {
arguments = Bundle().apply {
@@ -33,11 +34,6 @@ class PhotoDialog() : BaseDialogFragment(R.layout.dialog_photo_view) {
private val binding by viewBinding(DialogPhotoViewBinding::bind)
override fun onStart() {
super.onStart()
setLayout(1f, ViewGroup.LayoutParams.MATCH_PARENT)
}
@SuppressLint("CheckResult")
override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
val arguments = arguments ?: return
+35 -3
View File
@@ -1,12 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="wrap_content"
android:paddingHorizontal="16dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:id="@+id/header_layout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:paddingHorizontal="16dp"
android:paddingBottom="8dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.bottomsheet.BottomSheetDragHandleView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal" />
<TextView
android:id="@+id/bottom_sheet_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="图片显示"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
<io.legato.kazusa.ui.widget.image.PhotoView
android:id="@+id/photo_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/header_layout"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:scaleType="centerInside" />
</androidx.constraintlayout.widget.ConstraintLayout>
+21 -10
View File
@@ -1,19 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
app:strokeWidth="0dp"
app:cardBackgroundColor="?attr/colorSurfaceContainer">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
app:flexDirection="row"
app:flexWrap="wrap"
app:layoutManager="com.google.android.flexbox.FlexboxLayoutManager" />
android:padding="8dp"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
app:flexDirection="row"
app:flexWrap="wrap"
app:layoutManager="com.google.android.flexbox.FlexboxLayoutManager" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
</LinearLayout>