Class PdfUiFragmentBuilder
-
- All Implemented Interfaces:
public final class PdfUiFragmentBuilder extends BasePdfUiBuilder<T>
Builder used for creating an PdfUiFragment. Allows setting the document and all of the necessary configuration such as document sources, passwords, etc.
-
-
Method Summary
Modifier and Type Method Description static PdfUiFragmentBuilder
fromUri(@NonNull() Context context, @NonNull() Array<Uri> uris)
Creates a new fragment builder with document being loaded from URI. static PdfUiFragmentBuilder
fromDataProvider(@NonNull() Context context, @NonNull() Array<DataProvider> dataProviders)
Creates a new fragment builder with document being loaded from data provider. static PdfUiFragmentBuilder
fromImageUri(@NonNull() Context context, @NonNull() Uri uri)
Creates a new fragment builder with image document being loaded from Uri. static PdfUiFragmentBuilder
fromImageProvider(@NonNull() Context context, @NonNull() DataProvider dataProvider)
Creates a new fragment builder with an image document being loaded from data provider. static PdfUiFragmentBuilder
fromDocumentDescriptor(@NonNull() Context context, @NonNull() Array<DocumentDescriptor> documentDescriptor)
Creates a new fragment builder with document describe by DocumentDescriptor. static PdfUiFragmentBuilder
emptyFragment(@NonNull() Context context)
Creates a new fragment builder with no document, this is useful if you provide custom UI inside your PdfUiFragment subclass to open new documents. PdfUiFragmentBuilder
configuration(@Nullable() PdfActivityConfiguration configuration)
Sets PdfActivityConfiguration to be set on the target PdfUiFragment in which the document(s) will be displayed. PdfUiFragmentBuilder
passwords(@Nullable() Array<String> passwords)
Sets list of passwords for when the opened document is merged from several documents or for a single document. PdfUiFragmentBuilder
contentSignatures(@Nullable() Array<String> contentSignatures)
Sets list of content signatures for when the opened document is merged from several documents or for a single document. PdfUiFragmentBuilder
visibleDocument(int visibleDocumentIndex)
Sets index of the document that should be visible after opening the fragment. PdfUiFragmentBuilder
fragmentClass(@Nullable() Class<out PdfUiFragment> fragmentClass)
Sets a custom fragment
class used for document display.PdfUiFragmentBuilder
pdfFragmentTag(@Nullable() String pdfFragmentTag)
Sets a custom fragment tag to be used with the internal PdfFragment. PdfUiFragment
build()
Builds PdfUiFragment with the values provided in the PdfUiFragmentBuilder. -
-
Method Detail
-
fromUri
static PdfUiFragmentBuilder fromUri(@NonNull() Context context, @NonNull() Array<Uri> uris)
Creates a new fragment builder with document being loaded from URI. If there are multiple passed URIs, multiple documents will be loaded and merged into a single document.
- Parameters:
context
- Context of the calling component, used for fragment creation.uris
- List of URIs of the documents to merge and open, or just a single URI for a single document to be opened.- Returns:
Fragment builder with specified document URIs as the source.
-
fromDataProvider
static PdfUiFragmentBuilder fromDataProvider(@NonNull() Context context, @NonNull() Array<DataProvider> dataProviders)
Creates a new fragment builder with document being loaded from data provider. If there are multiple passed data providers, multiple documents will be loaded and merged into a single document.
- Parameters:
context
- Context of the calling component, used for fragment creation.dataProviders
- List of data providers of the documents to merge and open, or just a single data provider for a single document to be opened.- Returns:
Fragment builder with specified document data providers as the source.
-
fromImageUri
static PdfUiFragmentBuilder fromImageUri(@NonNull() Context context, @NonNull() Uri uri)
Creates a new fragment builder with image document being loaded from Uri.
- Parameters:
context
- Context of the calling component, used for fragment creation.uri
- Uri of the image document to open.- Returns:
Fragment builder with specified document Uri as the source.
-
fromImageProvider
static PdfUiFragmentBuilder fromImageProvider(@NonNull() Context context, @NonNull() DataProvider dataProvider)
Creates a new fragment builder with an image document being loaded from data provider.
- Parameters:
context
- Context of the calling component, used for fragment creation.dataProvider
- Data provider of the image documents to open.- Returns:
Fragment builder with specified image document data provider as the source.
-
fromDocumentDescriptor
@NonNull() static PdfUiFragmentBuilder fromDocumentDescriptor(@NonNull() Context context, @NonNull() Array<DocumentDescriptor> documentDescriptor)
Creates a new fragment builder with document describe by DocumentDescriptor. If there are multiple passed document descriptors, documents for these descriptors will be displayed as tabs.
- Parameters:
context
- Context of the calling component, used for fragment creation.documentDescriptor
- List of document descriptors for documents that should be displayed in the PdfUiFragment.- Returns:
Fragment builder instance.
-
emptyFragment
@NonNull() static PdfUiFragmentBuilder emptyFragment(@NonNull() Context context)
Creates a new fragment builder with no document, this is useful if you provide custom UI inside your PdfUiFragment subclass to open new documents.
- Parameters:
context
- Context of the calling component, used for fragment creation.- Returns:
Fragment builder instance.
-
configuration
@NonNull() PdfUiFragmentBuilder configuration(@Nullable() PdfActivityConfiguration configuration)
Sets PdfActivityConfiguration to be set on the target PdfUiFragment in which the document(s) will be displayed. If
null
the default configuration will be set.- Parameters:
configuration
- Activity configuration to be set on the target PdfUiFragment.- Returns:
Builder for PdfUiFragmentBuilder with set activity configuration.
-
passwords
@NonNull() PdfUiFragmentBuilder passwords(@Nullable() Array<String> passwords)
Sets list of passwords for when the opened document is merged from several documents or for a single document. The positions of password strings in the list must correspond to positions of URIs or data providers passed in fromUri} or fromDataProvider.
- Parameters:
passwords
- List of document passwords, has to be the same size as the list of URIs or data providers.- Returns:
Builder for PdfUiFragmentBuilder with declared document password(s).
-
contentSignatures
@NonNull() PdfUiFragmentBuilder contentSignatures(@Nullable() Array<String> contentSignatures)
Sets list of content signatures for when the opened document is merged from several documents or for a single document. The positions of content signature strings in the list must correspond to positions of URIs or data providers passed in fromUri} or fromDataProvider.
- Parameters:
contentSignatures
- List of document content signatures, has to be the same size as the list of URIs or data providers.- Returns:
Builder for PdfUiFragmentBuilder with declared document content signature(s).
-
visibleDocument
@NonNull() PdfUiFragmentBuilder visibleDocument(int visibleDocumentIndex)
Sets index of the document that should be visible after opening the fragment. This is only valid when builder has been created with multiple documents via fromDocumentDescriptor.
- Parameters:
visibleDocumentIndex
- Index of the visible document.- Returns:
Instance of this builder.
-
fragmentClass
@NonNull() PdfUiFragmentBuilder fragmentClass(@Nullable() Class<out PdfUiFragment> fragmentClass)
Sets a custom
fragment
class used for document display. Thefragment
must extend PdfUiFragment. Ifnull
is passed, the default PdfUiFragment will be used for document display.- Parameters:
fragmentClass
- Custom PdfUiFragment subclass, ornull
for the default fragment to be used.- Returns:
Builder for PdfUiFragmentBuilder with set fragment subclass.
-
pdfFragmentTag
@NonNull() PdfUiFragmentBuilder pdfFragmentTag(@Nullable() String pdfFragmentTag)
Sets a custom fragment tag to be used with the internal PdfFragment. This is required when trying to host multiple fragments in the same view hierarchy.
Note: When this is set to anything other than
null
we make the assumption that this PdfUiFragment will be used next to other PdfUiFragment instances and special handling of the toolbar will be applied.Namely, when onCreateOptionsMenu, onPrepareOptionsMenu, or onOptionsItemSelected is called, the
menu
parameter will be ignored and we always use the menu provided by the main toolbar that is part of the view hierarchy.- Parameters:
pdfFragmentTag
- The custom fragment tag to use, ornull
for the default fragment tag.
-
build
@NonNull() PdfUiFragment build()
Builds PdfUiFragment with the values provided in the PdfUiFragmentBuilder.
- Returns:
An PdfUiFragment configured for displaying documents.
-
-
-
-