2014-11-11 21:53:13 -05:00
|
|
|
package org.bspeice.minimalbible.activity.downloader.manager
|
|
|
|
|
|
|
|
import org.crosswire.jsword.book.Book
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by bspeice on 11/11/14.
|
|
|
|
*/
|
2015-01-13 22:41:38 -05:00
|
|
|
data class DLProgressEvent(val bookProgress: Int,
|
|
|
|
val indexProgress: Int,
|
|
|
|
val b: Book) {
|
2014-11-11 21:53:13 -05:00
|
|
|
class object {
|
|
|
|
val PROGRESS_COMPLETE = 100
|
|
|
|
val PROGRESS_BEGINNING = 0
|
2015-01-13 22:41:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Build a DLProgressEvent that is just beginning
|
|
|
|
* Mostly just a nice shorthand
|
|
|
|
*/
|
|
|
|
fun beginningEvent(b: Book) = DLProgressEvent(DLProgressEvent.PROGRESS_BEGINNING,
|
|
|
|
DLProgressEvent.PROGRESS_BEGINNING, b)
|
2014-11-11 21:53:13 -05:00
|
|
|
}
|
|
|
|
|
2015-01-13 22:41:38 -05:00
|
|
|
val averageProgress: Int
|
|
|
|
get() = (bookProgress + indexProgress) / 2
|
|
|
|
|
|
|
|
fun toCircular() = (averageProgress.toFloat() * 360 / 100).toInt()
|
2014-11-11 21:53:13 -05:00
|
|
|
}
|