mirror of
https://github.com/TonyJiangWJ/Auto.js.git
synced 2026-06-24 21:33:16 +08:00
回收图像资源时判断bitmap是否已回收 避免重复回收导致闪退
This commit is contained in:
parent
0c23395412
commit
eb841906fa
@ -4,6 +4,7 @@ import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.media.Image;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import com.stardust.autojs.core.opencv.Mat;
|
||||
import com.stardust.autojs.core.opencv.OpenCVHelper;
|
||||
@ -140,10 +141,12 @@ public class ImageWrapper {
|
||||
return mBitmap;
|
||||
}
|
||||
|
||||
public void recycle() {
|
||||
if (mBitmap != null) {
|
||||
public synchronized void recycle() {
|
||||
if (mBitmap != null && !mBitmap.isRecycled()) {
|
||||
mBitmap.recycle();
|
||||
mBitmap = null;
|
||||
} else if (mBitmap != null && mBitmap.isRecycled()) {
|
||||
Log.d("ImageWrapper", "recycle bitmap: not null but is recycled");
|
||||
}
|
||||
if (mMat != null) {
|
||||
OpenCVHelper.release(mMat);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user