GlideApp
is actually Generated API.
Glide v4 uses an annotation processor to generate an API that allows applications to access all options in RequestBuilder, RequestOptions and any included integration libraries in a single fluent API.
The generated API serves two purposes:
- Integration libraries can extend Glide’s API with custom options.
- Applications can extend Glide’s API by adding methods that bundle commonly used options.
Although both of these tasks can be accomplished by hand by writing custom subclasses of RequestOptions, doing so is challenging and produces a less fluent API.
To enable GlideApp - Generated API
Include Glide
compiler in app module's build.gradle
.
apply plugin: 'kotlin-kapt'
dependencies {
...
implementation 'com.github.bumptech.glide:glide:4.7.1'
kapt 'com.github.bumptech.glide:compiler:4.7.1'
}
Include a GlideModule
class.
import com.bumptech.glide.annotation.GlideModuleimport com.bumptech.glide.module.AppGlideModule@GlideModuleclass GlideModule : AppGlideModule()
Glide vs GlideApp
GlideApp.with(this) .load(file) .placeholder(R.drawable.placeholder_transparent_100) .circleCrop() .fitCenter() .override(100) .into(imageView)
Glide.with(this) .load(file) .apply(RequestOptions() .placeholder(R.drawable.placeholder_transparent_100) .circleCrop() .fitCenter() .override(100)) .into(imageView)