# 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 />

```
public final 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/androidx/activity/FullyDrawnReporter#addReporter()` or `https://developer.android.com/reference/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:

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

Or it can be manually controlled:

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

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

## Summary

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

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#addOnReportDrawnListener(kotlin.Function0)(@https://developer.android.com/reference/androidx/annotation/NonNull Function0<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> callback)` Registers `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#addOnReportDrawnListener(kotlin.Function0)` to be called when `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#reportFullyDrawn()` is called by this class. |
| `final void` | `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#addReporter()()` Adds a lock to prevent calling `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#reportFullyDrawn()`. |
| `final boolean` | `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#isFullyDrawnReported()()` Returns `true` after `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#reportFullyDrawn()` has been called or if backed by a `https://developer.android.com/reference/androidx/activity/ComponentActivity` and `https://developer.android.com/reference/androidx/activity/ComponentActivity#reportFullyDrawn()` has been called. |
| `final void` | `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#removeOnReportDrawnListener(kotlin.Function0)(@https://developer.android.com/reference/androidx/annotation/NonNull Function0<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> callback)` Removes a previously registered `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#removeOnReportDrawnListener(kotlin.Function0)` so that it won't be called when `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#reportFullyDrawn()` is called by this class. |
| `final void` | `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#removeReporter()()` Removes a lock added in `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#addReporter()`. |

## Public constructors

### FullyDrawnReporter

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

```
public FullyDrawnReporter(
    @NonNull Executor executor,
    @NonNull Function0<Unit> reportFullyDrawn
)
```

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

## Public methods

### addOnReportDrawnListener

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

```
public final void addOnReportDrawnListener(@NonNull Function0<Unit> callback)
```

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

Once `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#addOnReportDrawnListener(kotlin.Function0)` has been called, it will be removed and `https://developer.android.com/reference/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)

```
public final void addReporter()
```

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

### isFullyDrawnReported

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

```
public final boolean isFullyDrawnReported()
```

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

### removeOnReportDrawnListener

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

```
public final void removeOnReportDrawnListener(@NonNull Function0<Unit> callback)
```

Removes a previously registered `https://developer.android.com/reference/androidx/activity/FullyDrawnReporter#removeOnReportDrawnListener(kotlin.Function0)` so that it won't be called when `https://developer.android.com/reference/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)

```
public final void removeReporter()
```

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