public abstract class ResourcePathManager
extends java.lang.Object
init(ResourcePathManager)
at the start of your application and pass in your
implementation of this class. Wihtin there you will have to implement generatePath(int,
String)
method and return the relative path based on what file type it is.
The necessity of defining a file type is needed to keep compatibility with assets define in ResearchKitâ„¢ applications
Modifier and Type | Class and Description |
---|---|
static class |
ResourcePathManager.Resource
Class represents one asset within the assets folder.
|
Constructor and Description |
---|
ResourcePathManager() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
generateAbsolutePath(int type,
java.lang.String name)
Generates an absolute string file path
|
abstract java.lang.String |
generatePath(int type,
java.lang.String name)
The genereatePath method is abstract as the Framework does not know what the parent
directory of a file is.
|
java.lang.String |
getFileExtension(int type) |
static ResourcePathManager |
getInstance()
Returns the singleton instance of this class.
|
static java.io.InputStream |
getResouceAsInputStream(android.content.Context context,
java.lang.String filePath)
Load resource from a file-path and turns contents to a InputStream for consumption
|
static byte[] |
getResourceAsBytes(android.content.Context context,
java.lang.String filePath)
Load resource from a file-path and turns contents to a byte[] for consumption
|
static <T> T |
getResourceAsClass(android.content.Context context,
java.lang.Class<T> clazz,
java.lang.String filePath)
Load resource from a file-path and turns contents to a objects, of type T, for consumption
|
static java.lang.String |
getResourceAsString(android.content.Context context,
java.lang.String filePath)
Load resource from a file-path and turns contents to a String for consumption
|
static void |
init(ResourcePathManager manager)
Initializes the ResourcePathManager singleton.
|
public static void init(ResourcePathManager manager)
Application.onCreate()
method.manager
- an implementation of ResourcePathManagerpublic static ResourcePathManager getInstance()
public abstract java.lang.String generatePath(int type, java.lang.String name)
type
- the type of file. This will be used for appending the file extension.name
- the name of the filepublic java.lang.String generateAbsolutePath(int type, java.lang.String name)
type
- the type of file. This will be used for appending the file extension.name
- the name of the filepublic java.lang.String getFileExtension(int type)
type
- the type of file. Supported file types are defined within the ResourcePathManager.Resource
class. You may override this method in your implementation and implement your own
casespublic static java.lang.String getResourceAsString(android.content.Context context, java.lang.String filePath)
context
- android contextfilePath
- relative file pathpublic static byte[] getResourceAsBytes(android.content.Context context, java.lang.String filePath)
context
- android contextfilePath
- relative file pathpublic static java.io.InputStream getResouceAsInputStream(android.content.Context context, java.lang.String filePath)
context
- android contextfilePath
- relative file pathpublic static <T> T getResourceAsClass(android.content.Context context, java.lang.Class<T> clazz, java.lang.String filePath)
context
- android contextclazz
- the class of TfilePath
- relative file path