bumptech / bumptech/glide

About using custom DownSampleStrategy

Open
#5,119 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
35k
Forks
6.2k
Avg merge
1d 11h
Merged PRs (30d)
8

Description

**Glide Version:** #4.12.0

**Device/Android Version:**
Android Tiramisu

**Issue details / Repro steps / Use case background:**
I am using custom DownSampleStrategy (extends DownSampleStrategy).
When I put the new constructor in downsample() as shown in code 1 attached below,
A flickering phenomenon occurs when the change of images is notify.(RecyclerView)

If I use a static variable like number 2, there is no issue.

Do you know why,
For example, does it take a lot of memory or time to create a new DownSampleStrategy?

**The code:**
_1. using new constructor_

```
RequestOptions options = new RequestOptions().error(R.drawable.error_image);
options = options.downsample(new CustomDownSampleStrategy()).optionalTransform(new CenterCrop());

Glide.with(context)
.load(url)
.apply(options)
.into(imageView);
```

_2. using static variable_

```
private static final CustomDownSampleStrategy CUSTOM_STRATEGY = new CustomDownSampleStrategy();

RequestOptions options = new RequestOptions().error(R.drawable.error_image);
options = options.downsample(CUSTOM_STRATEGY).optionalTransform(new CenterCrop());

Glide.with(context)
.load(url)
.apply(options)
.into(imageView);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.