Browse Source

解决大图预览崩溃问题

zk 1 year ago
parent
commit
8f026d43c4

+ 1 - 1
app/src/main/java/com/datarecovery/master/module/preview/PreviewImagePagerAdapter.java

@@ -57,7 +57,7 @@ public class PreviewImagePagerAdapter extends RecyclerView.Adapter<PreviewImageP
         }
 
         public void bind(ImageDeepDetector.ImageFile imageFile) {
-            binding.previewImg.setImageURI(imageFile.getUri());
+            binding.setImageFile(imageFile);
         }
     }
 }

+ 27 - 16
app/src/main/res/layout/item_preview_img.xml

@@ -1,25 +1,36 @@
 <?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:app="http://schemas.android.com/apk/res-auto"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
+<layout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto">
 
-    <com.github.chrisbanes.photoview.PhotoView
-        android:id="@+id/preview_img"
+    <data>
+
+        <variable
+            name="imageFile"
+            type="com.datarecovery.master.utils.ImageDeepDetector.ImageFile" />
+    </data>
+
+    <FrameLayout
         android:layout_width="match_parent"
         android:layout_height="match_parent">
 
-    </com.github.chrisbanes.photoview.PhotoView>
+        <com.github.chrisbanes.photoview.PhotoView
+            android:id="@+id/preview_img"
+            imageUri="@{imageFile.uri}"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent">
 
+        </com.github.chrisbanes.photoview.PhotoView>
 
-    <com.datarecovery.master.widget.WatermarkView
-        android:id="@+id/watermark_view"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        app:watermark_color="#6d6d6d"
-        app:watermark_text="@string/export_without_watermark"
-        app:watermark_textSize="14sp">
 
-    </com.datarecovery.master.widget.WatermarkView>
+        <com.datarecovery.master.widget.WatermarkView
+            android:id="@+id/watermark_view"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            app:watermark_color="#6d6d6d"
+            app:watermark_text="@string/export_without_watermark"
+            app:watermark_textSize="14sp">
+
+        </com.datarecovery.master.widget.WatermarkView>
 
-</FrameLayout>
+    </FrameLayout>
+</layout>