Annotation events and notifications

In Nutrient Android SDK, annotation events are accessible through the PdfFragment. There, you can find the following listeners for subscription:

ListenerDescription
OnAnnotationCreationModeChangeListenerListener for annotation creation mode enter/exit.
OnAnnotationCreationModeSettingsChangeListenerListener for annotation creation mode settings changes.
OnAnnotationEditingModeChangeListenerListener for annotation editing mode enter/exit.
OnAnnotationSelectedListenerListener for annotation selection/deselection.

Most use cases should be covered by these listeners, and they can be used as such:

override fun onCreate(savedInstanceState : Bundle?) {
super.onCreate(savedInstanceState)
pdfFragment.addOnAnnotationSelectedListener(object :OnAnnotationSelectedListener {
override fun onPrepareAnnotationSelection(controller: AnnotationSelectionController, annotation: Annotation, annotationCreated: Boolean): Boolean {
// Returning `false` here would prevent the annotation from being selected.
return true
}
override fun onAnnotationSelected(annotation: Annotation, annotationCreated: Boolean) {
Log.i(TAG, "The annotation was selected.")
}
override fun onAnnotationDeselected(annotation: Annotation, reselected: Boolean) {
Log.i(TAG, "The annotation was deselected.")
}
})
pdfFragment.addOnAnnotationUpdatedListener(object: OnAnnotationUpdatedListener {
override fun onAnnotationCreated(annotation: Annotation) {
Log.i(TAG, "The annotation was created.")
}
override fun onAnnotationUpdated(annotation: Annotation) {
Log.i(TAG, "The annotation was updated.")
}
override fun onAnnotationRemoved(annotation: Annotation) {
Log.i(TAG, "The annotation was removed.")
}
})
}

For more information on editing annotations and reacting to changes, please see our how to detect annotation changes guide.