ConstraintController

abstract class ConstraintController<T> : 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
abstract Boolean

abstract Boolean
isConstrained(value: T)

Boolean

Determines if a particular WorkSpec is constrained.

open Unit
onConstraintChanged(newValue: T)

Called when the value of a constraint has changed.

Unit
replace(workSpecs: Iterable<WorkSpec>)

Replaces the list of WorkSpecs to monitor constraints for.

Unit

Clears all tracked WorkSpecs.

Properties
ConstraintController.OnConstraintUpdatedCallback?

Sets the callback to inform when constraints change.

Public methods

hasConstraint

abstract fun hasConstraint(workSpec: WorkSpec): Boolean

isConstrained

abstract fun isConstrained(value: T): Boolean

isWorkSpecConstrained

fun isWorkSpecConstrained(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
true if the WorkSpec is considered constrained

onConstraintChanged

open fun onConstraintChanged(newValue: T): Unit

Called when the value of a constraint has changed.

Parameters
newValue: T the new value of the constraint

replace

fun replace(workSpecs: Iterable<WorkSpec>): Unit

Replaces the list of WorkSpecs to monitor constraints for.

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

reset

fun reset(): Unit

Clears all tracked WorkSpecs.

Properties

callback

var callback: ConstraintController.OnConstraintUpdatedCallback?

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