Скольжение занимает слишком много времени для загрузки и иногда не загружает изображения - PullRequest
0 голосов
/ 07 ноября 2019

Я загружаю несколько изображений с сервера через Glide. Я использую ViewPager, чтобы показать эти изображения. Но иногда он не загружает изображение и падает, когда я быстро прокручиваю. Я использую PhotoView вместо ImageView (для увеличения). Так как мне предотвратить эту ошибку?

        Glide.with(context).load(ApiClient.Base_URL + list.get(position).getImage())
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .dontAnimate()
                .fitCenter()
                .error(R.drawable.errorcircle128white)
                .listener(new RequestListener<Drawable>() {
                    @Override
                    public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                        lessonglideprogress.setVisibility(View.GONE);
                        return false;
                    }

                    @Override
                    public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
                        lessonglideprogress.setVisibility(View.GONE);
                        return false;
                    }
                })
                .into(photoView);

    PhotoViewAttacher pAttacher;
    pAttacher = new PhotoViewAttacher(photoView);
    pAttacher.update();

    container.addView(view);
    return view;
}

Журнал:

W/Glide: Load failed for url.jpg with size [1080x1386]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
There were 6 causes:
java.lang.OutOfMemoryError(Failed to allocate a 3725580 byte allocation with 3006928 free bytes and 2MB until OOM)
java.lang.OutOfMemoryError(Failed to allocate a 3725580 byte allocation with 3005408 free bytes and 2MB until OOM)
java.lang.OutOfMemoryError(Failed to allocate a 3725580 byte allocation with 2922632 free bytes and 2MB until OOM)
java.lang.OutOfMemoryError(Failed to allocate a 3725580 byte allocation with 2920952 free bytes and 2MB until OOM)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
java.io.IOException(java.lang.RuntimeException: setDataSource failed: status = 0x80000000)
 call GlideException#logRootCauses(String) for more detail
  Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed LoadPath{DirectByteBuffer->Object->Drawable}, REMOTE
There were 2 causes:
java.lang.OutOfMemoryError(Failed to allocate a 3725580 byte allocation with 3006928 free bytes and 2MB until OOM)
java.lang.OutOfMemoryError(Failed to allocate a 3725580 byte allocation with 3005408 free bytes and 2MB until OOM)
 call GlideException#logRootCauses(String) for more detail
    Cause (1 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->GifDrawable->Drawable}
    Cause (2 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->Bitmap->Drawable}
There was 1 cause:
java.lang.OutOfMemoryError(Failed to allocate a 3725580 byte allocation with 3006928 free bytes and 2MB until OOM)
 call GlideException#logRootCauses(String) for more detail
      Cause (1 of 1): class java.lang.OutOfMemoryError: Failed to allocate a 3725580 byte allocation with 3006928 free bytes and 2MB until OOM
    Cause (3 of 3): class com.bumptech.glide.load.engine.GlideException: Failed DecodePath{DirectByteBuffer->BitmapDrawable->Drawable}
There was 1 cause:
java.lang.OutOfMemoryError(Failed to allocate a 3725580 byte allocation with 3005408 free bytes and 2MB until OOM)
 call GlideException#logRootCauses(String) for more detail
      Cause (1 of 1): class java.lang.OutOfMemoryError: Failed to allocate a 3725580 byte allocation with 3005408 free bytes and 2MB until OOM
...