Interface OfflineCacheManager

com.yandex.mapkit.offline_cache

public interface OfflineCacheManager

Attention.

This feature is not available in the free MapKit version.

Offline cache manager.

Nested Classes

Methods

void addErrorListener(@NonNull ErrorListener errorListener)

Subscribe on errors.

void addRegionListUpdatesListener(@NonNull RegionListUpdatesListener regionListUpdatesListener)

Subscribe on update of region list.

void addRegionListener(@NonNull RegionListener regionListener)

Subscribe on status events.

void allowUseCellularNetwork(boolean useCellular)

Indicates whether to allow downloading using cellular networks (3G, LTE, etc.) Disallowed by default.

void clear(@NonNull ClearListener callback)

Erases all data for downloads and regions and wipes the tile cache.

void computeCacheSize(@NonNull SizeListener callback)

Calculates the full cache size in bytes.

void drop(int regionId)

Drop region data from the device.

void enableAutoUpdate(boolean enable)

Enables autoupdating downloaded caches when they become outdated.

List< String > getCities(int regionId)

Returns a list of cities.

float getProgress(int regionId)

Current region progress [0,1].

RegionState getState(int regionId)

Current region state.

boolean isLegacyPath(int regionId)

Returns true if region has files with legacy localized path.

boolean isValid()

Tells if this OfflineCacheManager is valid or no.

boolean mayBeOutOfAvailableSpace(int regionId)

Returns true if available disk space might not be enough for installation of the region data.

void moveData(@NonNull String newPath, @NonNull DataMoveListener dataMoveListener)

Moves offline caches to the specified folder.

void pauseDownload(int regionId)

Pause downloading of region.

List< Region > regions()

Copying a list of regions from memory.

void removeErrorListener(@NonNull ErrorListener errorListener)

Unsubscribe from errors.

void removeRegionListUpdatesListener(@NonNull RegionListUpdatesListener regionListUpdatesListener)

Unsubscribe from region list update.

void removeRegionListener(@NonNull RegionListener regionListener)

Unsubscribe from status events.

void requestPath(@NonNull PathGetterListener callback)

Provides the data path for offline cache files.

void setCachePath(@NonNull String path)

Sets a new path for caches.

void startDownload(int regionId)

Start to download new offline cache for the region or update if region has been downloaded.

void stopDownload(int regionId)

Stop downloading of region.

Method Detail

addErrorListener

public void addErrorListener (@NonNull ErrorListener errorListener)

Subscribe on errors.

addRegionListUpdatesListener

public void addRegionListUpdatesListener (@NonNull RegionListUpdatesListener regionListUpdatesListener)

Subscribe on update of region list.

addRegionListener

public void addRegionListener (@NonNull RegionListener regionListener)

Subscribe on status events.

allowUseCellularNetwork

public void allowUseCellularNetwork (boolean useCellular)

Indicates whether to allow downloading using cellular networks (3G, LTE, etc.) Disallowed by default.

clear

public void clear (@NonNull ClearListener callback)

Erases all data for downloads and regions and wipes the tile cache.

Forces reloading the list from the remote source

computeCacheSize

public void computeCacheSize (@NonNull SizeListener callback)

Calculates the full cache size in bytes.

drop

public void drop (int regionId)

Drop region data from the device.

If data is being downloaded then downloading is cancelled.

enableAutoUpdate

public void enableAutoUpdate (boolean enable)

Enables autoupdating downloaded caches when they become outdated.

getCities

public List< String > getCities (int regionId)

Returns a list of cities.

getProgress

public float getProgress (int regionId)

Current region progress [0,1].

For downloaded files returns 1; If we haven't start download yet, returns 0;

getState

public RegionState getState (int regionId)

Current region state.

isLegacyPath

public boolean isLegacyPath (int regionId)

Returns true if region has files with legacy localized path.

If region in downloading state result may be incorrect.

isValid

public boolean isValid ()

Tells if this OfflineCacheManager is valid or no.

Any other method (except for this one) called on an invalid OfflineCacheManager will throw java.lang.RuntimeException. An instance becomes invalid only on UI thread, and only when its implementation depends on objects already destroyed by now. Please refer to general docs about the interface for details on its invalidation.

mayBeOutOfAvailableSpace

public boolean mayBeOutOfAvailableSpace (int regionId)

Returns true if available disk space might not be enough for installation of the region data.

moveData

public void moveData (@NonNull String newPath, @NonNull DataMoveListener dataMoveListener)

Moves offline caches to the specified folder.

This operation is non-cancellable. If there is already a pending operation to set the cache path, it throws an error (Android). If the application exits before the operation is completed, it does not take effect, but garbage will not be cleared.
Parameters:
newPath

New path to store data.

dataMoveListener

It will be unsubscribed automatically when the operation is completed or fails with an error.

pauseDownload

public void pauseDownload (int regionId)

Pause downloading of region.

regions

public List< Region > regions ()

Copying a list of regions from memory.

All changes of regions won't affected on on the collection.

removeErrorListener

public void removeErrorListener (@NonNull ErrorListener errorListener)

Unsubscribe from errors.

removeRegionListUpdatesListener

public void removeRegionListUpdatesListener (@NonNull RegionListUpdatesListener regionListUpdatesListener)

Unsubscribe from region list update.

removeRegionListener

public void removeRegionListener (@NonNull RegionListener regionListener)

Unsubscribe from status events.

requestPath

public void requestPath (@NonNull PathGetterListener callback)

Provides the data path for offline cache files.

setCachePath

public void setCachePath (@NonNull String path)

Sets a new path for caches.

If the specified path contains an existing cache, this cache will be used; otherwise, a new cache will be initialized. This takes effect after the application is restarted.

startDownload

public void startDownload (int regionId)

Start to download new offline cache for the region or update if region has been downloaded.

stopDownload

public void stopDownload (int regionId)

Stop downloading of region.