Item

interface Item

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

Get one from issue. Two handles for the same issue address the same download: they report the same state and their controls act on the same work, so they can be held independently by as many screens as need one.

Types

Link copied to clipboard
sealed interface State

Where a download stands.

Properties

Link copied to clipboard
abstract val progress: StateFlow<Double>

How much of the issue is on the device, from 0.0 to 1.0.

Link copied to clipboard
abstract val state: StateFlow<Download.Item.State>

The download's current state, and every change to it.

Functions

Link copied to clipboard
abstract suspend fun cancel()

Abandons the download and discards what it had fetched. The issue returns to State.NotDownloaded; starting again begins from zero. If another profile on the device also has the issue, the files stay for that profile, and a transfer still running is paused.

Link copied to clipboard
abstract suspend fun pause()

Stops the download, keeping what has been fetched so far. resume continues from there.

Link copied to clipboard
abstract suspend fun resume()

Continues a paused download from where it stopped. Does nothing unless state is State.Paused.

Link copied to clipboard
abstract suspend fun start()

Queues the download, resumes it if it is paused, or restarts it after a failure.

Link copied to clipboard
abstract suspend fun startImmediate()

Starts this download ahead of everything else: whatever else is running is paused while it takes a slot, then resumed as capacity allows.