Annotation events and notifications
In Nutrient Android SDK, annotation events are accessible through the PdfFragment
. There, you can find the following listeners for subscription:
Listener | Description |
---|---|
OnAnnotationCreationModeChangeListener | Listener for annotation creation mode enter/exit. |
OnAnnotationCreationModeSettingsChangeListener | Listener for annotation creation mode settings changes. |
OnAnnotationEditingModeChangeListener | Listener for annotation editing mode enter/exit. |
OnAnnotationSelectedListener | Listener 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.