GithubHelp home page GithubHelp logo

stefb965 / kotgo Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nekocode/create-android-kotlin-app

0.0 2.0 0.0 1.9 MB

๐Ÿš€ An android development framework using MVP architecture on kotlin.

License: Apache License 2.0

Kotlin 78.14% Python 21.86%

kotgo's Introduction

README

Apache 2.0 License Release Join the chat at https://gitter.im/nekocode/kotgo

Create Template Project

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.

Description

Kotgo is an android development framework using MVP architecture, it is built entirely with Kotlin. There are some related articles talk about it.

Package structure

cn.nekocode.kotgo.sample
โ”œโ”€ data
โ”‚  โ”œโ”€ DO
โ”‚  โ”œโ”€ repo
โ”‚  โ””โ”€ service
โ”‚ 
โ”œโ”€ ui
โ”‚  โ””โ”€ screen_one
โ”‚     โ”œโ”€ Contract.kt
โ”‚     โ”œโ”€ Presenter.kt
โ”‚     โ””โ”€ Activity.kt
โ”‚
โ””โ”€ App.kt

Dependencies

  • 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

Sample

Thanks to gank.io. The sample app fetchs photos from it.

Another more perfect Sample: Murmur

Component Library

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>'
}

RxLifecycle & RxBus

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)
        }

Fragment Presenter

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.")
    }
}

Single Activity Multiple Fragments

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()

kotgo's People

Contributors

nekocode avatar sirrah avatar gitter-badger avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.