Create android kotlin app by template.
Branch: master
Clone or download
Latest commit aaf1a9e Jan 27, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
app Upgrade stuffs Jan 27, 2019
backend Upgrade stuffs Jan 27, 2019
gradle/wrapper
.gitignore Update gitignore file Jul 26, 2018
LICENSE Add license file Jul 26, 2018
README.md Update README.md Oct 8, 2018
build.gradle Upgrade stuffs Jan 27, 2019
create-android-kotlin-app.py Update creator script Jul 27, 2018
gradle.properties Upgrade stuffs Jan 27, 2019
gradlew Initial commit of refactoring Jul 25, 2018
gradlew.bat Initial commit of refactoring Jul 25, 2018
settings.gradle Tidy up the gradle scripts Jul 26, 2018

README.md

README

This is an android application template project built with kotlin language and some useful libraries. It provides a creator script to quickly create an project from template.

Creating project

Make sure you have installed Python 3 and requests library before proceeding. And then paste the following command at a terminal, replace the PROJECT_NAME and APP_PACKAGE_NAME and execute it:

python3 -c \
"$(curl -fsSL https://raw.githubusercontent.com/nekocode/create-android-kotlin-app/master/create-android-kotlin-app.py)" \
PROJECT_NAME \
APP_PACKAGE_NAME

What is included

The template project imports the Meepo library to create activity & broadcast routers. And use kotlin language sugars to make their usages simpler. For example:

// Goto a new activity
activityRouter().gotoXxxActivity(this)

// Broadcast a action
broadcastRouter().tellSomeSth(this)

// Receiver a broadcast
registerLocalReceiver({ _, intent ->
    val action = (intent ?: return@registerLocalReceiver).action
            ?: return@registerLocalReceiver
    when (action) {
        "ACTION_XXX" -> {
            // Do sth
        }
    }
}, "ACTION_XXX", "ACTION_XXX2")

Sending a network request in this project is also simple:

gankIoService().picApi.getMeiziPics(1, 0)
    // ...

And the network operations are separated into a submodule. Some tests are created for them:

class GankIoServiceTest {
    private val gankIoService = GankIoService(OkHttpClient(), Gson())

    @Test
    fun getMeiziPics() {
        gankIoService.picApi.getMeiziPics(10, 0)
                .test()
                .assertNoErrors()
                .assertValue { response ->
                    !response.error && response.results.size == 10
                }
    }
}

In addition, it creates some extention methods for AutoDispose so that you can automatically dispose your rx stream more conveniently:

// ... Rx stream
        .autoDispose()
        .subscribe()

For more details, you can look at the code of template directly.