Multiple executions of the same failed target when backgrounding
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
**Glide Version**: 4.12.0
**Integration libraries**: n/a
**Device/Android Version**: Pixel 5 - API 30 emulator
**Issue details / Repro steps / Use case background**:
If an image fails to load (does not exist) then pausing and resuming the app triggers the load again
**Glide load line / `GlideModule` (if any) / list Adapter code (if any)**:
```java
package com.example.myapplication;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.RequestManager;
import com.bumptech.glide.request.target.CustomViewTarget;
import com.bumptech.glide.request.transition.Transition;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = findViewById(R.id.my_button);
ImageView img = findViewById(R.id.my_image);
btn.setOnClickListener(v -> {
RequestManager glide = Glide.with(img);
MyCustomViewTarget target = new MyCustomViewTarget(img, glide);
glide
.load("bad_file_name.png")
.into(target);
});
}
}
class MyCustomViewTarget extends CustomViewTarget {
private final RequestManager requestManager;
private int counter;
public MyCustomViewTarget(@NonNull ImageView view, RequestManager requestManager) {
super(view);
this.requestManager = requestManager;
Log.e("MY_APP", "new MyCustomViewTarget");
}
@Override
protected void onResourceCleared(@Nullable Drawable placeholder) {
}
@Override
public void onLoadFailed(@Nullable Drawable errorDrawable) {
Log.e("MY_APP", "onLoadFailed: " + counter++);
}
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition transition) {
Log.e("MY_APP", "onResourceReady");
this.view.setImageDrawable(resource);
}
}
```
**Layout XML**:
```xml
```
https://user-images.githubusercontent.com/1096616/166216185-e2a846e1-ea54-4126-9fa7-6a7f573ef150.mp4
Contributor guide
Assessment
This issue has not been assessed yet.