Glide vs GlideApp 4+: Override, Placeholder and Transformation (Kotlin)

Jun 19, 2018

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)

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.