public class

MiscUtils

extends Object
java.lang.Object
   ↳ com.pdftron.demo.utils.MiscUtils

Summary

Public Constructors
MiscUtils()
Public Methods
static SpannableString appendFavoriteHeart(Context context, String title)
static int copy(InputStream input, OutputStream output, CustomAsyncTask task)
static ExternalFileInfo extractFileFromFileSpec(Context context, ExternalFileInfo extractFolder, FileSpec fileSpec, String fileName)
static void extractFileFromFileSpec(Context context, Uri destFileUri, FileSpec fileSpec)
static String extractFileFromPortfolio(File portfolioFile, String fileName)
static String extractFileFromPortfolio(Context context, Uri portfolioFileUri, String fileName)
static Intent getAppSettingsIntent(Context context)
static SpannableStringBuilder getFileDescriptionFromUri(String uriString, Context context)
Returns description of a file a given content uri
static Uri getUriParent(Uri uri)
static void handleDocumentTreePickerResult(Activity activity, Uri treeUri, ContentResolver contentResolver, onComplete)
Handles the document tree picker intent, typically in onActivityResult.
static void handleLowMemory(Context context, BaseFileAdapter adapter)
static void handleLowMemory(Context context)
static boolean isExternalFileUri(Context context, Uri uri)
static boolean isExternalStorageDocument(Uri uri)
static boolean isIntentActionMain(Intent intent)
static boolean isPDFFile(String filename)
static void launchDocumentTreePicker(Fragment fragment)
Launches the document tree picker via intent.
static void manageOOM(Context context, PDFViewCtrl pdfViewCtrl)
static void manageOOM(Context context)
static File parseIntentGetPdfFile(Context context, Intent intent)
Given an Intent, try to parse it and get a File for the PDF document.
static void removeFiles(ArrayList<FileInfo> filesToDelete)
static void restartWithTransition(Activity activity)
static void showPermissionResultSnackbar(Activity activity, View layout, boolean hasPermission, int requestCode)
static boolean showSDCardActionErrorDialog(Context context, JumpNavigationCallbacks jumpNavigationCallbacks, String action)
static void sortDocumentFileList(List<DocumentFile> list, Comparator<DocumentFile> sortMode)
Sorts DocumentFile list according to sort setting
static void sortFileInfoList(List<FileInfo> list, Comparator<FileInfo> sortMode)
Sorts file info list according to sort setting
static void updateAdapterViewWidthAfterGlobalLayout(RecyclerView recyclerView, BaseFileAdapter adapter)
static boolean validateStringFilenameUsingIO(Context context, String filename)
static boolean verifyPermissions(int[] grantResults)
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public MiscUtils ()

Public Methods

public static SpannableString appendFavoriteHeart (Context context, String title)

public static int copy (InputStream input, OutputStream output, CustomAsyncTask task)

Throws
IOException

public static ExternalFileInfo extractFileFromFileSpec (Context context, ExternalFileInfo extractFolder, FileSpec fileSpec, String fileName)

Throws
Exception

public static void extractFileFromFileSpec (Context context, Uri destFileUri, FileSpec fileSpec)

Throws
Exception

public static String extractFileFromPortfolio (File portfolioFile, String fileName)

public static String extractFileFromPortfolio (Context context, Uri portfolioFileUri, String fileName)

public static Intent getAppSettingsIntent (Context context)

public static SpannableStringBuilder getFileDescriptionFromUri (String uriString, Context context)

Returns description of a file a given content uri

Parameters
uriString uri to a file
context context to get string resources and content resolver
Returns
  • description for file

public static Uri getUriParent (Uri uri)

public static void handleDocumentTreePickerResult (Activity activity, Uri treeUri, ContentResolver contentResolver, onComplete)

Handles the document tree picker intent, typically in onActivityResult.

Parameters
activity used to show toast
treeUri Tree Uri obtains from Intent.ACTION_OPEN_DOCUMENT_TREE
contentResolver used to obtain persistable permission
onComplete callback after document tree uri is added to database

public static void handleLowMemory (Context context, BaseFileAdapter adapter)

public static void handleLowMemory (Context context)

public static boolean isExternalFileUri (Context context, Uri uri)

public static boolean isExternalStorageDocument (Uri uri)

public static boolean isIntentActionMain (Intent intent)

public static boolean isPDFFile (String filename)

public static void launchDocumentTreePicker (Fragment fragment)

Launches the document tree picker via intent.

Parameters
fragment used to start the activity

public static void manageOOM (Context context, PDFViewCtrl pdfViewCtrl)

public static void manageOOM (Context context)

public static File parseIntentGetPdfFile (Context context, Intent intent)

Given an Intent, try to parse it and get a File for the PDF document. This will only work if the Intent action is ACTION_VIEW or ACTION_EDIT, and the Intent data is a valid PDF file scheme.

Parameters
intent the Intent that holds the data
Returns
  • a File for the PDF document

public static void removeFiles (ArrayList<FileInfo> filesToDelete)

public static void restartWithTransition (Activity activity)

public static void showPermissionResultSnackbar (Activity activity, View layout, boolean hasPermission, int requestCode)

public static boolean showSDCardActionErrorDialog (Context context, JumpNavigationCallbacks jumpNavigationCallbacks, String action)

public static void sortDocumentFileList (List<DocumentFile> list, Comparator<DocumentFile> sortMode)

Sorts DocumentFile list according to sort setting

Parameters
list A list of DocumentFile
sortMode The sort mode

public static void sortFileInfoList (List<FileInfo> list, Comparator<FileInfo> sortMode)

Sorts file info list according to sort setting

Parameters
list A list of file info
sortMode The sort mode

public static void updateAdapterViewWidthAfterGlobalLayout (RecyclerView recyclerView, BaseFileAdapter adapter)

public static boolean validateStringFilenameUsingIO (Context context, String filename)

public static boolean verifyPermissions (int[] grantResults)