Download

interface Download

Fetching issues onto the device so they can be read offline, and following what the fetching is doing.

Obtained from CGS.download. An issue is addressed by its id and handed back as an Item that both reports its state and controls it:

val item = CGS.download().issue(issueId)
item.start()

item.state.collect { state ->
when (state) {
is Download.Item.State.Downloading -> showProgress(item.progress.value)
is Download.Item.State.Downloaded -> CGS.reader().open(activity, item)
is Download.Item.State.Failed -> offerRetry()
else -> Unit
}
}

Progress is persisted, so a download interrupted by a crash or a lost connection picks up where it stopped rather than starting over. Reading an issue requires it to be fully downloaded — the reader takes an Item, not an id.

Types

Link copied to clipboard
interface Item

One issue's download: its current state, its progress, and the actions that change them.

Functions

Link copied to clipboard
abstract fun issue(issueId: IssueId): Download.Item

The download handle for an issue.

Link copied to clipboard
abstract fun trackedIssues(): Flow<List<IssueId>>

Every issue the download manager currently knows about — queued, downloading, paused, failed or downloaded alike — in priority order.