Skip to content

Commit

Permalink
fix(android): isScraped not check image type
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 authored and siguangli committed Sep 12, 2023
1 parent 4d640a6 commit 15b16a8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@

package com.openhippy.pool;

import androidx.annotation.NonNull;

public abstract class ImageRecycleObject extends RecycleObject {

public abstract void evicted();

public abstract void cached();

@NonNull
public abstract ImageDataKey getCacheKey();

public abstract boolean isScraped();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
import static com.tencent.renderer.NativeRenderException.ExceptionCode.IMAGE_DATA_DECODE_ERR;

import android.graphics.ImageDecoder;
import android.graphics.ImageDecoder.ImageInfo;
import android.graphics.ImageDecoder.OnHeaderDecodedListener;
import android.graphics.ImageDecoder.Source;
import android.os.Build.VERSION_CODES;

import androidx.annotation.RequiresApi;
Expand Down Expand Up @@ -203,15 +200,10 @@ public boolean isScraped() {
if (mDrawable != null) {
return false;
}
if (ImageDataUtils.isJpeg(mOptions)
|| ImageDataUtils.isPng(mOptions)
|| ImageDataUtils.isWebp(mOptions)) {
return mBitmap == null || mBitmap.isRecycled();
}
if (ImageDataUtils.isGif(mOptions)) {
return mGifMovie == null;
}
return true;
return mBitmap == null || mBitmap.isRecycled();
}

@Override
Expand Down Expand Up @@ -320,12 +312,7 @@ private Drawable decodeGifForTarget28(@NonNull byte[] data) throws IOException {
// will work around the issue
ImageDecoder.Source source = ImageDecoder.createSource(ByteBuffer.wrap(data));
return ImageDecoder.decodeDrawable(source,
new OnHeaderDecodedListener() {
@Override
public void onHeaderDecoded(@NonNull ImageDecoder decoder,
@NonNull ImageInfo info, @NonNull Source source1) {
}
});
(decoder, info, source1) -> {});
}

@RequiresApi(api = VERSION_CODES.P)
Expand Down

0 comments on commit 15b16a8

Please sign in to comment.