# InProgressStrokesFinishedListener

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/InProgressStrokesFinishedListener.kt+class:androidx.ink.authoring.InProgressStrokesFinishedListener) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

*** ** * ** ***


```
@UiThread
public interface InProgressStrokesFinishedListener
```

<br />

*** ** * ** ***

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

## Summary

| ### Public methods |
|---|---|
| `default void` | `https://developer.android.com/reference/androidx/ink/authoring/InProgressStrokesFinishedListener#onStrokesFinished(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 https://developer.android.com/reference/androidx/ink/strokes/Stroke> strokes )` Called when there are no longer any in-progress strokes in the `https://developer.android.com/reference/androidx/ink/authoring/InProgressStrokesView` for a short period. |

## Public methods

### onStrokesFinished

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

```
default void onStrokesFinished(
    @NonNull Map<@NonNull InProgressStrokeId, @NonNull Stroke> strokes
)
```

Called when there are no longer any in-progress strokes in the `https://developer.android.com/reference/androidx/ink/authoring/InProgressStrokesView` for a short period. All strokes 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 strokes 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/strokes/Stroke` 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/InProgressStrokesView#removeFinishedStrokes(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/InProgressStrokesView` and the other `https://developer.android.com/reference/android/view/View.html` - either a gap where the stroke is not drawn during a frame, or a double draw where the stroke is drawn twice and translucent strokes appear more opaque than they should.

Example:

```
public fun onStrokesFinished(strokes: Map<InProgressStrokeId, Stroke>) {
  view.addStrokes(strokes.values)
  view.invalidate()
  inProgressStrokesView.removeFinishedStrokes(strokes.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 https://developer.android.com/reference/androidx/ink/strokes/Stroke> strokes` | The finished strokes, with map iteration order in the z-order that strokes were rendered in the `https://developer.android.com/reference/androidx/ink/authoring/InProgressStrokesView`, from back to front. This is the same order that strokes were started with `https://developer.android.com/reference/androidx/ink/authoring/InProgressStrokesView#startStroke(android.view.MotionEvent,kotlin.Int,androidx.ink.brush.Brush,android.graphics.Matrix,android.graphics.Matrix)`. |