Skip to content

Instantly share code, notes, and snippets.

@onyxmueller
onyxmueller / DownloadProgressUpdater.kt
Last active February 27, 2025 04:12
An Android Kotlin class to track and update download progress by the DownloadManager.
/**
* Tracks download of a DownloadManager job and reports progress.
*/
internal class DownloadProgressUpdater(private val manager: DownloadManager, private val downloadId: Long, private var downloadProgressListener: DownloadProgressListener?) : Thread() {
private val query: DownloadManager.Query = DownloadManager.Query()
private var totalBytes: Int = 0
interface DownloadProgressListener {
fun updateProgress(progress: Long)
}