项目作者: anapsil

项目描述 :
Android code base for MVVM architecture with DataBinding
高级语言: Java
项目地址: git://github.com/anapsil/android-mvvm-base.git
创建时间: 2018-01-17T16:01:43Z
项目社区:https://github.com/anapsil/android-mvvm-base

开源协议:

下载


ANDROID MVVM BASE Build Status API

Library with Android code base for MVVM architecture with DataBinding and Dagger2 for dependency injection.

Installation

Latest version

Gradle

  • Add it in your root build.gradle:

    1. allprojects {
    2. repositories {
    3. maven { url "https://dl.bintray.com/anapsil83/maven-android" }
    4. }
    5. }
  • Add the dependency:

    1. implementation 'net.anapsil.android.mvvm:library:0.1.0'

Maven

  • Add the bintray repository to your maven file:
  1. <repository>
  2. <id>bintray-anapsil83-maven-android</id>
  3. <url>https://dl.bintray.com/anapsil83/maven-android</url>
  4. </repository>
  • Add the dependency in the form
    1. <dependency>
    2. <groupId>net.anapsil.android.mvvm</groupId>
    3. <artifactId>library</artifactId>
    4. <version>0.1.0</version>
    5. </dependency>

    How to use

Dependency injection

Create your AppComponent class and add @Component annotation and set the modules AndroidSupportInjectionModule and AppModule.
Also include your application modules.

  1. @Singleton
  2. @Component(modules = {AndroidSupportInjectionModule.class, AppModule.class})
  3. public interface AppComponent extends AndroidInjector<DemoApplication> {
  4. @Component.Builder
  5. abstract class Builder extends AndroidInjector.Builder<DemoApplication> {
  6. }
  7. }

Application

Create your custom application extending net.anapsil.mvvmbase.App.class.

  1. public class DemoApplication extends App {
  2. @Override
  3. protected AndroidInjector<? extends DaggerApplication> applicationInjector() {
  4. return DaggerAppComponent.builder().create(this);
  5. }
  6. }

License

  1. Copyright (C) 2018 - Ana Paula da Silva
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.