Library with Android code base for MVVM architecture with DataBinding and Dagger2 for dependency injection.
- Add it in your root build.gradle:
allprojects {
repositories {
maven { url "https://dl.bintray.com/anapsil83/maven-android" }
}
}
- Add the dependency:
implementation 'net.anapsil.android.mvvm:library:0.1.0'
- Add the bintray repository to your maven file:
<repository>
<id>bintray-anapsil83-maven-android</id>
<url>https://dl.bintray.com/anapsil83/maven-android</url>
</repository>
- Add the dependency in the form
<dependency>
<groupId>net.anapsil.android.mvvm</groupId>
<artifactId>library</artifactId>
<version>0.1.0</version>
</dependency>
Create your AppComponent class and add @Component annotation and set the modules AndroidSupportInjectionModule and AppModule. Also include your application modules.
@Singleton
@Component(modules = {AndroidSupportInjectionModule.class, AppModule.class})
public interface AppComponent extends AndroidInjector<DemoApplication> {
@Component.Builder
abstract class Builder extends AndroidInjector.Builder<DemoApplication> {
}
}
Create your custom application extending net.anapsil.mvvmbase.App.class.
public class DemoApplication extends App {
@Override
protected AndroidInjector<? extends DaggerApplication> applicationInjector() {
return DaggerAppComponent.builder().create(this);
}
}
Copyright (C) 2018 - Ana Paula da Silva
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.