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
}
}Content copied to clipboard
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.