Skip to content

Commit dfe41d0

Browse files
authored
Update README.md
1 parent d4c8b56 commit dfe41d0

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

README.md

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,49 @@
1-
# README
1+
# README
2+
3+
This project shows how to build an android application with kotlin and some useful libraries. It intergates the [Meepo](https://github.com/nekocode/Meepo) library to create activity & broadcast routers. And use kotlin language sugars to make their usages simpler. For example:
4+
5+
```kotlin
6+
// Goto a new activity
7+
activityRouter().gotoXxxActivity(this)
8+
9+
// Broadcast a action
10+
broadcastRouter().tellSomeSth(this)
11+
12+
// Receiver a broadcast
13+
registerLocalReceiver({ _, intent ->
14+
val action = (intent ?: return@registerLocalReceiver).action
15+
?: return@registerLocalReceiver
16+
when (action) {
17+
"ACTION_XXX" -> {
18+
// Do sth
19+
}
20+
}
21+
}, "ACTION_XXX", "ACTION_XXX2")
22+
```
23+
24+
It intergates the [Retrofit](https://github.com/square/retrofit) library to help making http requests:
25+
26+
```kotlin
27+
gankIoService().picApi.getMeiziPics(1, 0)
28+
// ...
29+
```
30+
31+
And it splits the backend logic (file and network operations that not relate to ui) into a submodule. And make them easier to test:
32+
33+
```kotlin
34+
class GankIoServiceTest {
35+
private val gankIoService = GankIoService(OkHttpClient(), Gson())
36+
37+
@Test
38+
fun getMeiziPics() {
39+
gankIoService.picApi.getMeiziPics(10, 0)
40+
.test()
41+
.assertNoErrors()
42+
.assertValue { response ->
43+
!response.error && response.results.size == 10
44+
}
45+
}
46+
}
47+
```
48+
49+
Please reference the code to see more details.

0 commit comments

Comments
 (0)