-
public final class StorageHelperWrapperWrapper around the StorageHelper class, with some extra functionality that makes it easier to decouple the business logic and make it consistent.
-
-
Constructor Summary
Constructors Constructor Description StorageHelperWrapper(Context context, StorageHelper storageHelper, AttachmentFilter attachmentFilter)
-
Method Summary
Modifier and Type Method Description final List<AttachmentMetaData>getFiles()Loads a list of file metadata from the system and filters it against file types accepted by the backend. final List<AttachmentMetaData>getMedia()Loads a list of media metadata from the system. final List<Attachment>getAttachmentsForUpload(List<AttachmentMetaData> attachments)Transforms a list of AttachmentMetaData into a list of Attachments. final List<Attachment>getAttachmentsFromUris(List<Uri> uris)Takes a list of file Uris and transforms them into a list of Attachments so that we can upload them. final List<AttachmentMetaData>getAttachmentsMetadataFromUris(List<Uri> uris)Takes a list of file Uris and transforms them into a list of AttachmentMetaData. -
-
Constructor Detail
-
StorageHelperWrapper
StorageHelperWrapper(Context context, StorageHelper storageHelper, AttachmentFilter attachmentFilter)
- Parameters:
context- The context of the app, used to fetch files and media.storageHelper- The storage helper that provides all the logic required to work with the system storage.attachmentFilter- A filter that is used to filter out attachments that will not be accepted by the backend.
-
-
Method Detail
-
getFiles
final List<AttachmentMetaData> getFiles()
Loads a list of file metadata from the system and filters it against file types accepted by the backend.
-
getAttachmentsForUpload
final List<Attachment> getAttachmentsForUpload(List<AttachmentMetaData> attachments)
Transforms a list of AttachmentMetaData into a list of Attachments. This is required because we need to prepare the files for upload.
- Parameters:
attachments- The list of attachment meta data that we transform.
-
getAttachmentsFromUris
final List<Attachment> getAttachmentsFromUris(List<Uri> uris)
Takes a list of file Uris and transforms them into a list of Attachments so that we can upload them.
- Parameters:
uris- Selected file Uris, to be transformed.
-
getAttachmentsMetadataFromUris
final List<AttachmentMetaData> getAttachmentsMetadataFromUris(List<Uri> uris)
Takes a list of file Uris and transforms them into a list of AttachmentMetaData.
IMPORTANT: This method performs a potentially expensive query operation and should be called from a background thread to avoid blocking the UI.
- Parameters:
uris- Selected file Uris, to be transformed.
-
-
-
-