androidx.ui.res

Classes

DeferredResource

A class used for the result of the asynchronous resource loading.

FailedResource

A class represents the alternative resource due to failed to load the requested resource.

LoadedResource

A class represents the loaded resource.

PendingResource

A class represents the alternative resource due to background loading.

Resource

The base resource class for background resource loading.

Top-level functions summary

Effect<Boolean>
booleanResource(@BoolRes id: Int)

Load a boolean resource.

Effect<Color>
colorResource(@ColorRes id: Int)

Load a string resource.

Effect<Dp>
dimensionResource(@DimenRes id: Int)

Load a boolean resource.

Effect<Image>
imageResource(@DrawableRes id: Int)

Synchronously load an image resource.

Effect<IntArray>
integerArrayResource(@ArrayRes id: Int)

Load an array of integer resource.

Effect<Int>
integerResource(@IntegerRes id: Int)

Load an integer resource.

Effect<DeferredResource<Image>>
loadImageResource(id: Int, pendingImage: Image? = null, failedImage: Image? = null)

Load the image in background thread.

Effect<DeferredResource<VectorAsset>>
loadVectorResource(id: Int, pendingResource: VectorAsset? = null, failedResource: VectorAsset? = null)

Load the vector drawable in background thread.

Effect<Array<String>>
stringArrayResource(@ArrayRes id: Int)

Load a string resource.

Effect<String>
stringResource(@StringRes id: Int)

Load a string resource.

Effect<String>
stringResource(@StringRes id: Int, vararg formatArgs: Any)

Load a string resource with formatting.

Effect<VectorAsset>
vectorResource(@DrawableRes id: Int)

Effect used to load a VectorAsset from an Android resource id This is useful for querying top level properties of the VectorAsset such as it's intrinsic width and height to be able to size components based off of it's dimensions appropriately

Top-level functions

booleanResource

@CheckResult("+") fun booleanResource(@BoolRes id: Int): Effect<Boolean>

Load a boolean resource.

Parameters
id: Int the resource identifier
Return
the boolean associated with the resource

colorResource

@CheckResult("+") fun colorResource(@ColorRes id: Int): Effect<Color>

Load a string resource.

Parameters
id: Int the resource identifier
Return
the color associated with the resource

dimensionResource

@CheckResult("+") fun dimensionResource(@DimenRes id: Int): Effect<Dp>

Load a boolean resource.

Parameters
id: Int the resource identifier
Return
the dimension value associated with the resource

imageResource

@CheckResult("+") fun imageResource(@DrawableRes id: Int): Effect<Image>

Synchronously load an image resource.

Note: This API is transient and will be likely removed for encouraging async resource loading.

Parameters
id: Int the resource identifier
Return
the decoded image data associated with the resource

integerArrayResource

@CheckResult("+") fun integerArrayResource(@ArrayRes id: Int): Effect<IntArray>

Load an array of integer resource.

Parameters
id: Int the resource identifier
Return
the integer array associated with the resource

integerResource

@CheckResult("+") fun integerResource(@IntegerRes id: Int): Effect<Int>

Load an integer resource.

Parameters
id: Int the resource identifier
Return
the integer associated with the resource

loadImageResource

@CheckResult("+") fun loadImageResource(
    id: Int,
    pendingImage: Image? = null,
    failedImage: Image? = null
): Effect<DeferredResource<Image>>

Load the image in background thread.

Until resource loading complete, this function returns deferred image resource with PendingResource. Once the loading finishes, recompose is scheduled and this function will return deferred image resource with LoadedResource or FailedResource.

Parameters
id: Int the resource identifier
pendingImage: Image? = null an optional image to be used during loading instead.
failedImage: Image? = null an optional image to be used if image loading failed.
Return
the deferred image resource.

loadVectorResource

@CheckResult("+") fun loadVectorResource(
    id: Int,
    pendingResource: VectorAsset? = null,
    failedResource: VectorAsset? = null
): Effect<DeferredResource<VectorAsset>>

Load the vector drawable in background thread.

Until resource loading complete, this function returns deferred vector drawable resource with PendingResource. Once the loading finishes, recompose is scheduled and this function will return deferred vector drawable resource with LoadedResource or FailedResource.

Parameters
id: Int the resource identifier
pendingResource: VectorAsset? = null an optional resource to be used during loading instead.
failedResource: VectorAsset? = null an optional resource to be used if resource loading failed.
Return
the deferred vector drawable resource.

stringArrayResource

@CheckResult("+") fun stringArrayResource(@ArrayRes id: Int): Effect<Array<String>>

Load a string resource.

Parameters
id: Int the resource identifier
Return
the string data associated with the resource

stringResource

@CheckResult("+") fun stringResource(@StringRes id: Int): Effect<String>

Load a string resource.

Parameters
id: Int the resource identifier
Return
the string data associated with the resource

stringResource

@CheckResult("+") fun stringResource(
    @StringRes id: Int,
    vararg formatArgs: Any
): Effect<String>

Load a string resource with formatting.

Parameters
id: Int the resource identifier
vararg formatArgs: Any the format arguments
Return
the string data associated with the resource

vectorResource

@CheckResult("+") fun vectorResource(@DrawableRes id: Int): Effect<VectorAsset>

Effect used to load a VectorAsset from an Android resource id This is useful for querying top level properties of the VectorAsset such as it's intrinsic width and height to be able to size components based off of it's dimensions appropriately

Note: This API is transient and will be likely removed for encouraging async resource loading.