GuidesAPI ReferenceRelease Notes
HomeLog InHome
Guides

BlazeWidgetLabel - Android

BlazeWidgetLabel builds the label expression that decides which content a widget shows. Use it to target a single label, or to combine labels with logical AND and OR conditions.

How expressions compose

All BlazeWidgetLabel methods are static, and each one returns a new BlazeWidgetLabel. You build a complex expression by nesting: create a sub-expression first, then pass it into another method as an argument.

Methods can't be chained. mustInclude("for-you").atLeastOneOf("player", "team") doesn't compile, because the methods live on the companion object rather than on the instance. To express "for-you AND (player OR team)", nest the OR inside the AND:

val playerOrTeam = BlazeWidgetLabel.atLeastOneOf("player", "team")
val forYouAndEither = BlazeWidgetLabel.mustInclude(BlazeWidgetLabel.singleLabel("for-you"), playerOrTeam)

Both mustInclude and atLeastOneOf accept either strings or other BlazeWidgetLabel expressions.

MethodLogicAccepts
singleLabel()A single labelOne string
mustInclude()AND: every operand must matchStrings or expressions
atLeastOneOf()OR: at least one operand must matchStrings or expressions

Single label

val singleLabel = BlazeWidgetLabel.singleLabel("Blue")

Matches content labeled Blue.

AND expressions

Use mustInclude when every label must be present.

val andExpression = BlazeWidgetLabel.mustInclude("Blue", "Green")

Matches only content that has both Blue and Green.

OR expressions

Use atLeastOneOf when any one of the labels is enough.

val orExpression = BlazeWidgetLabel.atLeastOneOf("Blue", "Green")

Matches content that has Blue, Green, or both.

Combining expressions

Pass expressions instead of strings to nest them.

val blueOrGreen = BlazeWidgetLabel.atLeastOneOf("Blue", "Green")
val combinedExpression = BlazeWidgetLabel.mustInclude(blueOrGreen, BlazeWidgetLabel.singleLabel("Red"))

Matches content that has Red, and also has either Blue or Green.

Nest to any depth. This example matches content that carries any two of the three labels:

val one = BlazeWidgetLabel.singleLabel("test-1")
val four = BlazeWidgetLabel.singleLabel("test-4")
val seven = BlazeWidgetLabel.singleLabel("test-7")

val anyTwo = BlazeWidgetLabel.atLeastOneOf(
    BlazeWidgetLabel.mustInclude(one, four),
    BlazeWidgetLabel.mustInclude(four, seven),
    BlazeWidgetLabel.mustInclude(one, seven)
)

Related

Labels | Labels data source | iOS


Did this page help you?