Class OfflinePlugin


  • public class OfflinePlugin
    extends java.lang.Object
    OfflinePlugin is the main entry point for integrating the offline plugin into your app.

    To start downloading a region call startDownload(OfflineDownloadOptions)

    Since:
    0.1.0
    • Method Detail

      • getInstance

        public static OfflinePlugin getInstance​(@NonNull
                                                android.content.Context context)
        Get a single instance of OfflinePlugin
        Returns:
        the single instance of OfflinePlugin
        Since:
        0.1.0
      • getActiveDownloads

        @NonNull
        public java.util.List<OfflineDownloadOptions> getActiveDownloads()
        Get the active offline downloads
        Returns:
        a List of active offline downloads.
        Since:
        0.1.0
      • startDownload

        public void startDownload​(OfflineDownloadOptions options)
        Start downloading an offline download by providing an options object.

        You can listen to the actual creation of the download with OfflineDownloadChangeListener.

        Parameters:
        options - the offline download builder
        Since:
        0.1.0
      • cancelDownload

        public void cancelDownload​(OfflineDownloadOptions offlineDownload)
        Cancel an ongoing download.
        Parameters:
        offlineDownload - the offline download
        Since:
        0.1.0
      • getActiveDownloadForOfflineRegion

        @Nullable
        public OfflineDownloadOptions getActiveDownloadForOfflineRegion​(com.mapbox.mapboxsdk.offline.OfflineRegion offlineRegion)
        Get the OfflineDownloadOptions for an offline region, returns null if no download is active for region.
        Parameters:
        offlineRegion - the offline region to get related offline download for
        Returns:
        the active offline download, null if not downloading the region.
        Since:
        0.1.0
      • addOfflineDownloadStateChangeListener

        public void addOfflineDownloadStateChangeListener​(OfflineDownloadChangeListener listener)
        Add a callback that is invoked when the offline download state changes.

        In normal cases this method will be invoked as part of Activity.onStart()

        Parameters:
        listener - the callback that will be invoked
        Since:
        0.1.0
      • removeOfflineDownloadStateChangeListener

        public void removeOfflineDownloadStateChangeListener​(OfflineDownloadChangeListener listener)
        remove a callback that is invoked when the offline download state changes.

        In normal cases this method will be invoked as part of Activity.onStop()

        Parameters:
        listener - the callback that will be removed
        Since:
        0.1.0