mirror of
https://github.com/MinimalBible/MinimalBible
synced 2025-07-04 15:25:14 -04:00
Fix the download progress not updating
Integer roundoff errors...
This commit is contained in:
@ -114,8 +114,10 @@ class BookManager(private val installedBooks: Books, val rM: RefreshManager) :
|
||||
val job = ev.getJob()
|
||||
bookMappings.filter { it.getKey() == job.getJobID() }
|
||||
.map {
|
||||
val event = DLProgressEvent(job.getWorkDone() / job.getTotalWork() * 100,
|
||||
it.getValue())
|
||||
// We multiply by 100 first to avoid integer truncation
|
||||
// Also avoids roundoff error. Neat trick, but I'm spending just as much time
|
||||
// documenting it as implementing the floating point would take
|
||||
val event = DLProgressEvent(job.getWorkDone() * 100 / job.getTotalWork(), it.getValue())
|
||||
downloadEvents onNext event
|
||||
|
||||
if (job.getWorkDone() == job.getTotalWork()) {
|
||||
|
@ -12,5 +12,5 @@ class DLProgressEvent(val progress: Int, val b: Book) {
|
||||
val PROGRESS_BEGINNING = 0
|
||||
}
|
||||
|
||||
fun toCircular() = progress.toFloat() * 360 / 100
|
||||
fun toCircular() = (progress.toFloat() * 360 / 100).toInt()
|
||||
}
|
||||
|
Reference in New Issue
Block a user