跳到主要内容

Released documentation snapshot. This immutable manual describes viewcompose-image-glide:0.1.0-alpha01 from source revision 79a78900. For current guidance, open the current module catalog.

Image Glide

viewcompose-image-glide is the optional Glide 5 adapter for ViewCompose image nodes. It translates the platform-neutral source and request contract into Android ImageView requests without making the renderer or widget modules depend on Glide.

Artifact and stability​

dependencies {
implementation("com.viewcompose:viewcompose-image-glide:0.1.0-alpha01")
}
  • Stability: Alpha. The adapter boundary is established; request execution follows Glide 5.
  • Platform: Android 7.0 (API 24) and newer.
  • Optional: local resources and the core renderer work without this artifact.
  • It depends on viewcompose-ui-contract and viewcompose-renderer; neither depends back on it.
  • Glide remains an implementation dependency because no Glide type appears in the adapter's public API. The application still configures Glide through its normal generated API and AppGlideModule.

Installation​

Create one GlideImageLoaderAdapter and supply it to ProvideImageLoader or the host configuration that owns image loading:

val imageLoader = GlideImageLoaderAdapter()

ProvideImageLoader(imageLoader) {
Image(
source = ImageSource.Url("https://example.test/banner.png"),
contentDescription = "Banner",
)
}

The adapter resolves Glide.with(imageView) for every request. This preserves the lifecycle scope selected by Glide for the mounted target while retaining application-owned registry, networking, cache, and default-request configuration.

Source, request, and target model​

The adapter accepts ImageSource.Resource, Url, Uri, File, and keyed Model values. Each UiImageRequest carries optional placeholder and error resource IDs plus portable decode-size, cache, transition, content-scale, and typed-extension options. Null-source fallback is resolved by the renderer before a request exists. The adapter accepts only renderer targets wrapping an Android ImageView and ignores extension types it does not own.

UiImageDecodeSize.Target preserves Glide's target-size resolution, Original maps to Target.SIZE_ORIGINAL, and fixed UiDp bounds are converted with the renderer-captured request density before Glide receives physical pixel dimensions. Content scale maps to Glide's crop, fit, inside, or no-transform request options.

Caching, transitions, and ownership​

Default cache and transition policies preserve the application's Glide configuration. Disabled memory cache maps to skipMemoryCache(true), disabled disk cache maps to DiskCacheStrategy.NONE, and explicit None or Crossfade transitions override the configured default for that request.

The adapter returns a disposable handle that clears the exact Glide target request. The renderer disposes it before replacement or mounted-node removal. The adapter does not own the target ImageView, Glide singleton, application cache, or AppGlideModule.

Testing and operations​

  • Configure authentication, model loaders, decoders, cache budgets, and observability in Glide.
  • Test fast rebinding or recycled rows so disposed requests cannot replace newer content.
  • Exercise resource, URL, URI, file, keyed-model, placeholder, error, cache, and transition paths.
  • Keep adapter-specific options in immutable typed request extensions with stable identities.

The complete generated reference is available in the viewcompose-image-glide API tree.

Compatibility notes​

The 0.1.0-alpha01 line targets Glide 5.0.7. It does not expose Glide request builders in the declarative contract, create a second cache, or replace application-level Glide configuration.