Giter Site home page Giter Site logo

haikuowuya / moxy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from arello-mobile/moxy

1.0 1.0 0.0 616 KB

Moxy is MVP library for Android

Home Page: https://github.com/Arello-Mobile/Moxy/wiki

License: MIT License

Java 95.58% FreeMarker 3.44% Kotlin 0.98%

moxy's Introduction

Moxy

Maven Central license

Moxy is a library that help to use MVP pattern when you do the Android Application. Without problems of lifecycle and boilerplate code!

Main idea of using Moxy: schematic_using See what's happening here in the wiki.

Capabilities

Moxy has a few killer features on other ways:

  • Presenter stay alive when Activity recreated(it simplify work with multithreading)
  • Automatically restore all what user see when Activity recreated(including dynamic content is added)
  • Capability to changes of many Views from one Presenter

Sample

View interface

public interface HelloWorldView extends MvpView {
	void showMessage(int message);
}

Presenter

@InjectViewState
public class HelloWorldPresenter extends MvpPresenter<HelloWorldView> {
	public HelloWorldPresenter() {
		getViewState().showMessage(R.string.hello_world);
	}
}

View implementation

public class HelloWorldActivity extends MvpAppCompatActivity implements HelloWorldView {

	@InjectPresenter
	HelloWorldPresenter mHelloWorldPresenter;

	private TextView mHelloWorldTextView;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_hello_world);

		mHelloWorldTextView = ((TextView) findViewById(R.id.activity_hello_world_text_view_message));
	}

	@Override
	public void showMessage(int message) {
		mHelloWorldTextView.setText(message);
	}
}

Here you can see "Github" sample application.

Wiki

For all information check Moxy Wiki

Android studio templates

In order to avoid boilerplate code creating for binding activity,fragments and its presentation part, we propose to use Android Studio templates for Moxy.

Templates located in /moxy-templates

Links

Telegram channel (en)
Telegram channel (ru)
References
FAQ

Integration

Base modules integration:

dependencies {
  ...
  compile 'com.arello-mobile:moxy:1.2.1'
  provided 'com.arello-mobile:moxy-compiler:1.2.1'
}

If you want to see generated code, use apt instead of provided dependency type:

dependencies {
  ...
  apt 'com.arello-mobile:moxy-compiler:1.2.1'
}

For additional base view classes MvpActivity and MvpFragment add this:

dependencies {
  ...
  compile 'com.arello-mobile:moxy-android:1.2.1'
}

If you planing to use AppCompat, then you can use MvpAppCompatActivity and MvpAppCompatFragment. Then add this:

dependencies {
  ...
  compile 'com.arello-mobile:moxy-app-compat:1.2.1'
  compile 'com.android.support:appcompat-v7:$support_version'
}

Kotlin

If you are using kotlin, use kapt instead of provided/apt dependency type and set generateStubs property of kapt to true:

dependencies {
  ...
  kapt 'com.arello-mobile:moxy-compiler:1.2.1'
}
kapt {
    generateStubs = true
}

ProGuard

If you are using ProGuard you might need to add the following option:

-keep class **$$PresentersBinder
-keep class **$$State
-keep class **$$ViewStateClassNameProvider
-keepnames class * extends com.arellomobile.mvp.*

License

The MIT License (MIT)

Copyright (c) 2016 Arello Mobile

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

moxy's People

Contributors

senneco avatar xanderblinov avatar savinmike avatar cherryperry avatar fl1pflops avatar dmdevgo avatar terrakok avatar

Stargazers

haikuowuya avatar

Watchers

haikuowuya 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.