Added in API level 30

ResourcesLoader


open class ResourcesLoader
kotlin.Any
   ↳ android.content.res.loader.ResourcesLoader

A container for supplying ResourcesProvider(s) to Resources objects.

ResourcesLoader(s) are added to Resources objects to supply additional resources and assets or modify the values of existing resources and assets. Multiple Resources objects can share the same ResourcesLoaders and ResourcesProviders. Changes to the list of ResourcesProvider(s) a loader contains propagates to all Resources objects that use the loader.

Loaders must be added to Resources objects in increasing precedence order. A loader will override the resources and assets of loaders added before itself.

Providers retrieved with getProviders() are listed in increasing precedence order. A provider will override the resources and assets of providers listed before itself.

Modifying the list of providers a loader contains or the list of loaders a Resources object contains can cause lock contention with the UI thread. APIs that modify the lists of loaders or providers should only be used on the UI thread. Providers can be instantiated on any thread without causing lock contention.

Summary

Public constructors

Public methods
open Unit
addProvider(resourcesProvider: ResourcesProvider)

Appends a provider to the end of the provider list.

open Unit

Removes all ResourcesProvider(s).

open MutableList<ResourcesProvider!>

Retrieves the list of providers loaded into this instance.

open Unit
removeProvider(resourcesProvider: ResourcesProvider)

Removes a provider from the provider list.

open Unit

Sets the list of providers.

Public constructors

ResourcesLoader

ResourcesLoader()

Public methods

addProvider

Added in API level 30
open fun addProvider(resourcesProvider: ResourcesProvider): Unit

Appends a provider to the end of the provider list. If the provider is already present in the loader list, the list will not be modified.

This should only be called from the UI thread to avoid lock contention when propagating provider changes.

Parameters
resourcesProvider ResourcesProvider: the provider to add This value cannot be null.

clearProviders

Added in API level 30
open fun clearProviders(): Unit

Removes all ResourcesProvider(s).

This should only be called from the UI thread to avoid lock contention when propagating provider changes.

getProviders

Added in API level 30
open fun getProviders(): MutableList<ResourcesProvider!>

Retrieves the list of providers loaded into this instance. Providers are listed in increasing precedence order. A provider will override the values of providers listed before itself.

Return
MutableList<ResourcesProvider!> This value cannot be null.

removeProvider

Added in API level 30
open fun removeProvider(resourcesProvider: ResourcesProvider): Unit

Removes a provider from the provider list. If the provider is not present in the provider list, the list will not be modified.

This should only be called from the UI thread to avoid lock contention when propagating provider changes.

Parameters
resourcesProvider ResourcesProvider: the provider to remove This value cannot be null.

setProviders

Added in API level 30
open fun setProviders(resourcesProviders: MutableList<ResourcesProvider!>): Unit

Sets the list of providers.

This should only be called from the UI thread to avoid lock contention when propagating provider changes.

Parameters
resourcesProviders MutableList<ResourcesProvider!>: the new providers This value cannot be null.