Package-level declarations

Downloading files.

Downloader

The downloader is available from the DownloadManager interface

import com.cloudike.sdk.core.CoreManager
import com.cloudike.sdk.core.downloader.DownloadManager

val coreContext: CoreContext = coreManager.build(/* ... */)
val downloader: DownloadManager = coreContext.downloader

The downloader provides

  • The ability to track the status

  • The ability to install a notification adapter

  • Downloading a file from a link

  • Canceling the download

  • The utilitarian methods

To download resources as part of background work, you need to use specialized methods.

Download Media

import com.cloudike.sdk.photos.PhotoManager
import com.cloudike.sdk.core.CoreManager
import com.cloudike.sdk.core.download.DownloadPriority
import com.cloudike.sdk.core.cache.CacheMode

val photoManager: PhotoManager
val targetDirUri: Uri

photoManager.timeline.enqueueToDownload(
mediaIds = setOf(1L, 2L, 3L),
priority = DownloadPriority.REGULAR,
cacheMode = CacheMode.TEMPORARY,
targetDirUri = targetDirUri
)

Download File

import com.cloudike.sdk.files.FileManager
import com.cloudike.sdk.core.CoreManager
import com.cloudike.sdk.core.download.DownloadPriority
import com.cloudike.sdk.core.cache.CacheMode

val fileManager: FileManager
val targetDirUri: Uri

fileManager.operations.enqueueToDownload(
fileIds = setOf("1", "2", "3"),
priority = DownloadPriority.REGULAR,
cacheMode = CacheMode.TEMPORARY,
targetDirUri = targetDirUri
)

Download Document

import com.cloudike.sdk.documentwallet.DocumentWalletManager
import com.cloudike.sdk.documentwallet.document.data.DocumentSize
import com.cloudike.sdk.core.CoreManager
import com.cloudike.sdk.core.download.DownloadPriority
import com.cloudike.sdk.core.cache.CacheMode

val dwManager: DocumentWalletManager
val targetDirUri: Uri

dwManager.documentManager.enqueueToDownload(
documentId = "",
size = DocumentSize.FULL,
priority = DownloadPriority.REGULAR,
cacheMode = CacheMode.TEMPORARY,
targetDirUri = targetDirUri
)

Priority And Cache

The downloader has priority and cache parameters.

Priority

  • HIGH

  • REGULAR

Cache Mode

  • TEMPORARY - The cache is stored for 30 days.

  • OFFLINE - The cache is kept indefinitely. It`s not deleted during cleaning.

Types

Link copied to clipboard
data class DownloadConfiguration(val cacheLifetimeDays: Int = 30)
Link copied to clipboard

A set of factors representing the state of the downloader and the reasons why the download might be stopped.

Link copied to clipboard
interface DownloadManager
Link copied to clipboard

An interface to implement an adapter that translates the downloading state into a notification. The downloader uses it to display notifications during boot.

Link copied to clipboard
Link copied to clipboard
fun interface DownloadResultCopier
Link copied to clipboard
sealed class DownloadState

During the download process, the media file may change its download state.

Link copied to clipboard
data class DownloadStatus(val nonCriticalFactors: Set<DownloadFactor>, val criticalFactors: Set<DownloadFactor>, val activeWorkerCount: Int, val inQueueFilesCount: Int, val inDownloadFilesCount: Int, val downloadedFilesCount: Int) : Parcelable

A data model describing the downloader status.

Link copied to clipboard