Class PdfDocumentCheckpointer
-
- All Implemented Interfaces:
-
com.pspdfkit.annotations.AnnotationProvider.OnAnnotationUpdatedListener
public class PdfDocumentCheckpointer implements AnnotationProvider.OnAnnotationUpdatedListener
Handles documents checkpoint, cleaning and saving strategy.
-
-
Field Summary
Fields Modifier and Type Field Description public PdfDocumentCheckpointingStrategy
strategy
-
Constructor Summary
Constructors Constructor Description PdfDocumentCheckpointer(InternalPdfDocument document, File checkpointFile, CheckpointerConfiguration configuration)
-
Method Summary
Modifier and Type Method Description PdfDocumentCheckpointingStrategy
getStrategy()
Returns the strategy used for saving the checkpoint. void
setStrategy(@NonNull() PdfDocumentCheckpointingStrategy strategy)
Sets the strategy to use for saving the checkpoint. static List<DocumentSource>
setCheckpointPath(@NonNull() Context context, @NonNull() DocumentSource documentSource, @NonNull() String checkpointFolder)
Creates a local path for saving the checkpoint file. static boolean
isCheckpointSupported(@NonNull() DocumentSource documentSource)
Returns true
if the checkpoint is supported.void
documentSavedSuccessfully()
Logs that the saving succeeded and resets the dirty status of the document to false. Single<Boolean>
saveCheckpointAsync()
Saves the checkpoint asynchronously. Single<Boolean>
deleteCheckpointAsync()
Asynchronously deletes the checkpoint. boolean
checkpointExists()
Checks if a checkpoint for the document exists. boolean
saveCheckpoint()
Saves the checkpoint persistently on the local storage. boolean
deleteCheckpoint()
Deletes the checkpoint if exists. boolean
isDirty()
Returns true
if the document has been modified since the last saving.void
deleteAllCheckpoints()
Deletes all checkpoints stored on-disk. boolean
isSaving()
Returns whether or not the checkpointer is currently saving to the document. void
onAnnotationCreated(@NonNull() Annotation annotation)
Called when annotation has been created. void
onAnnotationUpdated(@NonNull() Annotation annotation)
Called when existing annotation has changed. void
onAnnotationRemoved(@NonNull() Annotation annotation)
Called when existing annotation has been removed. void
onAnnotationZOrderChanged(int pageIndex, @NonNull() List<Annotation> oldOrder, @NonNull() List<Annotation> newOrder)
Called when the z-order of annotations has changed on a specified page. -
-
Constructor Detail
-
PdfDocumentCheckpointer
PdfDocumentCheckpointer(InternalPdfDocument document, File checkpointFile, CheckpointerConfiguration configuration)
-
-
Method Detail
-
getStrategy
@NonNull() PdfDocumentCheckpointingStrategy getStrategy()
Returns the strategy used for saving the checkpoint. See for exact behaviour. Note that MANUAL is the strategy used by default.
- Returns:
The strategy used for saving the checkpoint.
-
setStrategy
void setStrategy(@NonNull() PdfDocumentCheckpointingStrategy strategy)
Sets the strategy to use for saving the checkpoint. See for exact behaviour.
- Parameters:
strategy
- Strategy to use for saving the checkpoint.
-
setCheckpointPath
static List<DocumentSource> setCheckpointPath(@NonNull() Context context, @NonNull() DocumentSource documentSource, @NonNull() String checkpointFolder)
Creates a local path for saving the checkpoint file.
-
isCheckpointSupported
static boolean isCheckpointSupported(@NonNull() DocumentSource documentSource)
Returns
true
if the checkpoint is supported. Checkpointing is only supported for unencrypted single-source documents.- Parameters:
documentSource
- Document source to check.- Returns:
true
if checkpoint is supported,false
otherwise.
-
documentSavedSuccessfully
void documentSavedSuccessfully()
Logs that the saving succeeded and resets the dirty status of the document to false.
-
saveCheckpointAsync
@NonNull() Single<Boolean> saveCheckpointAsync()
Saves the checkpoint asynchronously.
- Scheduler:
saveCheckpointAsync
does not operate by default on a particular .
- Returns:
Single returning
true
if the checkpoint was saved,false
otherwise.
-
deleteCheckpointAsync
@NonNull() Single<Boolean> deleteCheckpointAsync()
Asynchronously deletes the checkpoint.
- Scheduler:
deleteCheckpointAsync
does not operate by default on a particular .
- Returns:
Single returning
true
if the checkpoint was deleted,false
otherwise.
-
checkpointExists
boolean checkpointExists()
Checks if a checkpoint for the document exists.
- Returns:
true
if a checkpoint exists,false
otherwise.
-
saveCheckpoint
boolean saveCheckpoint()
Saves the checkpoint persistently on the local storage.
- Returns:
true
if the checkpoint was saved successfully,false
otherwise.
-
deleteCheckpoint
boolean deleteCheckpoint()
Deletes the checkpoint if exists.
- Returns:
true
if the checkpoint was deleted,false
otherwise.
-
isDirty
boolean isDirty()
Returns
true
if the document has been modified since the last saving.- Returns:
true
if the document has been modified,false
otherwise.
-
deleteAllCheckpoints
void deleteAllCheckpoints()
Deletes all checkpoints stored on-disk.
-
isSaving
boolean isSaving()
Returns whether or not the checkpointer is currently saving to the document.
-
onAnnotationCreated
void onAnnotationCreated(@NonNull() Annotation annotation)
Called when annotation has been created.
- Parameters:
annotation
- Annotation that has been created.
-
onAnnotationUpdated
void onAnnotationUpdated(@NonNull() Annotation annotation)
Called when existing annotation has changed.
- Parameters:
annotation
- Annotation that has been changed.
-
onAnnotationRemoved
void onAnnotationRemoved(@NonNull() Annotation annotation)
Called when existing annotation has been removed.
- Parameters:
annotation
- Annotation that has been removed.
-
onAnnotationZOrderChanged
void onAnnotationZOrderChanged(int pageIndex, @NonNull() List<Annotation> oldOrder, @NonNull() List<Annotation> newOrder)
Called when the z-order of annotations has changed on a specified page.
- Parameters:
pageIndex
- Index of the page where the z-order has changed.oldOrder
- The old order of annotations on the page.newOrder
- The new order of annotations on the page.
-
-
-
-