InProgressShapesCompletedListener


@UiThread
interface InProgressShapesCompletedListener<CompletedShapeT : Any>


Notifies the client app when a CompletedShapeT (or more than one) has been completed on InProgressShapesView.

Summary

Public functions

open Unit
onShapesCompleted(shapes: Map<InProgressStrokeId, CompletedShapeT>)

Called when there are no longer any in-progress shapes in the InProgressShapesView for a short period.

Public functions

onShapesCompleted

open fun onShapesCompleted(shapes: Map<InProgressStrokeId, CompletedShapeT>): Unit

Called when there are no longer any in-progress shapes in the 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 android.view.View by calling its android.view.View.invalidate function and using the new CompletedShapeT data in the next call to android.view.View.onDraw.

In the same UI thread run loop as calling android.view.View.invalidate, call InProgressShapesView.removeCompletedShapes with the IDs of the strokes that are now being rendered in the other android.view.View. If that happens in a different run loop of the UI thread, there may be brief rendering errors (appearing as flickers) between InProgressShapesView and the other android.view.View - 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
shapes: Map<InProgressStrokeId, CompletedShapeT>

The finished shapes, with map iteration order in the z-order that shapes were rendered in the InProgressShapesView, from back to front. This is the same order that shapes were started with InProgressShapesView.startShape.