Interface DocumentCoordinator
-
- All Implemented Interfaces:
public interface DocumentCoordinator
Coordinates loading and display of multiple documents in com.pspdfkit.ui.PdfActivity. Use it to modify the list of loaded documents and to switch between them.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
DocumentCoordinator.OnDocumentsChangedListener
Listener for changes made to documents managed by DocumentCoordinator.
public interface
DocumentCoordinator.OnDocumentVisibleListener
Listener for document becoming visible in the DocumentCoordinator.
public interface
DocumentCoordinator.OnDocumentCoordinatorEmptyListener
Listener for the last document being removed from the DocumentCoordinator.
-
Method Summary
Modifier and Type Method Description abstract void
addOnDocumentsChangedListener(@NonNull() DocumentCoordinator.OnDocumentsChangedListener listener)
Registers a OnDocumentsChangedListener to get notified when items in document coordinator change. abstract void
removeOnDocumentsChangedListener(@NonNull() DocumentCoordinator.OnDocumentsChangedListener listener)
Removes a previously registered OnDocumentsChangedListener. abstract void
addOnDocumentVisibleListener(@NonNull() DocumentCoordinator.OnDocumentVisibleListener listener)
Registers a OnDocumentVisibleListener to get notified when document gets visible in the manager. abstract void
removeOnDocumentVisibleListener(@NonNull() DocumentCoordinator.OnDocumentVisibleListener listener)
Removes a previously registered OnDocumentVisibleListener. abstract void
addOnDocumentCoordinatorEmptyListener(@NonNull() DocumentCoordinator.OnDocumentCoordinatorEmptyListener listener)
Registers a OnDocumentCoordinatorEmptyListener to get notified when document gets visible in the manager. abstract void
removeOnDocumentCoordinatorEmptyListener(@NonNull() DocumentCoordinator.OnDocumentCoordinatorEmptyListener listener)
Removes a previously registered OnDocumentCoordinatorEmptyListener. abstract boolean
setDocument(@NonNull() DocumentDescriptor documentDescriptor)
Replaces currently visible document with another document. abstract boolean
addDocument(@NonNull() DocumentDescriptor documentDescriptor)
Inserts a new document at the end of the documents list. abstract boolean
addDocument(@NonNull() DocumentDescriptor documentDescriptor, int index)
Inserts a new document at the specified index. abstract boolean
addDocumentAfterVisibleDocument(@NonNull() DocumentDescriptor documentDescriptor)
Inserts a document after the current visible document. abstract boolean
removeDocument(@NonNull() DocumentDescriptor documentDescriptor)
Removes the document if it's managed by this coordinator. abstract boolean
removeAllDocuments()
Removes all documents managed by this coordinator. abstract boolean
removeAllDocumentsExceptVisible()
Removes all documents managed by this coordinator except for the currently visible one. abstract boolean
moveDocument(@NonNull() DocumentDescriptor documentToMove, int targetIndex)
Moves documents in the document list to specified position. abstract List<DocumentDescriptor>
getDocuments()
Returns all documents managed by this coordinator. abstract boolean
setVisibleDocument(@NonNull() DocumentDescriptor visibleDocument)
Changes currently visible document. abstract DocumentDescriptor
getVisibleDocument()
Returns currently visible document (if any). -
-
Method Detail
-
addOnDocumentsChangedListener
abstract void addOnDocumentsChangedListener(@NonNull() DocumentCoordinator.OnDocumentsChangedListener listener)
Registers a OnDocumentsChangedListener to get notified when items in document coordinator change. If the listener has been registered previously, this method will be a no-op.
- Parameters:
listener
- Listener to register.
-
removeOnDocumentsChangedListener
abstract void removeOnDocumentsChangedListener(@NonNull() DocumentCoordinator.OnDocumentsChangedListener listener)
Removes a previously registered OnDocumentsChangedListener. If the listener hasn't been registered previously, this method will be a no-op.
- Parameters:
listener
- Listener to unregister.
-
addOnDocumentVisibleListener
abstract void addOnDocumentVisibleListener(@NonNull() DocumentCoordinator.OnDocumentVisibleListener listener)
Registers a OnDocumentVisibleListener to get notified when document gets visible in the manager. If the listener has been registered previously, this method will be a no-op.
- Parameters:
listener
- Listener to register.
-
removeOnDocumentVisibleListener
abstract void removeOnDocumentVisibleListener(@NonNull() DocumentCoordinator.OnDocumentVisibleListener listener)
Removes a previously registered OnDocumentVisibleListener. If the listener hasn't been registered previously, this method will be a no-op.
- Parameters:
listener
- Listener to unregister.
-
addOnDocumentCoordinatorEmptyListener
abstract void addOnDocumentCoordinatorEmptyListener(@NonNull() DocumentCoordinator.OnDocumentCoordinatorEmptyListener listener)
Registers a OnDocumentCoordinatorEmptyListener to get notified when document gets visible in the manager. If the listener has been registered previously, this method will be a no-op.
- Parameters:
listener
- Listener to register.
-
removeOnDocumentCoordinatorEmptyListener
abstract void removeOnDocumentCoordinatorEmptyListener(@NonNull() DocumentCoordinator.OnDocumentCoordinatorEmptyListener listener)
Removes a previously registered OnDocumentCoordinatorEmptyListener. If the listener hasn't been registered previously, this method will be a no-op.
- Parameters:
listener
- Listener to unregister.
-
setDocument
@UiThread() abstract boolean setDocument(@NonNull() DocumentDescriptor documentDescriptor)
Replaces currently visible document with another document. Making this document visible immediately.
This method may only be called if onSaveInstanceState has not been called or an exception will be thrown, since after that call state loss could occur.
- Parameters:
documentDescriptor
- Document to add.- Returns:
true
when documents list has changed.
-
addDocument
@UiThread() abstract boolean addDocument(@NonNull() DocumentDescriptor documentDescriptor)
Inserts a new document at the end of the documents list. If the document already exists, it will not be added again or moved.
The document is not made visible by this method, use setVisibleDocument to make it visible.
- Parameters:
documentDescriptor
- Document to add.- Returns:
true
when documents list has changed.
-
addDocument
@UiThread() abstract boolean addDocument(@NonNull() DocumentDescriptor documentDescriptor, int index)
Inserts a new document at the specified index. If the document already exists, it will not be added again or moved.
The document is not made visible by this method, use setVisibleDocument to make it visible.
- Parameters:
documentDescriptor
- Document to add.index
- Index at which the document should be inserted.- Returns:
true
when documents list has changed.
-
addDocumentAfterVisibleDocument
@UiThread() abstract boolean addDocumentAfterVisibleDocument(@NonNull() DocumentDescriptor documentDescriptor)
Inserts a document after the current visible document. If the document already exists, it will not be added again or moved. This method is a no-op if no document is visible.
The document is not made visible by this method, use setVisibleDocument to make it visible.
- Parameters:
documentDescriptor
- Document to add.- Returns:
true
when documents list has changed.
-
removeDocument
@UiThread() abstract boolean removeDocument(@NonNull() DocumentDescriptor documentDescriptor)
Removes the document if it's managed by this coordinator. Next visible document will be shown after removing currently visible document.
- Parameters:
documentDescriptor
- Document to remove.- Returns:
true
when documents list has changed.
-
removeAllDocuments
@UiThread() abstract boolean removeAllDocuments()
Removes all documents managed by this coordinator.
- Returns:
true
when the document list has changed.
-
removeAllDocumentsExceptVisible
@UiThread() abstract boolean removeAllDocumentsExceptVisible()
Removes all documents managed by this coordinator except for the currently visible one.
- Returns:
true
when the document list has changed.
-
moveDocument
@UiThread() abstract boolean moveDocument(@NonNull() DocumentDescriptor documentToMove, int targetIndex)
Moves documents in the document list to specified position.
- Parameters:
documentToMove
- Document to move.targetIndex
- Index in documents list to which the document should be moved.- Returns:
true
when documents list has changed.
-
getDocuments
@UiThread()@NonNull() abstract List<DocumentDescriptor> getDocuments()
Returns all documents managed by this coordinator.
- Returns:
List of descriptors for documents managed by this coordinator.
-
setVisibleDocument
@UiThread() abstract boolean setVisibleDocument(@NonNull() DocumentDescriptor visibleDocument)
Changes currently visible document.
This method may only be called if onSaveInstanceState has not been called or an exception will be thrown, since after that call state loss could occur.
- Parameters:
visibleDocument
- Document that should be made visible.- Returns:
true
when visible document has changed.
-
getVisibleDocument
@UiThread()@Nullable() abstract DocumentDescriptor getVisibleDocument()
Returns currently visible document (if any).
- Returns:
Descriptor of the visible document or
null
if no document is currently visible.
-
-
-
-