ComposeUiSharedResources


Resource caches shared by Compose hierarchies that use the same Context, such as the caches used by painterResource to resolve drawable resources.

Share one instance between hierarchies whose Context has the same Configuration. Cached entries can depend on the configuration, so sharing an instance between different configurations can resolve the wrong resource variant.

Summary

Public constructors

ComposeUiSharedResources(initialConfiguration: Configuration)
android

Public functions

Unit

Clears all cached resources, for example in response to onTrimMemory.

android
Unit

Updates the caches for newConfiguration.

android

Public constructors

ComposeUiSharedResources

ComposeUiSharedResources(initialConfiguration: Configuration)
Parameters
initialConfiguration: Configuration

The Configuration of the Context that the hierarchies use. Later changes are reported with onConfigurationChanged.

Public functions

clear

fun clear(): Unit

Clears all cached resources, for example in response to onTrimMemory.

onConfigurationChanged

fun onConfigurationChanged(newConfiguration: Configuration): Unit

Updates the caches for newConfiguration. Entries that depend on a changed part of the configuration are removed. Any change clears the resource id cache.

Calling this again with an unchanged configuration has no effect.