Class Belvedere



  • public class Belvedere
    extends java.lang.Object
    Media picker manager.
    • Method Detail

      • from

        public static Belvedere from(Context context)
        Get the global Belvedere instance.
      • getViewIntent

        public Intent getViewIntent(Uri uri,
                                    java.lang.String contentType)
        Create an Intent for viewing an Uri.
        Parameters:
        uri - Uri pointing to a file
        contentType - (optional) the content type of the Uri
      • getShareIntent

        public Intent getShareIntent(Uri uri,
                                     java.lang.String contentType)
        Create an Intent for sharing an Uri.
        Parameters:
        uri - Uri pointing to a file
        contentType - (optional) the content type of the Uri
      • getFilesFromActivityOnResult

        public void getFilesFromActivityOnResult(int requestCode,
                                                 int resultCode,
                                                 Intent data,
                                                 Callback<java.util.List<MediaResult>> callback)
        Parse data from Activity#onActivityResult(int, int, Intent).

        It's important that the same instance of Belvedere is used, which was used to start the dialog or create the MediaIntent.

        Parameters:
        requestCode - The requestCode provided by Activity#onActivityResult(int, int, Intent)
        resultCode - The resultCode provided by Activity#onActivityResult(int, int, Intent)
        data - The Intent provided by Activity#onActivityResult(int, int, Intent)
        callback - Callback that will deliver a list of MediaResult
      • getFilesFromActivityOnResult

        public void getFilesFromActivityOnResult(int requestCode,
                                                 int resultCode,
                                                 Intent data,
                                                 Callback<java.util.List<MediaResult>> callback,
                                                 boolean resolveFiles)
        Parse data from Activity#onActivityResult(int, int, Intent).
        Parameters:
        requestCode - The requestCode provided by Activity#onActivityResult(int, int, Intent)
        resultCode - The resultCode provided by Activity#onActivityResult(int, int, Intent)
        data - The Intent provided by Activity#onActivityResult(int, int, Intent)
        callback - Callback that will deliver a list of MediaResult
        resolveFiles - Set to true if belvedere should resolve selected files
      • getFile

        public MediaResult getFile(java.lang.String dir,
                                   java.lang.String fileName)
        Returns a File and Uri for the given file name. The returned file is located in Belvedere's internal cache and can be accessed through BelvedereFileProvider.

        Belvedere doesn't keep track of your files, you have to manage them.

        Parameters:
        dir - Directory name of the file or null if not needed.
        fileName - The file name
        Returns:
        A MediaResult
      • resolveUris

        public void resolveUris(java.util.List<Uri> uris,
                                java.lang.String directory,
                                Callback<java.util.List<MediaResult>> callback)
        Copy the list of provided Uri into the internal cache.
        Parameters:
        uris - The list of Uri to resolve
        directory - Name of directory for storing them
        callback - Callback that will deliver a list of MediaResult
      • grantPermissionsForUri

        public void grantPermissionsForUri(Intent intent,
                                           Uri uri)
        Grant all Apps that are resolvable through the provided Intent Intent#FLAG_GRANT_READ_URI_PERMISSION and Intent#FLAG_GRANT_WRITE_URI_PERMISSION.
        Parameters:
        intent - An Intent
        uri - An Uri
      • revokePermissionsForUri

        public void revokePermissionsForUri(Uri uri)
        Revoke Intent#FLAG_GRANT_READ_URI_PERMISSION and Intent#FLAG_GRANT_WRITE_URI_PERMISSION that were previously granted by Belvedere.grantPermissionsForUri(Intent, Uri).
        Parameters:
        uri - An Uri
      • clearStorage

        public void clearStorage()
        Clear the internal Belvedere cache.