Class PdfUiFragment
-
- All Implemented Interfaces:
-
android.content.ComponentCallbacks
,android.view.View.OnCreateContextMenuListener
,androidx.activity.result.ActivityResultCaller
,androidx.lifecycle.HasDefaultViewModelProviderFactory
,androidx.lifecycle.LifecycleOwner
,androidx.lifecycle.ViewModelStoreOwner
,androidx.savedstate.SavedStateRegistryOwner
,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 PdfUiFragment extends Fragment implements PdfUi
Experimental API - Might change in the future.
This fragment provides the same UI as PdfActivity. It can be used inside any view hierarchy but use is limited to one instance per Activity, unless pdfFragmentTag is used to set a unique fragment tag for each instance.
-
-
Field Summary
Fields Modifier and Type Field Description public PdfUiImpl
implementation
-
Constructor Summary
Constructors Constructor Description PdfUiFragment()
-
Method Summary
Modifier and Type Method Description PdfUiImpl
getImplementation()
Intended for internal usage only. View
onCreateView(@NonNull() LayoutInflater inflater, @Nullable() ViewGroup container, @Nullable() Bundle savedInstanceState)
void
onStart()
void
onPause()
void
onResume()
void
onStop()
void
onDestroy()
void
onSaveInstanceState(@NonNull() Bundle outState)
void
onCreateOptionsMenu(@NonNull() Menu menu, @NonNull() MenuInflater inflater)
void
onPrepareOptionsMenu(@NonNull() Menu menu)
boolean
onOptionsItemSelected(@NonNull() MenuItem item)
int
onGetShowAsAction(int menuItemId, int defaultShowAsAction)
void
onActivityResult(int requestCode, int resultCode, Intent data)
boolean
onBackPressed()
Call this from your activity to properly close the UI when pressing back. void
onSetActivityTitle(@NonNull() PdfActivityConfiguration configuration, @Nullable() PdfDocument document)
Called when activity title must be set - before and after document was loaded. void
onUserInterfaceVisibilityChanged(boolean visible)
Called when user interface visibility have changed. void
onDocumentLoaded(@NonNull() PdfDocument document)
Called when document is successfully loaded and the document view has been laid out. void
onDocumentLoadFailed(@NonNull() Throwable exception)
Called if document loading has failed. boolean
onDocumentSave(@NonNull() PdfDocument document, @NonNull() DocumentSaveOptions saveOptions)
Called before document will be saved. void
onDocumentSaved(@NonNull() PdfDocument document)
Called after the document has been saved. void
onDocumentSaveFailed(@NonNull() PdfDocument document, @NonNull() Throwable exception)
Called if document saving has failed. void
onDocumentSaveCancelled(PdfDocument document)
Called if document saving has been cancelled. boolean
onPageClick(@NonNull() PdfDocument document, int pageIndex, @Nullable() MotionEvent event, @Nullable() PointF pagePosition, @Nullable() Annotation clickedAnnotation)
Called when user taps / clicks on the page. boolean
onDocumentClick()
Called when the user taps / clicks on the document, not the page itself but on the side (if visible). void
onPageChanged(@NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)
Called when user scrolled to a new page. void
onDocumentZoomed(@NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex, float scaleFactor)
Called when a user zooms a document. void
onPageUpdated(@NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)
Called when content of page with pageIndex has changed (for example due to annotation or form field being updated). PdfActivityConfiguration
getConfiguration()
Returns the PdfActivityConfiguration that was provided while launching this pdf UI. void
setConfiguration(@NonNull() PdfActivityConfiguration configuration)
Replaces activity configuration. List<Integer>
onGenerateMenuItemIds(@NonNull() List<Integer> menuItems)
void
onConfigurationChanged(@NonNull() Configuration newConfig)
-
-
Method Detail
-
getImplementation
@NonNull() PdfUiImpl getImplementation()
Intended for internal usage only.
-
onCreateView
@Nullable() View onCreateView(@NonNull() LayoutInflater inflater, @Nullable() ViewGroup container, @Nullable() Bundle savedInstanceState)
-
onStart
void onStart()
-
onPause
void onPause()
-
onResume
void onResume()
-
onStop
void onStop()
-
onDestroy
void onDestroy()
-
onSaveInstanceState
void onSaveInstanceState(@NonNull() Bundle outState)
-
onCreateOptionsMenu
void onCreateOptionsMenu(@NonNull() Menu menu, @NonNull() MenuInflater inflater)
-
onPrepareOptionsMenu
void onPrepareOptionsMenu(@NonNull() Menu menu)
-
onOptionsItemSelected
boolean onOptionsItemSelected(@NonNull() MenuItem item)
-
onGetShowAsAction
int onGetShowAsAction(int menuItemId, int defaultShowAsAction)
-
onActivityResult
void onActivityResult(int requestCode, int resultCode, Intent data)
-
onBackPressed
boolean onBackPressed()
Call this from your activity to properly close the UI when pressing back.
- Returns:
This method returns
true
if the event was consumed and should not be processed any further.
-
onSetActivityTitle
void onSetActivityTitle(@NonNull() PdfActivityConfiguration configuration, @Nullable() PdfDocument document)
Called when activity title must be set - before and after document was loaded.
- Parameters:
configuration
- Passed activity configuration instance.document
- Loaded document.
-
onUserInterfaceVisibilityChanged
void onUserInterfaceVisibilityChanged(boolean visible)
Called when user interface visibility have changed.
- Parameters:
visible
-true
when UI interface is visible,false
when it is hidden.
-
onDocumentLoaded
void onDocumentLoaded(@NonNull() PdfDocument document)
Called when document is successfully loaded and the document view has been laid out. This has to be called on the main thread.
- Parameters:
document
- Loaded document instance.
-
onDocumentLoadFailed
void onDocumentLoadFailed(@NonNull() Throwable exception)
Called if document loading has failed.
- Parameters:
exception
- Cause of the loading failure.
-
onDocumentSave
boolean onDocumentSave(@NonNull() PdfDocument document, @NonNull() DocumentSaveOptions saveOptions)
Called before document will be saved. This callback allows cancellation of the save process.
- Parameters:
document
- Instance of document to be saved.saveOptions
- Save options to be applied to the document.- Returns:
true
if the document should be saved,false
if saving should be cancelled.
-
onDocumentSaved
void onDocumentSaved(@NonNull() PdfDocument document)
Called after the document has been saved.
- Parameters:
document
- Instance of document that was saved.
-
onDocumentSaveFailed
void onDocumentSaveFailed(@NonNull() PdfDocument document, @NonNull() Throwable exception)
Called if document saving has failed.
- Parameters:
exception
- Cause of the saving failure if applicable.
-
onDocumentSaveCancelled
void onDocumentSaveCancelled(PdfDocument document)
Called if document saving has been cancelled.
- Parameters:
document
- Instance of document that was saved.
-
onPageClick
boolean onPageClick(@NonNull() PdfDocument document, int pageIndex, @Nullable() MotionEvent event, @Nullable() PointF pagePosition, @Nullable() Annotation clickedAnnotation)
Called when user taps / clicks on the page.
- Parameters:
document
- Currently opened document.pageIndex
- Page number of the page being tapped.event
- MotionEvent that triggered this page click.pagePosition
- Tapped page position (in PDF page coordinates with origin on bottom left).clickedAnnotation
- Annotation that was tapped, ornull
if no annotation was tapped.- Returns:
true
if tap was handled by thisDocumentListener
and should not be handled by PSPDFKit anymore. If returningfalse
PSPDFKit will continue executing it's default action.
-
onDocumentClick
boolean onDocumentClick()
Called when the user taps / clicks on the document, not the page itself but on the side (if visible).
- Returns:
true
if tap is handled orfalse
if PSPDFKit should execute it's default action.
-
onPageChanged
void onPageChanged(@NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)
Called when user scrolled to a new page.
- Parameters:
document
- Currently opened document.pageIndex
- Page number of new page.
-
onDocumentZoomed
void onDocumentZoomed(@NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex, float scaleFactor)
Called when a user zooms a document.
- Parameters:
document
- Current document.pageIndex
- The number of the page that the was zoomed.scaleFactor
- The current scale factor.
-
onPageUpdated
void onPageUpdated(@NonNull() PdfDocument document, @IntRange(from = 0) int pageIndex)
Called when content of page with pageIndex has changed (for example due to annotation or form field being updated). All views displaying this page need to refresh.
- Parameters:
pageIndex
- Page index of the updated page.
-
getConfiguration
@NonNull() PdfActivityConfiguration getConfiguration()
Returns the PdfActivityConfiguration that was provided while launching this pdf UI.
- Returns:
Currently set activity configuration.
-
setConfiguration
void setConfiguration(@NonNull() PdfActivityConfiguration configuration)
Replaces activity configuration. This method restarts the pdf UI to apply new configuration.
Note: This is a no-op when configuration has not changed.
- Parameters:
configuration
- The configuration to restart pdf UI with.
-
onGenerateMenuItemIds
@NonNull() List<Integer> onGenerateMenuItemIds(@NonNull() List<Integer> menuItems)
-
onConfigurationChanged
void onConfigurationChanged(@NonNull() Configuration newConfig)
-
-
-
-