ConstraintController

abstract class ConstraintController<T : Any!> : ConstraintListener<T>
kotlin.Any
   ↳ androidx.work.impl.constraints.controllers.ConstraintController

A controller for a particular constraint.

Summary

Nested classes
abstract

A callback for when a constraint changes.

Public methods
open Boolean
isWorkSpecConstrained(@NonNull workSpecId: String)

Determines if a particular WorkSpec is constrained.

open Unit
onConstraintChanged(@Nullable newValue: T?)

open Unit
replace(@NonNull workSpecs: MutableIterable<WorkSpec!>)

Replaces the list of WorkSpecs to monitor constraints for.

open Unit

Clears all tracked WorkSpecs.

open Unit

Sets the callback to inform when constraints change.

Public methods

isWorkSpecConstrained

open fun isWorkSpecConstrained(@NonNull workSpecId: String): Boolean

Determines if a particular WorkSpec is constrained. It is constrained if it is tracked by this controller, and the controller constraint was set, but not satisfied.

Parameters
workSpecId String: The ID of the WorkSpec to check if it is constrained.
Return
Boolean true if the WorkSpec is considered constrained

onConstraintChanged

open fun onConstraintChanged(@Nullable newValue: T?): Unit

replace

open fun replace(@NonNull workSpecs: MutableIterable<WorkSpec!>): Unit

Replaces the list of WorkSpecs to monitor constraints for.

Parameters
workSpecs MutableIterable<WorkSpec!>: A list of WorkSpecs to monitor constraints for

reset

open fun reset(): Unit

Clears all tracked WorkSpecs.

setCallback

open fun setCallback(@Nullable callback: ConstraintController.OnConstraintUpdatedCallback?): Unit

Sets the callback to inform when constraints change. This callback is also triggered the first time it is set.

Parameters
callback ConstraintController.OnConstraintUpdatedCallback?: The callback to inform about constraint met/unmet states