Add download queue features from J2K fork

This commit is contained in:
arkon
2020-02-23 12:42:10 -05:00
parent 3e5a48e5e4
commit fb897e37d1
16 changed files with 439 additions and 127 deletions

View File

@@ -20,15 +20,23 @@ open class Page(
set(value) {
field = value
statusSubject?.onNext(value)
statusCallback?.invoke(this)
}
@Transient
@Volatile
var progress: Int = 0
set(value) {
field = value
statusCallback?.invoke(this)
}
@Transient
private var statusSubject: Subject<Int, Int>? = null
@Transient
private var statusCallback: ((Page) -> Unit)? = null
override fun update(bytesRead: Long, contentLength: Long, done: Boolean) {
progress = if (contentLength > 0) {
(100 * bytesRead / contentLength).toInt()
@@ -41,6 +49,10 @@ open class Page(
this.statusSubject = subject
}
fun setStatusCallback(f: ((Page) -> Unit)?) {
statusCallback = f
}
companion object {
const val QUEUE = 0
const val LOAD_PAGE = 1