Class DocumentStoreStrategy
-
- All Implemented Interfaces:
public final class DocumentStoreStrategy
Provides java.io.File directories for saving Document
The structure of the document folder is the following: {documents_directory}/document UUID -------{document_name}.pdf -------{thumbnail}
-
-
Field Summary
Fields Modifier and Type Field Description private final File
documentsDir
private final List<File>
documentsFiles
-
Constructor Summary
Constructors Constructor Description DocumentStoreStrategy(Context context, SharedPreferences preferences)
-
Method Summary
Modifier and Type Method Description final File
getDocumentsDir()
final List<File>
getDocumentsFiles()
final Boolean
ensureDocumentDir(File docDir)
final File
getDocumentDir(String docId)
final Unit
ensureDocumentDirectory(String docId)
Creates directory for Document if not exists. final File
getDocumentFile(String docId, String name)
final File
getThumbnailFile(String docId)
final Unit
eraseDocument(String docId, String docName)
Deletes Document directory and all its pages from file system Use from BG thread only final Unit
eraseDocumentThumbnail(String docId)
Deletes Document thumbnail Use from BG thread only final Boolean
renameDocument(String docId, String oldName, String newName)
Renames document. final String
getUniqueName(String newName)
Recursively trying to find unique name for pdf document in pdf files directory final String
getPageImagePath(Integer pagePosition, Document document)
final Unit
migrateDocuments(String newPath, List<Document> documents)
Migrates all pdf files to directory specified in preferences PreferencesConstants.EXTERNAL_DIR or default directory Constants.DEFAULT_EXTERNAL_DIR_NAME or from external directory to internal application document directories. -
-
Constructor Detail
-
DocumentStoreStrategy
DocumentStoreStrategy(Context context, SharedPreferences preferences)
-
-
Method Detail
-
getDocumentsDir
final File getDocumentsDir()
-
getDocumentsFiles
final List<File> getDocumentsFiles()
-
ensureDocumentDir
final Boolean ensureDocumentDir(File docDir)
- Parameters:
docDir
- File to check
-
getDocumentDir
final File getDocumentDir(String docId)
-
ensureDocumentDirectory
final Unit ensureDocumentDirectory(String docId)
Creates directory for Document if not exists.
-
getDocumentFile
final File getDocumentFile(String docId, String name)
-
getThumbnailFile
final File getThumbnailFile(String docId)
-
eraseDocument
final Unit eraseDocument(String docId, String docName)
Deletes Document directory and all its pages from file system Use from BG thread only
-
eraseDocumentThumbnail
final Unit eraseDocumentThumbnail(String docId)
Deletes Document thumbnail Use from BG thread only
-
renameDocument
final Boolean renameDocument(String docId, String oldName, String newName)
Renames document. Use from BG thread only
- Parameters:
oldName
- old namenewName
- new name
-
getUniqueName
final String getUniqueName(String newName)
Recursively trying to find unique name for pdf document in pdf files directory
- Parameters:
newName
- new document name
-
getPageImagePath
final String getPageImagePath(Integer pagePosition, Document document)
-
migrateDocuments
final Unit migrateDocuments(String newPath, List<Document> documents)
Migrates all pdf files to directory specified in preferences PreferencesConstants.EXTERNAL_DIR or default directory Constants.DEFAULT_EXTERNAL_DIR_NAME or from external directory to internal application document directories.
Use from BG thread only.
- Parameters:
newPath
- new directory path.documents
- list of document which will be moved
-
-
-
-