You can createOrGet a new Kotgo template project fast by using the following command. Just paste and execute it at a terminal prompt. Have fun!
python -c "$(curl -fsSL https://raw.githubusercontent.com/nekocode/kotgo/master/project_creator.py)"
Of course, you can also download the python script to your local disk to run it. It depends on the requests
lib.
Kotgo is an android development framework using MVP architecture, it is built entirely with Kotlin. There are some related articles talk about it.
cn.nekocode.kotgo.sample
โโ data
โ โโ DO
โ โโ repo
โ โโ service
โ
โโ ui
โ โโ screen_one
โ โโ Contract.kt
โ โโ Presenter.kt
โ โโ Activity.kt
โ
โโ App.kt
- kotlin:
1.1.1
- anko:
0.9.1
- rxkotlin:
2.0.0-RC3
- retrofit:
2.2.0
- picasso:
2.5.2
- paper:
2.0.0
- paperparcel:
2.0.0
Thanks to gank.io. The sample app fetchs photos from it.
Another more perfect Sample: Murmur
You can only use the kotgo's component library. It provides many useful tools to help you to build a MVP project fast and simply. Just add the JitPack repository to your root build.gradle:
repositories {
maven { url "https://jitpack.io" }
}
And then add the dependency to your sub build.gradle:
dependencies {
compile 'com.github.nekocode:kotgo:<lastest-version>'
}
You can bind the RxJava subscriptions into the lifecycle of the class that implements RxLifecycle.Impl
(such as base activity, fragment and presenter). It can help you unsubscribe the Observable
when the activity or fragment is destoried.
MeiziRepo.getMeizis(50, 1)
.bindLifecycle()
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
view.refreshMeizis(it)
}
And you can use RxBus
to send events everywhere.
RxBus.send("Success")
RxBus.toObserverable(String::class.java)
.bindLifecycle()
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
showToast(it)
}
This library uses fragment to implement presenter.
class MeiziPresenter(): KtPresenter<Contract.View>(), Contract.Presenter {
override fun onViewCreated(view: Contract.View?, savedInstanceState: Bundle?) {
view?.showToast("View created.")
}
}
You can build applications with only one single KtFragmentActivity
. Then use fragment instead of activity to make pages. The KtFragmentActivity
and KtPresenter
provides some functions to help you manage the fragments in the stack. Such as:
push()
pushForResult()
popThis()
popAll()
popUntil()
popTop()
pop()
startActivityForResult()