Class InstantPdfActivity
-
- All Implemented Interfaces:
-
android.content.ComponentCallbacks
,android.content.ComponentCallbacks2
,android.view.KeyEvent.Callback
,android.view.LayoutInflater.Factory
,android.view.LayoutInflater.Factory2
,android.view.View.OnCreateContextMenuListener
,android.view.Window.Callback
,androidx.activity.FullyDrawnReporterOwner
,androidx.activity.OnBackPressedDispatcherOwner
,androidx.activity.contextaware.ContextAware
,androidx.activity.result.ActivityResultCaller
,androidx.activity.result.ActivityResultRegistryOwner
,androidx.appcompat.app.ActionBarDrawerToggle.DelegateProvider
,androidx.appcompat.app.AppCompatCallback
,androidx.core.app.ActivityCompat.OnRequestPermissionsResultCallback
,androidx.core.app.ActivityCompat.RequestPermissionsRequestCodeValidator
,androidx.core.app.OnMultiWindowModeChangedProvider
,androidx.core.app.OnNewIntentProvider
,androidx.core.app.OnPictureInPictureModeChangedProvider
,androidx.core.app.OnUserLeaveHintProvider
,androidx.core.app.TaskStackBuilder.SupportParentable
,androidx.core.content.OnConfigurationChangedProvider
,androidx.core.content.OnTrimMemoryProvider
,androidx.core.view.KeyEventDispatcher.Component
,androidx.core.view.MenuHost
,androidx.lifecycle.HasDefaultViewModelProviderFactory
,androidx.lifecycle.LifecycleOwner
,androidx.lifecycle.ViewModelStoreOwner
,androidx.savedstate.SavedStateRegistryOwner
,com.pspdfkit.instant.listeners.InstantDocumentListener
,com.pspdfkit.instant.listeners.InstantPdfActivityListener
,com.pspdfkit.internal.ui.menu.PdfActivityMenu.OnPrepareDefaultMenuItemListener
,com.pspdfkit.listeners.DocumentListener
,com.pspdfkit.listeners.OnMenuItemsGenerateListener
,com.pspdfkit.listeners.PdfActivityListener
,com.pspdfkit.ui.PdfActivityComponentsApi
,com.pspdfkit.ui.PdfUi
public class InstantPdfActivity extends PdfActivity implements InstantPdfActivityListener
Activity with fully integrated views and behaviour. Can be invoked by the simple helper method showInstantDocument.
For more advanced customization use InstantPdfActivityIntentBuilder to generate an Intent with proper parameters.
-
-
Constructor Summary
Constructors Constructor Description InstantPdfActivity()
-
Method Summary
Modifier and Type Method Description static void
showInstantDocument(@NonNull() Context context, @NonNull() String serverUrl, @NonNull() String jwt, @Nullable() PdfActivityConfiguration configuration)
Opens a new InstantPdfActivity displaying server document. InstantPdfDocument
getDocument()
Returns the PdfDocument that is loaded into this pdf UI, or null
if no document has been loaded yet.InstantPdfFragment
getPdfFragment()
Returns the PdfFragment that is used to show the document. InstantPdfFragment
requirePdfFragment()
Returns the PdfFragment that is used to show the document. void
onAuthenticationFailed(@NonNull() InstantPdfDocument instantDocument, @NonNull() InstantException error)
Called when authentication with Instant Server (PSPDFKit Document Engine) has failed. void
onAuthenticationFinished(@NonNull() InstantPdfDocument instantDocument, @NonNull() String validJwt)
Called when authentication with Instant Server (PSPDFKit Document Engine) has successfully finished. void
onSyncStarted(@NonNull() InstantPdfDocument instantDocument)
Called when annotation sync has been started. void
onSyncError(@NonNull() InstantPdfDocument instantDocument, @NonNull() InstantException error)
Called when annotation sync has been finished with an error. void
onSyncFinished(@NonNull() InstantPdfDocument instantDocument)
Called when annotation sync has been finished successfully. void
onDocumentStateChanged(@NonNull() InstantPdfDocument instantDocument, @NonNull() InstantDocumentState state)
Called when the document changes its state. void
onDocumentCorrupted(@NonNull() InstantPdfDocument instantDocument)
Called when InstantPdfDocument has detected data corruption. void
onDocumentInvalidated(@NonNull() InstantPdfDocument instantDocument)
Called when InstantPdfDocument becomes invalid. void
setDocument(@NonNull() String serverUrl, @NonNull() String jwt)
Loads a new Instant document in this activity and replaces the existing one. void
setDocumentFromUri(@NonNull() Uri documentUri, @Nullable() String password)
Loads a new document in this activity and replaces the existing one. void
setDocumentFromUris(@NonNull() List<Uri> documentUris, @Nullable() List<String> passwords)
Loads a new document in this activity and replaces the existing one. void
setDocumentFromDataProvider(@NonNull() DataProvider dataProvider, @Nullable() String password)
Loads a new document in this activity and replaces the existing one. void
setDocumentFromDataProviders(@NonNull() List<DataProvider> dataProviders, @Nullable() List<String> passwords)
Loads a new document in this pdf UI and replaces the existing one. DocumentCoordinator
getDocumentCoordinator()
Returns the coordinator responsible for displaying documents and switching between multiple loaded documents. -
-
Method Detail
-
showInstantDocument
static void showInstantDocument(@NonNull() Context context, @NonNull() String serverUrl, @NonNull() String jwt, @Nullable() PdfActivityConfiguration configuration)
Opens a new InstantPdfActivity displaying server document.
- Parameters:
context
- Calling contextserverUrl
- Url of the Instant Server (PSPDFKit Document Engine) - used to initialize InstantClient.jwt
- Authentication token used to authenticate access to the document.configuration
- Desired activity configuration generated with
-
getDocument
@Nullable() InstantPdfDocument getDocument()
Returns the PdfDocument that is loaded into this pdf UI, or
null
if no document has been loaded yet.- Returns:
Document loaded into the pdf UI.
-
getPdfFragment
@NonNull() InstantPdfFragment getPdfFragment()
Returns the PdfFragment that is used to show the document.
- Returns:
Current fragment for displaying the document, or
null
if no document is being displayed.
-
requirePdfFragment
@NonNull() InstantPdfFragment requirePdfFragment()
Returns the PdfFragment that is used to show the document. Throws an exception when PdfFragment is not yet initialized.
- Returns:
Current fragment for displaying the document.
-
onAuthenticationFailed
void onAuthenticationFailed(@NonNull() InstantPdfDocument instantDocument, @NonNull() InstantException error)
Called when authentication with Instant Server (PSPDFKit Document Engine) has failed.
- Parameters:
instantDocument
- Document that we were authenticating for.error
- Authentication error.
-
onAuthenticationFinished
void onAuthenticationFinished(@NonNull() InstantPdfDocument instantDocument, @NonNull() String validJwt)
Called when authentication with Instant Server (PSPDFKit Document Engine) has successfully finished.
- Parameters:
instantDocument
- Document that we were authenticating for.validJwt
- JWT that was used for this authentication request.
-
onSyncStarted
void onSyncStarted(@NonNull() InstantPdfDocument instantDocument)
Called when annotation sync has been started.
- Parameters:
instantDocument
- Document that is syncing the annotations.
-
onSyncError
void onSyncError(@NonNull() InstantPdfDocument instantDocument, @NonNull() InstantException error)
Called when annotation sync has been finished with an error.
The most likely reason is network failure REQUEST_FAILED. Other common reasons are expiration of your authentication token AUTHENTICATION_FAILED, and cancellation USER_CANCELLED.
- Parameters:
instantDocument
- Document that was syncing the annotations.error
- Error thrown while syncing annotations.
-
onSyncFinished
void onSyncFinished(@NonNull() InstantPdfDocument instantDocument)
Called when annotation sync has been finished successfully.
- Parameters:
instantDocument
- Document that was syncing the annotations.
-
onDocumentStateChanged
void onDocumentStateChanged(@NonNull() InstantPdfDocument instantDocument, @NonNull() InstantDocumentState state)
Called when the document changes its state.
Note: After onSyncStarted, this method may be called multiple times during the sync process.
- Parameters:
instantDocument
- Document which state has changed.state
- New document state.
-
onDocumentCorrupted
void onDocumentCorrupted(@NonNull() InstantPdfDocument instantDocument)
Called when InstantPdfDocument has detected data corruption.
Receiving this callback means any further interaction with the sender’s document are destined to fail. You can copy the document package aside for forensic purposes, but you will — eventually — have to purge its storage, and download it anew.
Because this situation means the document has become unusable, it will invalidate itself immediately after this method returns.
- Parameters:
instantDocument
- Document that has detected data corruption.
-
onDocumentInvalidated
void onDocumentInvalidated(@NonNull() InstantPdfDocument instantDocument)
Called when InstantPdfDocument becomes invalid. Any future instant operations on this document will fail.
- Parameters:
instantDocument
- Document that is becoming invalid.
-
setDocument
void setDocument(@NonNull() String serverUrl, @NonNull() String jwt)
Loads a new Instant document in this activity and replaces the existing one. 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:
serverUrl
- Instant Server (PSPDFKit Document Engine) url.jwt
- JWT used to authenticate access to the document.
-
setDocumentFromUri
void setDocumentFromUri(@NonNull() Uri documentUri, @Nullable() String password)
Loads a new document in this activity and replaces the existing one. 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:
documentUri
- Document URI.password
- Document password.
-
setDocumentFromUris
void setDocumentFromUris(@NonNull() List<Uri> documentUris, @Nullable() List<String> passwords)
Loads a new document in this activity and replaces the existing one. 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:
documentUris
- List of document URIs for compound document.passwords
- List of passwords for compound document, may be null.
-
setDocumentFromDataProvider
void setDocumentFromDataProvider(@NonNull() DataProvider dataProvider, @Nullable() String password)
Loads a new document in this activity and replaces the existing one. 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:
dataProvider
- Data provider for the document.password
- Document password.
-
setDocumentFromDataProviders
void setDocumentFromDataProviders(@NonNull() List<DataProvider> dataProviders, @Nullable() List<String> passwords)
Loads a new document in this pdf UI and replaces the existing one. 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:
dataProviders
- List of data providers for compound document.passwords
- List of passwords for compound document, may be null.
-
getDocumentCoordinator
@NonNull() DocumentCoordinator getDocumentCoordinator()
Returns the coordinator responsible for displaying documents and switching between multiple loaded documents.
- Returns:
DocumentCoordinator instance managing documents in this PdfUi.
-
-
-
-