我想在我的Android应用上通过滑行加载reddit gif。
但它从流错误中读取数据错误。但是这个网址工作得很好。
这是错误日志
从流
中读取数据时出错java.io.InterruptedIOException:线程被中断 在com.android.okhttp.okio.Timeout.throwIfReached(Timeout.java:145) 在com.android.okhttp.okio.Okio $ 2.read(Okio.java:133) 在com.android.okhttp.okio.AsyncTimeout $ 2.read(AsyncTimeout.java:211) 在com.android.okhttp.okio.RealBufferedSource.read(RealBufferedSource.java:50) 在com.android.okhttp.internal.http.HttpConnection $ FixedLengthSource.read(HttpConnection.java:418) 在com.android.okhttp.okio.RealBufferedSource $ 1.read(RealBufferedSource.java:371) 在java.io.FilterInputStream.read(FilterInputStream.java:133) 在com.bumptech.glide.util.ContentLengthInputStream.read(ContentLengthInputStream.java:65) 在com.bumptech.glide.util.ContentLengthInputStream.read(ContentLengthInputStream.java:60) at com.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream.fillbuf(RecyclableBufferedInputStream.java:132) at com.bumptech.glide.load.resource.bitmap.RecyclableBufferedInputStream.read(RecyclableBufferedInputStream.java:309) 在java.io.FilterInputStream.read(FilterInputStream.java:107) at com.bumptech.glide.load.resource.gif.GifResourceDecoder.inputStreamToBytes(GifResourceDecoder.java:105) 在com.bumptech.glide.load.resource.gif.GifResourceDecoder.decode(GifResourceDecoder.java:57) 在com.bumptech.glide.load.resource.gif.GifResourceDecoder.decode(GifResourceDecoder.java:26) at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceDecoder.decodeGifWrapper(GifBitmapWrapperResourceDecoder.java:101) at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceDecoder.decodeStream(GifBitmapWrapperResourceDecoder.java:87) at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceDecoder.decode(GifBitmapWrapperResourceDecoder.java:71) at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceDecoder.decode(GifBitmapWrapperResourceDecoder.java:61) at com.bumptech.glide.load.resource.gifbitmap.GifBitmapWrapperResourceDecoder.decode(GifBitmapWrapperResourceDecoder.java:22) 在com.bumptech.glide.load.engine.DecodeJob.decodeFromSourceData(DecodeJob.java:190) 在com.bumptech.glide.load.engine.DecodeJob.decodeSource(DecodeJob.java:177) 在com.bumptech.glide.load.engine.DecodeJob.decodeFromSource(DecodeJob.java:128) 在com.bumptech.glide.load.engine.EngineRunnable.decodeFromSource(EngineRunnable.java:122) 在com.bumptech.glide.load.engine.EngineRunnable.decode(EngineRunnable.java:101) 在com.bumptech.glide.load.engine.EngineRunnable.run(EngineRunnable.java:58) at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:428) 在java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:607) 在java.lang.Thread.run(Thread.java:761) at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor $ DefaultThreadFactory $ 1.run(FifoPr
Reddit GIF url example:
加载gif的GLide代码
GlideDrawableImageViewTarget imageViewPreview2 = new GlideDrawableImageViewTarget(holder.image);
Glide.with(c).load(data.getImage()).listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
return false;
}
}).fitCenter().into(imageViewPreview2);
Thanx寻求帮助