Package com.mapbox.mapboxsdk.storage

Contains the Mapbox Maps Android Storage API classes.

Types

Name Summary
FileSource
open class FileSource
Holds a central reference to the core’s DefaultFileSource for as long as there are active mapviews / offline managers
Resource
class Resource
Resource provides access to resource types.

FileSource

open class FileSource

Holds a central reference to the core’s DefaultFileSource for as long as there are active mapviews / offline managers

Types

Name Summary
ResourcesCachePathChangeCallback
interface ResourcesCachePathChangeCallback
This callback receives an asynchronous response containing the new path of theresources cache database.
ResourceTransformCallback
interface ResourceTransformCallback
This callback allows implementors to transform URLs before they are requestedfrom the internet.

Functions

Name Summary
activate
open fun activate()
deactivate
open fun deactivate()
getAccessToken
@NonNull()
open fun getAccessToken(): String
getInstance
@UiThread()
open fun getInstance(context: Context): FileSource
Get the single instance of FileSource.
initializeFileDirsPaths
@UiThread()
open fun initializeFileDirsPaths(context: Context)
Initializes file directories paths.
isActivated
open fun isActivated(): Boolean
isExternalStorageReadable
open fun isExternalStorageReadable(): Boolean
Checks if external storage is available to at least read.
setAccessToken
open fun setAccessToken(accessToken: String)
setApiBaseUrl
open fun setApiBaseUrl(baseUrl: String)
setResourceTransform
open fun setResourceTransform(callback: FileSource.ResourceTransformCallback)
Sets a callback for transforming URLs requested from the internetThe callback will be executed on the main thread once for every requested URL.

Properties

Name Summary
internalCachePath private open var internalCachePath: String
resourcesCachePath @Nullable()
private open var resourcesCachePath: String

activate

open fun activate()

deactivate

open fun deactivate()

getAccessToken

@NonNull()

open fun getAccessToken(): String

getInstance

@UiThread()

open fun getInstance(context: Context): FileSource

Get the single instance of FileSource.

Return

the single instance of FileSource

Parameters
Name Summary
context
the context to derive the cache path from
   
   

initializeFileDirsPaths

@UiThread()

open fun initializeFileDirsPaths(context: Context)

Initializes file directories paths.

Parameters
Name Summary
context
the context to derive paths from
   
   

internalCachePath

private open var internalCachePath: String

isActivated

open fun isActivated(): Boolean

isExternalStorageReadable

open fun isExternalStorageReadable(): Boolean

Checks if external storage is available to at least read. In order for this to work, makesure you include (or WRITE_EXTERNAL_STORAGE) for API level < 18 in your app Manifest.

Code from https://developer.android.com/guide/topics/data/data-storage.html#filesExternal

Return

true if external storage is readable

resourcesCachePath

@Nullable()

private open var resourcesCachePath: String

setAccessToken

open fun setAccessToken(accessToken: String)

setApiBaseUrl

open fun setApiBaseUrl(baseUrl: String)

setResourceTransform

open fun setResourceTransform(callback: FileSource.ResourceTransformCallback)

Sets a callback for transforming URLs requested from the internet

The callback will be executed on the main thread once for every requested URL.

Parameters
Name Summary
callback
the callback to be invoked or null to reset
   
   

ResourceTransformCallback

interface ResourceTransformCallback

This callback allows implementors to transform URLs before they are requestedfrom the internet. This can be used add or remove custom parameters, or reroutecertain requests to other servers or endpoints.

Functions

Name Summary
onURL
abstract fun onURL(kind: Int, url: String): String
Called whenever a URL needs to be transformed.

onURL

abstract fun onURL(kind: Int, url: String): String

Called whenever a URL needs to be transformed.

Return

a URL that will now be downloaded.

Parameters
Name Summary
kind
the kind of URL to be transformed.
url
the URL to be transformed
   
   

ResourcesCachePathChangeCallback

interface ResourcesCachePathChangeCallback

This callback receives an asynchronous response containing the new path of theresources cache database.

Functions

Name Summary
onError
abstract fun onError(message: String)
Receives an error message if setting the path was not successful
onSuccess
abstract fun onSuccess(path: String)
Receives the new database path

onError

abstract fun onError(message: String)

Receives an error message if setting the path was not successful

Parameters
Name Summary
message
the error message
   
   

onSuccess

abstract fun onSuccess(path: String)

Receives the new database path

Parameters
Name Summary
path
the path of the current resources cache database
   
   

Resource

class Resource

Resource provides access to resource types.

Types

Name Summary
Kind
@Retention(value = RetentionPolicy.SOURCE)
annotation class Kind
Resource type variants.

Properties

Name Summary
GLYPHS val GLYPHS: IntSigned distance field glyphs for text rendering.
SOURCE val SOURCE: IntTileJSON file as specified in https://www.mapbox.
SPRITE_IMAGE val SPRITE_IMAGE: IntImage part of a sprite sheet.
SPRITE_JSON val SPRITE_JSON: IntJSON part of a sprite sheet.
STYLE val STYLE: IntStyle sheet JSON file
TILE val TILE: IntA vector or raster tile as described in the style sheet athttps://www.mapbox.
UNKNOWN val UNKNOWN: IntUnknown type

GLYPHS

val GLYPHS: Int

Signed distance field glyphs for text rendering. These are the URLs specified in the stylein https://www.mapbox.com/mapbox-gl-js/style-spec/#root-glyphs

SOURCE

val SOURCE: Int

TileJSON file as specified in https://www.mapbox.com/mapbox-gl-js/style-spec/#root-sources

SPRITE_IMAGE

val SPRITE_IMAGE: Int

Image part of a sprite sheet. It is constructed of the prefix inhttps://www.mapbox.com/mapbox-gl-js/style-spec/#root-sprite and a PNG file extension.

SPRITE_JSON

val SPRITE_JSON: Int

JSON part of a sprite sheet. It is constructed of the prefix inhttps://www.mapbox.com/mapbox-gl-js/style-spec/#root-sprite and a JSON file extension.

STYLE

val STYLE: Int

Style sheet JSON file

TILE

val TILE: Int

A vector or raster tile as described in the style sheet athttps://www.mapbox.com/mapbox-gl-js/style-spec/#sources

UNKNOWN

val UNKNOWN: Int

Unknown type

Kind

@Retention(value = RetentionPolicy.SOURCE)

annotation class Kind

Resource type variants.

Functions

Name Summary
annotationType
abstract fun annotationType(): Class
equals
abstract fun equals(p: Any): Boolean
hashCode
abstract fun hashCode(): Int
toString
abstract fun toString(): String