-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
347 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,44 @@ | ||
#Progress | ||
Progress tracking for Kotlin. | ||
Track progress for [Kotlin](http://kotlinlang.org) | ||
|
||
--- | ||
[![CircleCI branch](https://img.shields.io/circleci/project/mplatvoet/progress/master.svg)](https://circleci.com/gh/mplatvoet/progress/tree/master) [![Maven Central](https://img.shields.io/maven-central/v/nl.komponents.progress/progress.svg)](http://search.maven.org/#browse%7C-300825966) [![DUB](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/mplatvoet/progress/blob/master/LICENSE) | ||
|
||
Please refer to [progress.komponents.nl](http://progress.komponents.nl) for more information | ||
|
||
```kt | ||
val progress = Progress() | ||
progress.onUpdate { p-> | ||
println("${p.percentage}%") | ||
//private part | ||
val control = Progress.control() | ||
|
||
//public part | ||
val progress = control.progress | ||
|
||
//get notified on updates | ||
progress.update { | ||
println("${value}") | ||
} | ||
|
||
//set value | ||
control.value = 0.25 | ||
control.value = 0.50 | ||
control.value = 0.75 | ||
control.value = 1.0 | ||
``` | ||
|
||
## Getting started | ||
This version is build against `kotlin-stdlib:0.12.200`. | ||
|
||
###Gradle | ||
```groovy | ||
dependencies { | ||
compile 'nl.komponents.progress:progress:0.1.+' | ||
} | ||
``` | ||
|
||
val sub1 = progress.child(weight = 0.1) | ||
val sub2 = progress.child(weight = 5) | ||
val sub2sub1 = sub2.child() | ||
val sub2sub2 = sub2.child() | ||
val sub3 = progress.child() | ||
val sub4 = progress.child(weight = 2) | ||
|
||
sub1.value = 0.25 | ||
sub1.value = 0.50 | ||
sub1.value = 0.75 | ||
sub1.value = 1.0 | ||
|
||
sub2sub1.completed = true | ||
sub2sub2.value = 0.5 | ||
sub2sub2.value = 1.0 | ||
|
||
sub3.value = 0.25 | ||
sub3.value = 0.50 | ||
sub3.value = 0.75 | ||
sub3.value = 1.0 | ||
|
||
sub4.value = 0.25 | ||
sub4.value = 0.50 | ||
sub4.value = 0.75 | ||
sub4.value = 1.0 | ||
###Maven | ||
```xml | ||
<dependency> | ||
<groupId>nl.komponents.progress</groupId> | ||
<artifactId>progress</artifactId> | ||
<version>[0.1.0, 0.2.0)</version> | ||
</dependency> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#Progress usage documentation | ||
|
||
Progress is a small utility for tracking progress in Kotlin. It is written with concurrency scenarios in mind and | ||
is thus entirely thread safe. Progress tracking consists of two separate parts: | ||
|
||
- `Progress` for receiving updates | ||
- `ProgressControl` for changing the state. | ||
|
||
##ProgressControl | ||
A `ProgressControl` allows you to mutate the state, ergo setting the progress value, for the associated `Progress`. | ||
There are two types of `ProgressControl`s: | ||
|
||
- a single value control `SingleProgressControl` | ||
- a container control `ContainerProgressControl` | ||
|
||
A `SingleProgressControl` allows you to directly set a value | ||
```kt | ||
val control = Progress.control() | ||
|
||
control.value = 1.0 // must be between 0.0 and 1.0 (inclusive) | ||
``` | ||
|
||
A `ContainerProgressControl` allows you to depend on more than one `Progress` instances | ||
|
||
```kt | ||
val control = Progress.containerControl() | ||
|
||
// create a SingleProcessControl as a child | ||
// of this control | ||
val one = control.child() | ||
|
||
// create a ContainerProcessControl as a child | ||
// of this control | ||
val second = control.containerChild() | ||
|
||
// another child from the second | ||
// container with a custom weight | ||
// for determining the impact on | ||
// overall progress | ||
val third = second.child(0.5) | ||
|
||
// so this weighs heavy on the progress | ||
val fourth = second.child(2.0) | ||
``` | ||
|
||
##Progress | ||
Progress is the client part of progress tracking. You can register a callback for receiving updates on progress or | ||
just query the current state. This can be shared across threads. You obtain a `Progress` instance from a `ProgressControl` | ||
instance. | ||
|
||
```kt | ||
val control = //... | ||
val progress = control.progress | ||
|
||
progress.update { | ||
//called upon updates | ||
} | ||
|
||
// current value between 0.0 and 1.0 (inclusive) | ||
progress.value | ||
|
||
// boolean value that is true when progress.value == 1.0 | ||
progress.done | ||
|
||
``` | ||
|
||
|
||
|
||
##Example | ||
|
||
```kt | ||
val masterControl = Progress.containerControl() | ||
masterControl.progress.update { | ||
println("${value}") | ||
} | ||
|
||
val firstChild = masterControl.child(0.1) | ||
val secondChild = masterControl.containerChild(5.0) | ||
val secondChildFirstChild = secondChild.child() | ||
val secondChildSecondChild = secondChild.child() | ||
val thirdChild = masterControl.child() | ||
val fourthChild = masterControl.child(2.0) | ||
|
||
firstChild.value = 0.25 | ||
firstChild.value = 0.50 | ||
firstChild.value = 0.75 | ||
firstChild.value = 1.0 | ||
|
||
secondChildFirstChild.markAsDone() | ||
secondChildSecondChild.value = 0.5 | ||
secondChildSecondChild.value = 1.0 | ||
|
||
thirdChild.value = 0.25 | ||
thirdChild.value = 0.50 | ||
thirdChild.value = 0.75 | ||
thirdChild.value = 1.0 | ||
|
||
fourthChild.value = 0.25 | ||
fourthChild.value = 0.50 | ||
fourthChild.value = 0.75 | ||
fourthChild.value = 1.0 | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,42 @@ | ||
#Progress | ||
Track progress for [Kotlin](http://kotlinlang.org) | ||
|
||
[![CircleCI branch](https://img.shields.io/circleci/project/mplatvoet/progress/master.svg)](https://circleci.com/gh/mplatvoet/progress/tree/master) [![Maven Central](https://img.shields.io/maven-central/v/nl.komponents.progress/progress.svg)](http://search.maven.org/#browse%7C-300825966) [![DUB](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/mplatvoet/progress/blob/master/LICENSE) | ||
|
||
```kt | ||
//TODO | ||
//private part | ||
val control = Progress.control() | ||
|
||
//public part | ||
val progress = control.progress | ||
|
||
//get notified on updates | ||
progress.update { | ||
println("${value}") | ||
} | ||
|
||
//set value | ||
control.value = 0.25 | ||
control.value = 0.50 | ||
control.value = 0.75 | ||
control.value = 1.0 | ||
``` | ||
|
||
## Getting started | ||
This version is build against `Java 7` and `kotlin-stdlib:0.11.91`. | ||
This version is build against `kotlin-stdlib:0.12.200`. | ||
|
||
###Gradle | ||
```groovy | ||
dependencies { | ||
compile 'nl.mplatvoet.komponents:progress:x.x.x' | ||
compile 'nl.komponents.progress:progress:0.1.+' | ||
} | ||
``` | ||
|
||
###Maven | ||
```xml | ||
<dependency> | ||
<groupId>nl.mplatvoet.komponents</groupId> | ||
<groupId>nl.komponents.progress</groupId> | ||
<artifactId>progress</artifactId> | ||
<version>x.x.x</version> | ||
<version>[0.1.0, 0.2.0)</version> | ||
</dependency> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,6 @@ repo_name: 'GitHub' | |
|
||
pages: | ||
- ['index.md', 'Home'] | ||
- ['documentation.md', 'Documentation'] | ||
|
||
theme_dir: theme/yeti |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,28 @@ | ||
#Sun May 03 08:59:15 CEST 2015 | ||
# | ||
# Copyright (c) 2015 Mark Platvoet<mplatvoet@gmail.com> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
# | ||
|
||
#Tue Jun 09 21:11:52 CEST 2015 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-rc-1-all.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.