Can't use waitForLayout method with RecyclerView ViewHolder
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
**Glide Version**:
4.8.0
**Issue details / Repro steps / Use case background**:
I'm trying to use waitForLayout flag to load image into ImageView inside RecyclerView's ViewHolder , because my ImageViews may be of different sizes. I used the following method in onBindViewHolder which worked fine:
```java
Glide.with(fragment)
.load(urls.get(position))
.into(new DrawableImageViewTarget(imageView, /*waitForLayout=*/ true));
```
However, ViewTarget constructor which takes waitForLayout parameter is deprecated now, so i switched to the following version:
```java
Glide.with(fragment)
.load(urls.get(position))
.into(imageView)
.waitForLayout();
```
Unfortunately, some of my images sizes seem to be incorrect after that change. My guess is that in the second case getSize method in ViewTarget class and subsequent size assumptions (in getTargetDimen method) happen before the waitForLayout flag in SizeDeterminer is set. When using the first version this flag is set immediately and everything works as expected.
My question is whether these 2 approaches (waitForLayout method and deprecated constructor) are supposed to work in the same way or am i doing something wrong?
Contributor guide
Assessment
This issue has not been assessed yet.