ResourcesLoader

public class ResourcesLoader
extends Object

java.lang.Object
   ↳ 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

ResourcesLoader()

Public methods

void addProvider(ResourcesProvider resourcesProvider)

Appends a provider to the end of the provider list.

void clearProviders()

Removes all ResourcesProvider(s).

List<ResourcesProvider> getProviders()

Retrieves the list of providers loaded into this instance.

void removeProvider(ResourcesProvider resourcesProvider)

Removes a provider from the provider list.

void setProviders(List<ResourcesProvider> resourcesProviders)

Sets the list of providers.

Inherited methods

Public constructors

ResourcesLoader

public ResourcesLoader ()

Public methods

addProvider

Added in API level 30
public void addProvider (ResourcesProvider resourcesProvider)

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
public void clearProviders ()

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
public List<ResourcesProvider> getProviders ()

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.

Returns
List<ResourcesProvider> This value cannot be null.

removeProvider

Added in API level 30
public void removeProvider (ResourcesProvider resourcesProvider)

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
public void setProviders (List<ResourcesProvider> resourcesProviders)

Sets the list of providers.

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

Parameters
resourcesProviders List: the new providers This value cannot be null.