# InProgressShapesCompletedListener

Artifact: [androidx.ink:ink-authoring](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/authoring/InProgressShapesCompletedListener.kt+class:androidx.ink.authoring.InProgressShapesCompletedListener) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

*** ** * ** ***


```
@ExperimentalInkCustomShapeWorkflowApi
@UiThread
public interface InProgressShapesCompletedListener<CompletedShapeT extends Object>
```

<br />

*** ** * ** ***

Notifies the client app when a `https://developer.android.com/reference/androidx/ink/authoring/InProgressShapesCompletedListener` (or more than one) has been completed on `https://developer.android.com/reference/androidx/ink/authoring/InProgressShapesView`.

## Summary

| ### Public methods |
|---|---|
| `default void` | `https://developer.android.com/reference/androidx/ink/authoring/InProgressShapesCompletedListener#onShapesCompleted(kotlin.collections.Map)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/authoring/InProgressStrokeId, @https://developer.android.com/reference/androidx/annotation/NonNull CompletedShapeT> shapes )` Called when there are no longer any in-progress shapes in the `https://developer.android.com/reference/androidx/ink/authoring/InProgressShapesView` for a short period. |

## Public methods

### onShapesCompleted

```
default void onShapesCompleted(
    @NonNull Map<@NonNull InProgressStrokeId, @NonNull CompletedShapeT> shapes
)
```

Called when there are no longer any in-progress shapes in the `https://developer.android.com/reference/androidx/ink/authoring/InProgressShapesView` for a short period. All shapes that were in progress simultaneously will be delivered in the same callback, running on the UI thread.

An implementation of this function should start rendering the given shapes in an `https://developer.android.com/reference/android/view/View.html` by calling its `https://developer.android.com/reference/android/view/View.html#invalidate()` function and using the new `https://developer.android.com/reference/androidx/ink/authoring/InProgressShapesCompletedListener` data in the next call to `https://developer.android.com/reference/android/view/View.html#onDraw(android.graphics.Canvas)`.

In the same UI thread run loop as calling `https://developer.android.com/reference/android/view/View.html#invalidate()`, call `https://developer.android.com/reference/androidx/ink/authoring/InProgressShapesView#removeCompletedShapes(kotlin.collections.Set)` with the IDs of the strokes that are now being rendered in the other `https://developer.android.com/reference/android/view/View.html`. If that happens in a different run loop of the UI thread, there may be brief rendering errors (appearing as flickers) between `https://developer.android.com/reference/androidx/ink/authoring/InProgressShapesView` and the other `https://developer.android.com/reference/android/view/View.html` - either a gap where the shape is not drawn during a frame, or a double draw where the shape is drawn twice and translucent strokes appear more opaque than they should.

Example:

```
public fun onShapesCompleted(shapes: Map<InProgressStrokeId, MyCompletedShape>) {
  view.addShapes(shapes.values)
  view.invalidate()
  inProgressShapesView.removeCompletedShapes(shapes.keys)
}
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/Map.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/authoring/InProgressStrokeId, @https://developer.android.com/reference/androidx/annotation/NonNull CompletedShapeT> shapes` | The finished shapes, with map iteration order in the z-order that shapes were rendered in the `https://developer.android.com/reference/androidx/ink/authoring/InProgressShapesView`, from back to front. This is the same order that shapes were started with `https://developer.android.com/reference/androidx/ink/authoring/InProgressShapesView#startShape(android.view.MotionEvent,kotlin.Int,kotlin.Any,android.graphics.Matrix,android.graphics.Matrix)`. |