API suggestion - RequestOptions
- Dominant language
- Java
- Stars
- 35k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 8
Description
**Glide Version**: 4.5
**Integration libraries**: -
**Device/Android Version**: LL
**Issue details / Repro steps / Use case background**:
Current `RequestOptions` differentiate between one and multiple transformations. Why? I see that internally the transformations are handled by a `MultiTransformation` if multiple transformations are used, but this could be totally hidden from the user I think. Additional, currently a unnecessary `MultiTransformation` object is created if only one transformation is passed to the `transforms` function
**Suggestion**
Why not change the API to look like following (combine `transform` and `transforms`):
public RequestOptions transform(@NonNull Transformation... transformations) {
if (transformations.lengh > 1) {
return transform(new MultiTransformation<>(transformations), /*isRequired=*/ true);
} else if (transformations.lengh == 1) {
return transform(transformation, /*isRequired=*/ true);
} else {
return this;
}
}
**Usage before**
This way as a user using an array (potentially empty) I could change following:
RequestOptions ro = new RequestOptions();
if (transformations != null && transformations.size() > 0) {
if (transformations .size() == 1) {
ro = ro.transform(transformations .get(0));
} else {
ro = ro.transforms(transformations .toArray(new Transformation[transformations .size()]));
}
}
**Usage after**
RequestOptions ro = new RequestOptions();
if (transformations != null) {
ro = ro.transform(transformations .toArray(new Transformation[transformations .size()]));
}
Contributor guide
Assessment
This issue has not been assessed yet.