From 0e870a0d919a28a45084a7df5f662afbfd7e086d Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 15 十二月 2020 14:44:28 +0800
Subject: [PATCH] DownloadAndSetImageTask和SetImageTask两个类由于在子线程执行,会经常出现activity关闭后继续执行导致报错崩溃问题,修复此bug
---
app/src/main/java/cn/flightfeather/thirdapp/adapter/CommonPagerAdapter.java | 31 +++++++++++++++----------------
1 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/adapter/CommonPagerAdapter.java b/app/src/main/java/cn/flightfeather/thirdapp/adapter/CommonPagerAdapter.java
index a7be5aa..15cfe38 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/adapter/CommonPagerAdapter.java
+++ b/app/src/main/java/cn/flightfeather/thirdapp/adapter/CommonPagerAdapter.java
@@ -1,20 +1,16 @@
package cn.flightfeather.thirdapp.adapter;
import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.drawable.BitmapDrawable;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;
import com.bm.library.PhotoView;
+import com.bumptech.glide.Glide;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
-
-import cn.flightfeather.thirdapp.util.ScreenUtils;
-import cn.flightfeather.thirdapp.util.photo.PhotoUtil;
/**
* Created by hyhb01 on 2018/3/26.
@@ -57,9 +53,12 @@
@Override
public Object instantiateItem(ViewGroup container, int position) {
- Bitmap bm = PhotoUtil.decodeSampledBitmapFromResource(fileList.get(position).getAbsolutePath(), ScreenUtils.getScreenWidth(context), ScreenUtils.getScreenHeight(context));
- viewList.get(position).setImageBitmap(bm);
+// Bitmap bm = PhotoUtil.decodeSampledBitmapFromResource(fileList.get(position).getAbsolutePath(), ScreenUtils.getScreenWidth(context), ScreenUtils.getScreenHeight(context));
+// viewList.get(position).setImageBitmap(bm);
+ Glide.with(container)
+ .load(fileList.get(position))
+ .into(viewList.get(position));
container.addView(viewList.get(position));
return viewList.get(position);
@@ -67,15 +66,15 @@
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
- BitmapDrawable bitmapDrawable = (BitmapDrawable) viewList.get(position).getDrawable();
- viewList.get(position).setImageDrawable(null);
- if (bitmapDrawable != null) {
- Bitmap bitmap = bitmapDrawable.getBitmap();
- if (bitmap != null) {
- bitmap.recycle();
- System.gc();
- }
- }
+// BitmapDrawable bitmapDrawable = (BitmapDrawable) viewList.get(position).getDrawable();
+// viewList.get(position).setImageDrawable(null);
+// if (bitmapDrawable != null) {
+// Bitmap bitmap = bitmapDrawable.getBitmap();
+// if (bitmap != null) {
+// bitmap.recycle();
+// System.gc();
+// }
+// }
container.removeView(viewList.get(position));
}
--
Gitblit v1.9.3