public interface

DocumentCoordinator

com.pspdfkit.ui.DocumentCoordinator

Class Overview

Coordinates loading and display of multiple documents in PdfActivity. Use it to modify the list of loaded documents and to switch between them.

Summary

Nested Classes
interface DocumentCoordinator.OnDocumentCoordinatorEmptyListener Listener for the last document being removed from the DocumentCoordinator
interface DocumentCoordinator.OnDocumentVisibleListener Listener for document becoming visible in the DocumentCoordinator
interface DocumentCoordinator.OnDocumentsChangedListener Listener for changes made to documents managed by DocumentCoordinator
Public Methods
abstract boolean addDocument(DocumentDescriptor documentDescriptor, int index)
Inserts a new document at the specified index.
abstract boolean addDocument(DocumentDescriptor documentDescriptor)
Inserts a new document at the end of the documents list.
abstract boolean addDocumentAfterVisibleDocument(DocumentDescriptor documentDescriptor)
Inserts a document after the current visible document.
abstract void addOnDocumentCoordinatorEmptyListener(DocumentCoordinator.OnDocumentCoordinatorEmptyListener listener)
Registers a DocumentCoordinator.OnDocumentCoordinatorEmptyListener to get notified when document gets visible in the manager.
abstract void addOnDocumentVisibleListener(DocumentCoordinator.OnDocumentVisibleListener listener)
Registers a DocumentCoordinator.OnDocumentVisibleListener to get notified when document gets visible in the manager.
abstract void addOnDocumentsChangedListener(DocumentCoordinator.OnDocumentsChangedListener listener)
Registers a DocumentCoordinator.OnDocumentsChangedListener to get notified when items in document coordinator change.
abstract List<DocumentDescriptor> getDocuments()
Returns all documents managed by this coordinator.
abstract DocumentDescriptor getVisibleDocument()
Returns currently visible document (if any).
abstract boolean moveDocument(DocumentDescriptor documentToMove, int targetIndex)
Moves documents in the document list to specified position.
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 removeDocument(DocumentDescriptor documentDescriptor)
Removes the document if it's managed by this coordinator.
abstract void removeOnDocumentCoordinatorEmptyListener(DocumentCoordinator.OnDocumentCoordinatorEmptyListener listener)
abstract void removeOnDocumentVisibleListener(DocumentCoordinator.OnDocumentVisibleListener listener)
Removes a previously registered DocumentCoordinator.OnDocumentVisibleListener.
abstract void removeOnDocumentsChangedListener(DocumentCoordinator.OnDocumentsChangedListener listener)
Removes a previously registered DocumentCoordinator.OnDocumentsChangedListener.
abstract boolean setDocument(DocumentDescriptor documentDescriptor)
Replaces currently visible document with another document.
abstract boolean setVisibleDocument(DocumentDescriptor visibleDocument)
Changes currently visible document.

Public Methods

public abstract boolean addDocument (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(DocumentDescriptor) 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.

public abstract boolean addDocument (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(DocumentDescriptor) to make it visible.

Parameters
documentDescriptor Document to add.
Returns
  • true when documents list has changed.

public abstract boolean addDocumentAfterVisibleDocument (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(DocumentDescriptor) to make it visible.

Parameters
documentDescriptor Document to add.
Returns
  • true when documents list has changed.

public abstract void addOnDocumentCoordinatorEmptyListener (DocumentCoordinator.OnDocumentCoordinatorEmptyListener listener)

Registers a DocumentCoordinator.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. Must be non-null.

public abstract void addOnDocumentVisibleListener (DocumentCoordinator.OnDocumentVisibleListener listener)

Registers a DocumentCoordinator.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. Must be non-null.

public abstract void addOnDocumentsChangedListener (DocumentCoordinator.OnDocumentsChangedListener listener)

Registers a DocumentCoordinator.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. Must be non-null.

public abstract List<DocumentDescriptor> getDocuments ()

Returns all documents managed by this coordinator.

Returns
  • List of descriptors for documents managed by this coordinator.

public abstract DocumentDescriptor getVisibleDocument ()

Returns currently visible document (if any).

Returns
  • Descriptor of the visible document or null if no document is currently visible.

public abstract boolean moveDocument (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.

public abstract boolean removeAllDocuments ()

Removes all documents managed by this coordinator.

Returns
  • true when the document list has changed.

public abstract boolean removeAllDocumentsExceptVisible ()

Removes all documents managed by this coordinator except for the currently visible one.

Returns
  • true when the document list has changed.

public abstract boolean removeDocument (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.
Throws
IllegalStateException if not called on the UI thread

public abstract void removeOnDocumentCoordinatorEmptyListener (DocumentCoordinator.OnDocumentCoordinatorEmptyListener listener)

Removes a previously registered DocumentCoordinator.OnDocumentCoordinatorEmptyListener. If the listener hasn't been registered previously, this method will be a no-op.

Parameters
listener Listener to unregister. Must be non-null.

public abstract void removeOnDocumentVisibleListener (DocumentCoordinator.OnDocumentVisibleListener listener)

Removes a previously registered DocumentCoordinator.OnDocumentVisibleListener. If the listener hasn't been registered previously, this method will be a no-op.

Parameters
listener Listener to unregister. Must be non-null.

public abstract void removeOnDocumentsChangedListener (DocumentCoordinator.OnDocumentsChangedListener listener)

Removes a previously registered DocumentCoordinator.OnDocumentsChangedListener. If the listener hasn't been registered previously, this method will be a no-op.

Parameters
listener Listener to unregister. Must be non-null.

public abstract boolean setDocument (DocumentDescriptor documentDescriptor)

Replaces currently visible document with another document. Making this document visible immediately.

This method may only be called if onSaveInstanceState(Bundle) 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.

public abstract boolean setVisibleDocument (DocumentDescriptor visibleDocument)

Changes currently visible document.

This method may only be called if onSaveInstanceState(Bundle) 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.