# FullyDrawnReporter

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/FullyDrawnReporter.kt+class:androidx.activity.FullyDrawnReporter) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/activity#1.7.0)

*** ** * ** ***

<br />

```
class FullyDrawnReporter
```

<br />

*** ** * ** ***

Manages when to call `https://developer.android.com/reference/android/app/Activity.html#reportFullyDrawn()`. Different parts of the UI may individually indicate when they are ready for interaction. `https://developer.android.com/reference/android/app/Activity.html#reportFullyDrawn()` will only be called by this class when all parts are ready. At least one `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#addReporter()` or `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.FullyDrawnReporter).reportWhenComplete(kotlin.coroutines.SuspendFunction0)` must be used before `https://developer.android.com/reference/android/app/Activity.html#reportFullyDrawn()` will be called by this class.

For example, to use coroutines:

```kotlin
val fullyDrawnReporter = componentActivity.fullyDrawnReporter
launch {
    fullyDrawnReporter.reportWhenComplete {
        dataLoadedMutex.lock()
        dataLoadedMutex.unlock()
    }
}
```

Or it can be manually controlled:

```kotlin
// On the UI thread:
fullyDrawnReporter.addReporter()

// Do the loading on worker thread:
fullyDrawnReporter.removeReporter()
```

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#FullyDrawnReporter(java.util.concurrent.Executor,kotlin.Function0)(executor: https://developer.android.com/reference/java/util/concurrent/Executor.html, reportFullyDrawn: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#addOnReportDrawnListener(kotlin.Function0)(callback: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Registers `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#addOnReportDrawnListener(kotlin.Function0)` to be called when `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#reportFullyDrawn()` is called by this class. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#addReporter()()` Adds a lock to prevent calling `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#reportFullyDrawn()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#removeOnReportDrawnListener(kotlin.Function0)(callback: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Removes a previously registered `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#removeOnReportDrawnListener(kotlin.Function0)` so that it won't be called when `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#reportFullyDrawn()` is called by this class. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#removeReporter()()` Removes a lock added in `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#addReporter()`. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#isFullyDrawnReported()` Returns `true` after `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#reportFullyDrawn()` has been called or if backed by a `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity` and `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity#reportFullyDrawn()` has been called. |

| ### Extension functions |
|---|---|
| `suspend inline https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter.https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#(androidx.activity.FullyDrawnReporter).reportWhenComplete(kotlin.coroutines.SuspendFunction0)(reporter: suspend () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Tells the `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter` to wait until `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.FullyDrawnReporter).reportWhenComplete(kotlin.coroutines.SuspendFunction0)` has completed before calling `https://developer.android.com/reference/android/app/Activity.html#reportFullyDrawn()`. |

## Public constructors

### FullyDrawnReporter

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/activity#1.7.0)

```
FullyDrawnReporter(executor: Executor, reportFullyDrawn: () -> Unit)
```

| Parameters |
|---|---|
| `executor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | The `https://developer.android.com/reference/java/util/concurrent/Executor.html` on which to call `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#reportFullyDrawn()`. |
| `reportFullyDrawn: () -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Will be called when all reporters have been removed. |

## Public functions

### addOnReportDrawnListener

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/activity#1.7.0)

```
fun addOnReportDrawnListener(callback: () -> Unit): Unit
```

Registers `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#addOnReportDrawnListener(kotlin.Function0)` to be called when `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#reportFullyDrawn()` is called by this class. If it has already been called, then `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#addOnReportDrawnListener(kotlin.Function0)` will be called immediately.

Once `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#addOnReportDrawnListener(kotlin.Function0)` has been called, it will be removed and `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#removeOnReportDrawnListener(kotlin.Function0)` does not need to be called to remove it.

### addReporter

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/activity#1.7.0)

```
fun addReporter(): Unit
```

Adds a lock to prevent calling `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#reportFullyDrawn()`.

### removeOnReportDrawnListener

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/activity#1.7.0)

```
fun removeOnReportDrawnListener(callback: () -> Unit): Unit
```

Removes a previously registered `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#removeOnReportDrawnListener(kotlin.Function0)` so that it won't be called when `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#reportFullyDrawn()` is called by this class.

### removeReporter

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/activity#1.7.0)

```
fun removeReporter(): Unit
```

Removes a lock added in `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#addReporter()`. When all locks have been removed, `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#reportFullyDrawn()` will be called on the next animation frame.

## Public properties

### isFullyDrawnReported

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/activity#1.7.0)

```
val isFullyDrawnReported: Boolean
```

Returns `true` after `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter#reportFullyDrawn()` has been called or if backed by a `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity` and `https://developer.android.com/reference/kotlin/androidx/activity/ComponentActivity#reportFullyDrawn()` has been called.

## Extension functions

### FullyDrawnReporter.reportWhenComplete

Artifact: [androidx.activity:activity](https://developer.android.com/jetpack/androidx/releases/activity) [View Source](https://cs.android.com/search?q=file:androidx/activity/FullyDrawnReporter.kt+function:reportWhenComplete)

```
suspend inline fun FullyDrawnReporter.reportWhenComplete(reporter: suspend () -> Unit): Unit
```

Tells the `https://developer.android.com/reference/kotlin/androidx/activity/FullyDrawnReporter` to wait until `https://developer.android.com/reference/kotlin/androidx/activity/package-summary#(androidx.activity.FullyDrawnReporter).reportWhenComplete(kotlin.coroutines.SuspendFunction0)` has completed before calling `https://developer.android.com/reference/android/app/Activity.html#reportFullyDrawn()`.