PausedComposition


PausedComposition is the result of calling PausableComposition.setContent or PausableComposition.setContentWithReuse. It is used to drive the paused composition to completion. A PausedComposition should not be used until isComplete is true and apply has been called.

A PausedComposition is created paused and will only compose the content parameter when resume is called the first time.

Summary

Public functions

Unit

Apply the composition.

Cmn
Unit

Cancels the paused composition.

Cmn
Boolean

Resume the composition that has been paused.

Cmn

Public properties

Boolean

Returns true when the PausedComposition is complete.

Cmn

Public functions

apply

fun apply(): Unit

Apply the composition. This is the last step of a paused composition and is required to be called prior to the composition is usable.

cancel

fun cancel(): Unit

Cancels the paused composition. This should only be used if the composition is going to be disposed and the entire composition is not going to be used.

resume

fun resume(shouldPause: ShouldPauseCallback): Boolean

Resume the composition that has been paused. This method should be called until resume returns true or isComplete is true which has the same result as the last result of calling resume. The shouldPause parameter is a lambda that returns whether the composition should be paused. For example, in lazy lists this returns false until just prior to the next frame starting in which it returns true

Calling resume after it returns true or when isComplete is true will throw an exception.

Parameters
shouldPause: ShouldPauseCallback

A lambda that is used to determine if the composition should be paused. This lambda is called often so should be a very simple calculation. Returning true does not guarantee the composition will pause, it should only be considered a request to pause the composition. Not all composable functions are pausable and only pausable composition functions will pause.

Returns
Boolean

true if the composition is complete and false if one or more calls to resume are required to complete composition.

Public properties

isComplete

val isCompleteBoolean

Returns true when the PausedComposition is complete. isComplete matches the last value returned from resume. Once a PausedComposition is isComplete the apply method should be called.