dave08
10/21/2018, 10:44 AMGlobalScope.actor<InstallState>(capacity = Channel.CONFLATED) {
val notification = progressNotifierFactory(
fileName.hashCode(),
R.drawable.icon,
name
)
var downloadSize = 0L
channel.consumeEach { msg ->
when (msg) {
is InstallState.Downloading ->
notification.update(R.string.notif_file_downloading, null, msg.totalMb)
.also { downloadSize = msg.totalMb }
is InstallState.UpdateDownloadProgress -> {
i { "Notifying progress: ${msg.currPercentage}" }
delay(500)
notification.update(
R.string.notif_file_downloading,
msg.currPercentage,
downloadSize
)
}
is InstallState.Failed ->
notification.update(R.string.notif_file_download_failed, 0)
}
}
}