Skip to content

Commit 23f864e

Browse files
committed
Android UI context implementation and Guide to UI programming with coroutines
1 parent 4fe1801 commit 23f864e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+2126
-27
lines changed

README.md

+23-13
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,33 @@
22

33
Library support for Kotlin coroutines. This is a companion version for Kotlin 1.1.0 release.
44

5-
## Modules and features
6-
7-
* [kotlinx-coroutines-core](kotlinx-coroutines-core) module with core primitives to work with coroutines.
8-
* This module's functionality is covered by the [guide to kotlinx.coroutines](coroutines-guide.md).
9-
* [kotlinx-coroutines-jdk8](kotlinx-coroutines-jdk8) module with additional libraries for JDK8 (or Android API level 24).
10-
* [kotlinx-coroutines-nio](kotlinx-coroutines-nio) module with extensions for asynchronous IO on JDK7+.
11-
* [kotlinx-coroutines-swing](kotlinx-coroutines-swing) module with `Swing` context for Swing UI applications.
12-
* [kotlinx-coroutines-javafx](kotlinx-coroutines-javafx) module with `JavaFx` context for JavaFX UI applications.
13-
* [kotlinx-coroutines-reactive](kotlinx-coroutines-reactive) module with utilities for [Reactive Streams](http://www.reactive-streams.org)
14-
* [kotlinx-coroutines-rx1](kotlinx-coroutines-rx1) module with utilities for [RxJava 1.x](https://github.com/ReactiveX/RxJava/tree/1.x)
15-
* [kotlinx-coroutines-rx2](kotlinx-coroutines-rx2) module with utilities for [RxJava 2.x](https://github.com/ReactiveX/RxJava)
5+
## Modules
6+
7+
Basic modules:
8+
9+
* [kotlinx-coroutines-core](kotlinx-coroutines-core) -- core primitives to work with coroutines.
10+
* [kotlinx-coroutines-jdk8](kotlinx-coroutines-jdk8) -- additional libraries for JDK8 (or Android API level 24).
11+
* [kotlinx-coroutines-nio](kotlinx-coroutines-nio) -- extensions for asynchronous IO on JDK7+.
12+
13+
Modules that provide builders and iteration support for various reactive streams libraries:
14+
15+
* [kotlinx-coroutines-reactive](kotlinx-coroutines-reactive) -- utilities for [Reactive Streams](http://www.reactive-streams.org)
16+
* [kotlinx-coroutines-rx1](kotlinx-coroutines-rx1) -- utilities for [RxJava 1.x](https://github.com/ReactiveX/RxJava/tree/1.x)
17+
* [kotlinx-coroutines-rx2](kotlinx-coroutines-rx2) -- utilities for [RxJava 2.x](https://github.com/ReactiveX/RxJava)
18+
19+
Modules that provide coroutine dispatchers for various single-threaded UI libraries:
20+
21+
* [kotlinx-coroutines-android](ui/kotlinx-coroutines-android) -- `UI` context for Android applications.
22+
* [kotlinx-coroutines-javafx](ui/kotlinx-coroutines-javafx) -- `JavaFx` context for JavaFX UI applications.
23+
* [kotlinx-coroutines-swing](ui/kotlinx-coroutines-swing) -- `Swing` context for Swing UI applications.
1624

17-
## References and documentation
25+
## Documentation
1826

19-
* [Guide to kotlinx.coroutines by example](coroutines-guide.md)
27+
* [Guide to kotlinx.coroutines by example](coroutines-guide.md) (**read it first**)
28+
* [Guide to UI programming with coroutines](ui/coroutines-guide-ui.md)
2029
* [Change log for kotlinx.coroutines](CHANGES.md)
2130
* [Coroutines design document (KEEP)](https://github.com/Kotlin/kotlin-coroutines/blob/master/kotlin-coroutines-informal.md)
31+
* [Full kotlinx.coroutines API reference](http://kotlin.github.io/kotlinx.coroutines)
2232

2333
## Using in your projects
2434

knit/src/Knit.kt

+10-6
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ fun knit(markdownFileName: String) {
6767
val test = arrayListOf<String>()
6868
var testOut: PrintWriter? = null
6969
var lastPgk: String? = null
70-
val files = mutableSetOf<String>()
70+
val files = mutableSetOf<File>()
7171
val allApiRefs = arrayListOf<ApiRef>()
7272
val remainingApiRefNames = mutableSetOf<String>()
7373
var siteRoot: String? = null
@@ -190,8 +190,9 @@ fun knit(markdownFileName: String) {
190190
}
191191
knitRegex?.find(inLine)?.let { knitMatch ->
192192
val fileName = knitMatch.groups[1]!!.value
193-
require(files.add(fileName)) { "Duplicate file name: $fileName"}
194-
println("Knitting $fileName ...")
193+
val file = File(markdownFile.parentFile, fileName)
194+
require(files.add(file)) { "Duplicate file: $file"}
195+
println("Knitting $file ...")
195196
val outLines = arrayListOf<String>()
196197
for (include in includes) {
197198
val includeMatch = include.regex.matchEntire(fileName) ?: continue
@@ -204,7 +205,6 @@ fun knit(markdownFileName: String) {
204205
}
205206
outLines += code
206207
code.clear()
207-
val file = File(fileName)
208208
val oldLines = try { file.readLines() } catch (e: IOException) { emptyList<String>() }
209209
if (outLines != oldLines) writeLines(file, outLines)
210210
}
@@ -401,7 +401,6 @@ fun loadApiIndex(
401401
namePrefix: String = ""
402402
): Map<String, String> {
403403
val fileName = docsRoot + "/" + path + INDEX_MD
404-
println("Reading index from $fileName")
405404
val visited = mutableSetOf<String>()
406405
val map = HashMap<String,String>()
407406
File(fileName).withLineNumberReader<LineNumberReader>(::LineNumberReader) {
@@ -431,7 +430,12 @@ fun processApiIndex(
431430
remainingApiRefNames: MutableSet<String>
432431
): List<String> {
433432
val key = ApiIndexKey(docsRoot, pkg)
434-
val map = apiIndexCache.getOrPut(key, { loadApiIndex(docsRoot, pkg, pkg) })
433+
val map = apiIndexCache.getOrPut(key, {
434+
print("Parsing API docs at $docsRoot: ")
435+
val result = loadApiIndex(docsRoot, pkg, pkg)
436+
println("${result.size} definitions")
437+
result
438+
})
435439
val indexList = arrayListOf<String>()
436440
val it = remainingApiRefNames.iterator()
437441
while (it.hasNext()) {

pom.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,15 @@
9797

9898
<modules>
9999
<module>kotlinx-coroutines-core</module>
100-
<module>kotlinx-coroutines-swing</module>
101-
<module>kotlinx-coroutines-javafx</module>
102100
<module>kotlinx-coroutines-jdk8</module>
103101
<module>kotlinx-coroutines-nio</module>
104102
<module>kotlinx-coroutines-reactive</module>
105103
<module>kotlinx-coroutines-rx1</module>
106104
<module>kotlinx-coroutines-rx2</module>
107105
<module>kotlinx-coroutines-rx-example</module>
106+
<module>ui/kotlinx-coroutines-swing</module>
107+
<module>ui/kotlinx-coroutines-javafx</module>
108+
<module>ui/kotlinx-coroutines-android</module>
108109
<module>site</module>
109110
</modules>
110111

site/build.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
<fileset dir="../kotlinx-coroutines-core/target/dokka" includes="**/*.md"/>
2222
<fileset dir="../kotlinx-coroutines-jdk8/target/dokka" includes="**/*.md"/>
2323
<fileset dir="../kotlinx-coroutines-nio/target/dokka" includes="**/*.md"/>
24-
<fileset dir="../kotlinx-coroutines-swing/target/dokka" includes="**/*.md"/>
25-
<fileset dir="../kotlinx-coroutines-javafx/target/dokka" includes="**/*.md"/>
2624
<fileset dir="../kotlinx-coroutines-reactive/target/dokka" includes="**/*.md"/>
2725
<fileset dir="../kotlinx-coroutines-rx1/target/dokka" includes="**/*.md"/>
2826
<fileset dir="../kotlinx-coroutines-rx2/target/dokka" includes="**/*.md"/>
27+
<fileset dir="../ui/kotlinx-coroutines-android/target/dokka" includes="**/*.md"/>
28+
<fileset dir="../ui/kotlinx-coroutines-javafx/target/dokka" includes="**/*.md"/>
29+
<fileset dir="../ui/kotlinx-coroutines-swing/target/dokka" includes="**/*.md"/>
2930
</copy>
3031
<antcall target="jekyll"/>
3132
</target>

ui/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Coroutines for UI
2+
3+
This directory contains modules for coroutine programming with various single-threaded UI libraries:
4+
5+
## Modules
6+
7+
* [kotlinx-coroutines-android](kotlinx-coroutines-android) -- `UI` context for Android applications.
8+
* [kotlinx-coroutines-javafx](kotlinx-coroutines-javafx) -- `JavaFx` context for JavaFX UI applications.
9+
* [kotlinx-coroutines-swing](kotlinx-coroutines-swing) -- `Swing` context for Swing UI applications.

0 commit comments

Comments
 (0)