public class FileSource
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
FileSource.ResourcesCachePathChangeCallback
This callback receives an asynchronous response containing the new path of the
resources cache database.
|
static interface |
FileSource.ResourceTransformCallback
This callback allows implementors to transform URLs before they are requested
from the internet.
|
Modifier and Type | Method and Description |
---|---|
void |
activate() |
void |
deactivate() |
protected void |
finalize() |
java.lang.String |
getAccessToken() |
static FileSource |
getInstance(android.content.Context context)
Get the single instance of FileSource.
|
static java.lang.String |
getInternalCachePath(android.content.Context context)
Get internal cache path for a context.
|
static java.lang.String |
getResourcesCachePath(android.content.Context context)
Get files directory path for a context.
|
static void |
initializeFileDirsPaths(android.content.Context context)
Initializes file directories paths.
|
boolean |
isActivated() |
static boolean |
isExternalStorageReadable()
Checks if external storage is available to at least read.
|
void |
setAccessToken(java.lang.String accessToken) |
void |
setApiBaseUrl(java.lang.String baseUrl) |
static void |
setResourcesCachePath(android.content.Context context,
java.lang.String path,
FileSource.ResourcesCachePathChangeCallback callback)
Deprecated.
|
static void |
setResourcesCachePath(java.lang.String path,
FileSource.ResourcesCachePathChangeCallback callback)
Changes the path of the resources cache database.
|
void |
setResourceTransform(FileSource.ResourceTransformCallback callback)
Sets a callback for transforming URLs requested from the internet
|
@UiThread public static FileSource getInstance(@NonNull android.content.Context context)
context
- the context to derive the cache path frompublic static boolean isExternalStorageReadable()
Code from https://developer.android.com/guide/topics/data/data-storage.html#filesExternal
@UiThread public static void initializeFileDirsPaths(android.content.Context context)
context
- the context to derive paths from@NonNull public static java.lang.String getResourcesCachePath(@NonNull android.content.Context context)
context
- the context to derive the files directory path frompublic static java.lang.String getInternalCachePath(@NonNull android.content.Context context)
context
- the context to derive the internal cache path from@Deprecated public static void setResourcesCachePath(@NonNull android.content.Context context, @NonNull java.lang.String path, @NonNull FileSource.ResourcesCachePathChangeCallback callback)
setResourcesCachePath(String, ResourcesCachePathChangeCallback)
The callback reference is strongly kept throughout the process, so it needs to be wrapped in a weak reference or released on the client side if necessary.
context
- the context of the pathpath
- the new database pathcallback
- the callback to obtain the resultpublic static void setResourcesCachePath(@NonNull java.lang.String path, @NonNull FileSource.ResourcesCachePathChangeCallback callback)
The callback reference is strongly kept throughout the process, so it needs to be wrapped in a weak reference or released on the client side if necessary.
path
- the new database pathcallback
- the callback to obtain the resultpublic boolean isActivated()
public void activate()
public void deactivate()
public void setAccessToken(java.lang.String accessToken)
@NonNull public java.lang.String getAccessToken()
public void setApiBaseUrl(java.lang.String baseUrl)
public void setResourceTransform(FileSource.ResourceTransformCallback callback)
The callback will be executed on the main thread once for every requested URL.
callback
- the callback to be invoked or null to resetprotected void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable