Glide: You can't start or clear loads in RequestListener or Target callbacks.

Created on 30 Oct 2017  路  2Comments  路  Source: bumptech/glide

Glide Version: 4.2.0

Device/Android Version: 7.0

Error : You can't start or clear loads in RequestListener or Target callbacks.

Code:

GlideApp.with(activity)
                    .load(transformUrl)
                    .centerCrop()
                    .thumbnail(0.1f)
                    .transition(new DrawableTransitionOptions().transition(v -> {
                        v.setScaleY(0);
                        v.setScaleX(0);
                        v.animate()
                                .scaleY(1)
                                .scaleX(1)
                                .setDuration(600)
                                .setInterpolator(INTERPOLATOR)
                                .start();
                    }))
                    .listener(
                            new RequestListener<Drawable>() {
                                @Override
                                public boolean onLoadFailed(@android.support.annotation.Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
                                    CUtils.Log(e.getCauses() + " " + e.getMessage());
                                    GlideApp.with(activity)
                                            .load(turingPic.getUrl() + Constant.PIC_QUALITY_LIST)
                                            .centerCrop()
                                            .thumbnail(0.1f)
                                            .transition(new DrawableTransitionOptions().transition(v -> {
                                                v.setScaleY(0);
                                                v.setScaleX(0);
                                                v.animate()
                                                        .scaleY(1)
                                                        .scaleX(1)
                                                        .setDuration(600)
                                                        .setInterpolator(INTERPOLATOR)
                                                        .start();
                                            }))
                                            .into(view);
                                    return false;
                                }

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

How could Glide reload other url when onLoadFailed call ??? Please help, thanks!

question stale

Most helpful comment

Follow the suggestion in the exception message and post a Runnable to the main thread that starts your request:

Handler handler = new Handler();
...
@Override
public boolean onLoadFailed(@android.support.annotation.Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
  handler.post(new Runnable() {
    @Override
    public void run() {
      Glide.with(...)
    }
  }
};

In 4.3.0 or the snapshot, you can use error() instead.

All 2 comments

Follow the suggestion in the exception message and post a Runnable to the main thread that starts your request:

Handler handler = new Handler();
...
@Override
public boolean onLoadFailed(@android.support.annotation.Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
  handler.post(new Runnable() {
    @Override
    public void run() {
      Glide.with(...)
    }
  }
};

In 4.3.0 or the snapshot, you can use error() instead.

This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MrFuFuFu picture MrFuFuFu  路  3Comments

sergeyfitis picture sergeyfitis  路  3Comments

Anton111111 picture Anton111111  路  3Comments

technoir42 picture technoir42  路  3Comments

billy2271 picture billy2271  路  3Comments