diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java index 06676d76a1..f0cb8d973a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/storage/FileSource.java @@ -3,13 +3,11 @@ package com.mapbox.mapboxsdk.storage; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; +import android.content.res.AssetManager; import android.os.Environment; import android.support.annotation.NonNull; -import android.content.res.AssetManager; - import com.mapbox.mapboxsdk.Mapbox; import com.mapbox.mapboxsdk.constants.MapboxConstants; - import timber.log.Timber; /** @@ -28,8 +26,9 @@ public class FileSource { /** * Called whenever a URL needs to be transformed. * - * @param kind The kind of URL to be transformed. - * @return A URL that will now be downloaded. + * @param kind the kind of URL to be transformed. + * @param url the URL to be transformed + * @return a URL that will now be downloaded. */ String onURL(@Resource.Kind int kind, String url); @@ -38,6 +37,12 @@ public class FileSource { // File source instance is kept alive after initialization private static FileSource INSTANCE; + /** + * Get the single instance of FileSource. + * + * @param context the context to derive the cache path from + * @return the single instance of FileSource + */ public static synchronized FileSource getInstance(Context context) { if (INSTANCE == null) { String cachePath = getCachePath(context); @@ -47,6 +52,12 @@ public class FileSource { return INSTANCE; } + /** + * Get the cache path for a context. + * + * @param context the context to derive the cache path from + * @return the cache path + */ public static String getCachePath(Context context) { // Default value boolean setStorageExternal = MapboxConstants.DEFAULT_SET_STORAGE_EXTERNAL; @@ -59,9 +70,9 @@ public class FileSource { MapboxConstants.KEY_META_DATA_SET_STORAGE_EXTERNAL, MapboxConstants.DEFAULT_SET_STORAGE_EXTERNAL); } catch (PackageManager.NameNotFoundException exception) { - Timber.e("Failed to read the package metadata: ", exception); + Timber.e(exception, "Failed to read the package metadata: "); } catch (Exception exception) { - Timber.e("Failed to read the storage key: ", exception); + Timber.e(exception, "Failed to read the storage key: "); } String cachePath = null; @@ -70,7 +81,7 @@ public class FileSource { // Try getting the external storage path cachePath = context.getExternalFilesDir(null).getAbsolutePath(); } catch (NullPointerException exception) { - Timber.e("Failed to obtain the external storage path: ", exception); + Timber.e(exception, "Failed to obtain the external storage path: "); } } @@ -111,6 +122,10 @@ public class FileSource { initialize(Mapbox.getAccessToken(), cachePath, assetManager); } + public native void activate(); + + public native void deactivate(); + public native void setAccessToken(@NonNull String accessToken); public native String getAccessToken(); |