Class LoadHelper


  • public class LoadHelper
    extends java.lang.Object
    Convenience class to parse Uri's.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int drawableResourceNameToIdentifier​(android.content.Context context, java.lang.String name)
      Return the integer resource id for the specified resource name.
      static void enableCaching​(long cacheByteSize, java.io.File cacheBaseDir, java.lang.String cacheFolderName)
      Enables HTTP caching, remote Uri requests responses are cached to cacheBaseDir/cacheFolderName
      static void enableCaching​(android.content.Context context)
      Enables HTTP caching with default settings, remote Uri requests responses are cached to cacheBaseDir/cacheFolderName
      static void flushHttpCache()  
      static java.util.concurrent.Callable<java.io.InputStream> fromResource​(android.content.Context context, int resId)
      Creates an InputStream from an Android resource ID.
      static java.util.concurrent.Callable<java.io.InputStream> fromUri​(android.content.Context context, android.net.Uri sourceUri)
      Creates different InputStreams depending on the contents of the Uri
      static java.util.concurrent.Callable<java.io.InputStream> fromUri​(android.content.Context context, android.net.Uri sourceUri, java.util.Map<java.lang.String,​java.lang.String> requestProperty)
      Creates different InputStreams depending on the contents of the Uri.
      static java.lang.String getLastPathSegment​(android.net.Uri uri)  
      static java.lang.Boolean isAndroidResource​(android.net.Uri sourceUri)
      True if the Uri is an Android resource, false if any other uri.
      static java.lang.Boolean isContentResource​(android.net.Uri sourceUri)
      True if the Uri is an Android resource, false if any other uri.
      static boolean isDataUri​(android.net.Uri uri)  
      static java.lang.Boolean isFileAsset​(android.net.Uri sourceUri)
      True if the Uri is a filename, false if it is a remote location.
      static boolean isGltfDataUri​(android.net.Uri uri)  
      static int rawResourceNameToIdentifier​(android.content.Context context, java.lang.String name)
      Return the integer resource id for the specified resource name.
      static android.net.Uri resolveUri​(android.net.Uri unresolvedUri, android.net.Uri parentUri)
      Normalizes Uri's based on a reference Uri.
      static android.net.Uri resourceToUri​(android.content.Context context, int resID)
      Generates a Uri from an Android resource.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INVALID_RESOURCE_IDENTIFIER

        public static final int INVALID_RESOURCE_IDENTIFIER
        See Also:
        Constant Field Values
    • Method Detail

      • isAndroidResource

        public static java.lang.Boolean isAndroidResource​(android.net.Uri sourceUri)
        True if the Uri is an Android resource, false if any other uri.
      • isFileAsset

        public static java.lang.Boolean isFileAsset​(android.net.Uri sourceUri)
        True if the Uri is a filename, false if it is a remote location.
      • isContentResource

        public static java.lang.Boolean isContentResource​(android.net.Uri sourceUri)
        True if the Uri is an Android resource, false if any other uri.
      • resolveUri

        public static android.net.Uri resolveUri​(android.net.Uri unresolvedUri,
                                                 @Nullable
                                                 android.net.Uri parentUri)
        Normalizes Uri's based on a reference Uri. This function is for convenience only since the Uri class can do this as well.
      • fromResource

        public static java.util.concurrent.Callable<java.io.InputStream> fromResource​(android.content.Context context,
                                                                                      int resId)
        Creates an InputStream from an Android resource ID.
        Throws:
        java.lang.IllegalArgumentException - for resources that can't be loaded.
      • fromUri

        public static java.util.concurrent.Callable<java.io.InputStream> fromUri​(android.content.Context context,
                                                                                 android.net.Uri sourceUri)
        Creates different InputStreams depending on the contents of the Uri
        Throws:
        java.lang.IllegalArgumentException - for Uri's that can't be loaded.
      • fromUri

        public static java.util.concurrent.Callable<java.io.InputStream> fromUri​(android.content.Context context,
                                                                                 android.net.Uri sourceUri,
                                                                                 @Nullable
                                                                                 java.util.Map<java.lang.String,​java.lang.String> requestProperty)
        Creates different InputStreams depending on the contents of the Uri.
        Parameters:
        requestProperty - Adds connection properties to created input stream.
        Throws:
        java.lang.IllegalArgumentException - for Uri's that can't be loaded.
      • resourceToUri

        public static android.net.Uri resourceToUri​(android.content.Context context,
                                                    int resID)
        Generates a Uri from an Android resource.
        Throws:
        android.content.res.Resources.NotFoundException
      • rawResourceNameToIdentifier

        public static int rawResourceNameToIdentifier​(android.content.Context context,
                                                      java.lang.String name)
        Return the integer resource id for the specified resource name.
      • drawableResourceNameToIdentifier

        public static int drawableResourceNameToIdentifier​(android.content.Context context,
                                                           java.lang.String name)
        Return the integer resource id for the specified resource name.
      • enableCaching

        public static void enableCaching​(android.content.Context context)
        Enables HTTP caching with default settings, remote Uri requests responses are cached to cacheBaseDir/cacheFolderName
      • enableCaching

        public static void enableCaching​(long cacheByteSize,
                                         java.io.File cacheBaseDir,
                                         java.lang.String cacheFolderName)
        Enables HTTP caching, remote Uri requests responses are cached to cacheBaseDir/cacheFolderName
      • flushHttpCache

        public static void flushHttpCache()
      • isDataUri

        public static boolean isDataUri​(android.net.Uri uri)
      • isGltfDataUri

        public static boolean isGltfDataUri​(android.net.Uri uri)
      • getLastPathSegment

        public static java.lang.String getLastPathSegment​(android.net.Uri uri)