# WeightedElementsComplicationData

Artifact: [androidx.wear.watchface:watchface-complications-data](https://developer.android.com/jetpack/androidx/releases/wear-watchface) [View Source](https://cs.android.com/search?q=file:androidx/wear/watchface/complications/data/Data.kt+class:androidx.wear.watchface.complications.data.WeightedElementsComplicationData) Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

*** ** * ** ***


```
@RequiresApi(value = 33)
public final class WeightedElementsComplicationData extends ComplicationData
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.wear.watchface.complications.data.ComplicationData](https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData) ||
|   | ↳ | [androidx.wear.watchface.complications.data.WeightedElementsComplicationData](https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData) |

*** ** * ** ***

Type used for complications which want to display the breakdown of something (e.g. nutrition data) perhaps as a pie chart, or as a stacked bar chart etc. The breakdown may be accompanied by an icon and/or short text and title.

The `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#elements()` field is required for this type and is expected to always be displayed.

The `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#monochromaticImage()`, `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#smallImage()`, `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#title()`, and `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#text()` fields are optional but at least one of them must be set. The watch face may choose which of these fields to display, if any.

If a `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#monochromaticImage()` and a `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#smallImage()` are both specified then only one should be displayed. If the complication is drawn with a single color it's recommended to choose `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#monochromaticImage()` and apply a tint. If the complication is rendered with multiple colors it's recommended to choose the `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#smallImage()`. It's best practice for a ComplicationDataSource to specify both a `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#monochromaticImage()` and a `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#smallImage()`.

A data source that wants to serve a SmallImageComplicationData must include the following meta data in its manifest (NB the value is a comma separated list):

```
<meta-data android:name="android.support.wearable.complications.SUPPORTED_TYPES"
   android:value="WEIGHTED_ELEMENTS"/>
```

## Summary

| ### Nested types |
|---|
| `@https://developer.android.com/reference/androidx/annotation/RequiresApi(value = 33) public final class https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Builder` Builder for `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData`. |
| `public final class https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element` Describes a single value within a `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData`. |

| ### Public fields |
|---|---|
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element>` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#PLACEHOLDER()` Used to signal the range should be rendered as a placeholder. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationType` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#TYPE()` The `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationType` corresponding to objects of this type. |

| ### Public methods |
|---|---|
| `final https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getContentDescription()()` The content description field for accessibility. |
| `final int` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getElementBackgroundColor()()` If elements are draw as segments then this is the background color to use in between them. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element>` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getElements()()` The breakdown of the subject into various `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element`s (e.g. the proportion of calories consumed which were carbohydrates, fats, etc.). |
| `static final int` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getMaxElements()()` Returns the maximum size for `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#elements()`. |
| `final https://developer.android.com/reference/androidx/wear/watchface/complications/data/MonochromaticImage` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getMonochromaticImage()()` A simple `https://developer.android.com/reference/androidx/wear/watchface/complications/data/MonochromaticImage` image that can be tinted by the watch face. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getNextChangeInstant(java.time.Instant)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html afterInstant)` Returns the next `https://developer.android.com/reference/java/time/Instant.html` after `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#getNextChangeInstant(java.time.Instant)` at which any field of the complication may change. |
| `final https://developer.android.com/reference/androidx/wear/watchface/complications/data/SmallImage` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getSmallImage()()` A `https://developer.android.com/reference/androidx/wear/watchface/complications/data/SmallImage` that is expected to cover a small fraction of a watch face occupied by a single complication. |
| `final https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getText()()` The body `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` of the complication. |
| `final https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getTitle()()` The optional title `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText`. |
| `boolean` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#hasPlaceholderFields()()` Returns `true` if any of the fields of this ComplicationData are placeholders. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#toString()()` |

### Inherited methods

From [androidx.wear.watchface.complications.data.ComplicationData](https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData) `boolean` `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` `final https://developer.android.com/reference/android/content/ComponentName.html` `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#getDataSource()()`

The `https://developer.android.com/reference/android/content/ComponentName.html` of the `https://developer.android.com/reference/androidx/wear/watchface/complications/datasource/ComplicationDataSourceService` that provided the ComplicationData.
`final int` `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#getDisplayPolicy()()`

The `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationDisplayPolicies` for this complication.
`final https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData` `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#getDynamicValueInvalidationFallback()()`

Used in case any dynamic value has been invalidated.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/os/PersistableBundle.html` `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#getExtras()()`

A copy of any extras set by a complication provider with the privileged permission `com.google.wear.permission.SET_COMPLICATION_EXTRAS` or `https://developer.android.com/reference/android/os/PersistableBundle.html#EMPTY`.
`final int` `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#getPersistencePolicy()()`

The `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationPersistencePolicies` for this complication.
`final https://developer.android.com/reference/android/app/PendingIntent.html` `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#getTapAction()()`

The `https://developer.android.com/reference/android/app/PendingIntent.html` to send when the complication is tapped on.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationType` `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#getType()()`

The `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationType` of this complication data.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeRange` `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#getValidTimeRange()()`

The `https://developer.android.com/reference/androidx/wear/watchface/complications/data/TimeRange` within which the complication should be displayed.
`int` `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#hashCode()()` `final boolean` `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#isTapActionLostDueToSerialization()()`

`https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#tapAction()` which is a `https://developer.android.com/reference/android/app/PendingIntent.html` unfortunately can't be serialized.
`final void` `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#setTapActionLostDueToSerialization(kotlin.Boolean)(boolean value)`

`https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#tapAction()` which is a `https://developer.android.com/reference/android/app/PendingIntent.html` unfortunately can't be serialized.

## Public fields

### PLACEHOLDER

```
public static final @NonNull List<@NonNull WeightedElementsComplicationData.Element> PLACEHOLDER
```

Used to signal the range should be rendered as a placeholder. It's suggested that a placeholder ranged value be drawn as a grey arc with a percentage value selected by the renderer.

Note a placeholder may only be used in the context of `https://developer.android.com/reference/androidx/wear/watchface/complications/data/NoDataComplicationData#placeholder()`.

### TYPE

```
public static final @NonNull ComplicationType TYPE
```

The `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationType` corresponding to objects of this type.

## Public methods

### getContentDescription

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final ComplicationText getContentDescription()
```

The content description field for accessibility.

### getElementBackgroundColor

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final int getElementBackgroundColor()
```

If elements are draw as segments then this is the background color to use in between them.

### getElements

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final @NonNull List<@NonNull WeightedElementsComplicationData.Element> getElements()
```

The breakdown of the subject into various `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData.Element`s (e.g. the proportion of calories consumed which were carbohydrates, fats, etc.). The colors need to be meaningful to the user (e.g. blue is cold, yellow/red is worm), and should be consistent with the experience launched by tapping on the complication. If this is equal to `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#PLACEHOLDER()` then the renderer must display this in a visually distinct way to suggest to the user that it's placeholder data. E.g. each element is rendered in light grey. The maximum valid size of this list is provided by `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#getMaxElements()` and it will be truncated if its larger.

### getMaxElements

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public static final int getMaxElements()
```

Returns the maximum size for `https://developer.android.com/reference/androidx/wear/watchface/complications/data/WeightedElementsComplicationData#elements()`. Complications are small and if we have a very large number of elements we likely won't be able to render them properly because the individual elements will be too small on screen.

### getMonochromaticImage

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final MonochromaticImage getMonochromaticImage()
```

A simple `https://developer.android.com/reference/androidx/wear/watchface/complications/data/MonochromaticImage` image that can be tinted by the watch face. If the monochromaticImage is equal to `https://developer.android.com/reference/androidx/wear/watchface/complications/data/MonochromaticImage#PLACEHOLDER()` the renderer must treat it as a placeholder rather than rendering normally, its suggested it should be rendered as a light grey box.

### getNextChangeInstant

```
public @NonNull Instant getNextChangeInstant(@NonNull Instant afterInstant)
```

Returns the next `https://developer.android.com/reference/java/time/Instant.html` after `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData#getNextChangeInstant(java.time.Instant)` at which any field of the complication may change. If there's no scheduled changes then `https://developer.android.com/reference/java/time/Instant.html#MAX` will be returned.

See `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#getNextChangeTime(java.time.Instant)`

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/Instant.html afterInstant` | The reference `https://developer.android.com/reference/java/time/Instant.html`, after which changes will be reported. |

### getSmallImage

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final SmallImage getSmallImage()
```

A `https://developer.android.com/reference/androidx/wear/watchface/complications/data/SmallImage` that is expected to cover a small fraction of a watch face occupied by a single complication. If the smallImage is equal to `https://developer.android.com/reference/androidx/wear/watchface/complications/data/SmallImage#PLACEHOLDER()` the renderer must treat it as a placeholder rather than rendering normally, its suggested it should be rendered as a light grey box.

### getText

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final ComplicationText getText()
```

The body `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText` of the complication. The length of the text, including any time-dependent values at any valid time, is expected to not exceed seven characters. When using this text, the watch face should be able to display any string of up to seven characters (reducing the text size appropriately if the string is very wide). Although not expected, it is possible that strings of more than seven characters might be seen, in which case they may be truncated. If the text is equal to `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#PLACEHOLDER()` the renderer must treat it as a placeholder rather than rendering normally, its suggested it should be rendered as a light grey box.

### getTitle

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0)

```
public final ComplicationText getTitle()
```

The optional title `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText`. The length of the title, including any time-dependent values at any valid time, is expected to not exceed seven characters. When using this text, the watch face should be able to display any string of up to seven characters (reducing the text size appropriately if the string is very wide). Although not expected, it is possible that strings of more than seven characters might be seen, in which case they may be truncated. If the title is equal to `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#PLACEHOLDER()` the renderer must treat it as a placeholder rather than rendering normally, its suggested it should be rendered as a light grey box.

### hasPlaceholderFields

```
public boolean hasPlaceholderFields()
```

Returns `true` if any of the fields of this ComplicationData are placeholders. I.e. if any fields are equal to: `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationText#PLACEHOLDER()`, `https://developer.android.com/reference/androidx/wear/watchface/complications/data/SmallImage#PLACEHOLDER()`, `https://developer.android.com/reference/androidx/wear/watchface/complications/data/MonochromaticImage#PLACEHOLDER()`, `https://developer.android.com/reference/androidx/wear/watchface/complications/data/PhotoImageComplicationData#PLACEHOLDER()`, or `https://developer.android.com/reference/androidx/wear/watchface/complications/data/RangedValueComplicationData#PLACEHOLDER()`.

### toString

```
public @NonNull String toString()
```