0

我使用 Ion 库在 RecyclerView 中加载一组 gif - 每行一个 Gif。我使用以下代码加载 gif:

@Override
public void onBindViewHolder(MyViewHolder vh, int i) {
    MyObject myObj = data.get(i);

    Ion.with(vh.imageViewGif)
            .error(R.mipmap.ic_launcher)
            .animateGif(AnimateGifMode.ANIMATE)
            .load(myObj.getGIF_URL());
}

碰巧如果我继续滚动,我会收到以下异常(OutOfMemoryError):

java.lang.OutOfMemoryError at android.graphics.Bitmap.nativeCreate(Native Method) at android.graphics.Bitmap.createBitmap(Bitmap.java:896) at android.graphics.Bitmap.createBitmap(Bitmap.java:920) at com. koushikdutta.ion.gif.GifDecoder.setPixels(GifDecoder.java:257) at com.koushikdutta.ion.gif.GifDecoder.readImage(GifDecoder.java:504) at com.koushikdutta.ion.gif.GifDecoder.nextFrame(GifDecoder. java:137) 在 com.koushikdutta.ion.IonDrawable$IonGifDecoder$1.run(IonDrawable.java:190) 在 java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) 在 java.util.concurrent.ThreadPoolExecutor$ Worker.run(ThreadPoolExecutor.java:587) 在 java.lang.Thread.run(Thread.java:841)

我该如何解决这个 OutOfMemoryError?处理内存和缓存需要 Ion 上的任何配置吗?

4

0 回答 0