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.0.4 - anko:
0.9 - rxkotlin:
0.60.0 - retrofit:
2.1.0 - picasso:
2.5.2 - hawk:
2.0.0-Alpha - paperparcel:
1.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(presenter).onUI {
view.refreshMeizis(it)
}And you can use RxBus to send events everywhere. And then subscribe them in the class that implements RxLifecycle.Impl
RxBus.send("Success")
RxBus.subscribe(String::class.java) { showToast(it) }This library uses fragment to implement presenter.
class MeiziPresenter(): BasePresenter<Contract.View>(), Contract.Presenter {
override fun onViewCreated(view: Contract.View?, savedInstanceState: Bundle?) {
view?.showToast("View created.")
}
}You can build applications with only one single FragmentActivity. Then use fragment instead of activity to make pages. The FragmentActivity provides following functions to help you manage the fragment page in the stack.
push()
pushForResult()
popAll()
popUntil()
popTop()
startActivityForResult()