X-Git-Url: https://git.distorted.org.uk/~mdw/tripe-android/blobdiff_plain/9190adc66f814b8b9add2d2df2ff65b43175104b..HEAD:/progress.scala diff --git a/progress.scala b/progress.scala index 308b535..5f81615 100644 --- a/progress.scala +++ b/progress.scala @@ -64,6 +64,16 @@ trait Model { class SimpleModel(val what: String, val max: Long) extends Model; +class DetailedModel(what: String, max: Long) extends SimpleModel(what, max) { + var detail: String = null; + override def format(cur: Long): String = { + val sb = new StringBuilder; + sb ++= super.format(cur); + if (detail != null) { sb += ' '; sb ++= detail; } + sb.result + } +} + private val UDATA = Seq("kB", "MB", "GB", "TB", "PB", "EB"); trait DataModel extends Model { @@ -90,8 +100,7 @@ trait OperationReporter extends BaseReporter { def step(detail: String); } -def withReporter[T, P <: BaseReporter] - (rep: P, body: P => T): T = { +def withReporter[T, P <: BaseReporter](rep: P, body: P => T): T = { val ret = try { body(rep) } catch { case e: Exception => rep.failed(e); throw e; } rep.done();