GlideOption
Identifies methods in GlideExtension annotated classes that extend
com.bumptech.glide.request.RequestOptions
.
All annotated methods will be added to a single
com.bumptech.glide.request.RequestOptions
implementation generated per application. Overlapping method names in different extensions may cause errors at compile time.
Static equivalents of annotated methods will also be generated.
Methods with this annotation will only be found if they belong to classes annotated with GlideExtension.
The preferred way of writing extension methods returns the provided
com.bumptech.glide.request.RequestOptions
object with one or more methods called on it. You must not return a newly instantiated com.bumptech.glide.request.RequestOptions
object as doing so my cause a ClassCastException
at runtime. Calling either
com.bumptech.glide.request.RequestOptions#autoClone()
or
com.bumptech.glide.request.RequestOptions#lock()
is safe, but unnecessary and should typically be avoided. The preferred style looks like:
{@}GlideExtension
public class MyExtension {
private MyExtension() {}
{@}GlideOption
public static RequestOptions myOption(RequestOptions options) {
return options
.optionOne()
.optionTwo();
}
}
The deprecated way of writing extension methods is simply a static void method. The
com.bumptech.glide.request.RequestOptions
object is cloned before it is passed to this method to avoid an option method returning a new instance, but using methods like
com.bumptech.glide.request.RequestOptions#clone()
or
com.bumptech.glide.request.RequestOptions#autoClone()
can result in options applied in the method being silently ignored. Prefer the new style whenever possible.
{@}GlideExtension
public class MyExtension {
private MyExtension() {}
// Deprecated! Use the new style of GlideOption extensions instead.
{@}GlideOption
public static void myOption(RequestOptions options) {
options
.optionOne()
.optionTwo();
}
}
Functions
true
to indicate that it's safe to statically memoize the result of this method using com.bumptech.glide.request.RequestOptions#autoClone()
.true
to prevent a static builder method from being generated.