当前位置:网站首页>An auxiliary MVP architecture project quick development library -mvpfastdagger

An auxiliary MVP architecture project quick development library -mvpfastdagger

2022-06-25 09:51:00 seevc

Share a MVP Architecture development , It can help to generate corresponding mvp Open source library of files , You don't have to create it manually model、view、presenter、module、component The file , Improve development efficiency . Source code address :MvpFastDagger

MvpFastDagger

MVP+Dagger+Annotation Rapid generation of project architecture mvp Corresponding documents .

MVP+Dagger+Annotation Every new one in the architecture Activity or Fragment All need to be added XXPresenter、IXXview、IXXModel、XXModleImp、XXModule、XXComponent class , Adding manually is tedious , This library can help us quickly generate mvp Corresponding documents .

notes : This open source library is applicable to MVP+Dagger+Annotation Architecture projects . Need to be introduced into the project Dagger and Annotation These two open source libraries .

MvpFastDagger It only takes one step to use

When using this annotation , You need to create Activity class , And then use @MvpFastDagger.

How annotations are used :

/**
* name  Corresponding to the name of the class to be created 
* basePresenterClazz It needs to be created presenter The parent of a class ,
* iBaseViewClazz Is to create view The parent of a class ,
* iBaseModelClazz Is to create model The parent class of the interface class ,
* baseModelImpClazz Is to be generated ModelImp Parent class of ,
* scopeClazz Corresponding Imodel Iview Life cycle of ,
* modules Corresponding Dagger in @Component In the annotations modules Field ,
* dependencies It's corresponding to @Component In the annotations dependencies Field , This field is optional 
*/
@MvpFastDagger(name = "login",
    basePresenterClazz = BasePresenter.class,
    iBaseViewClazz = IViewAdvance.class,
    iBaseModelClazz = IModel.class,
    baseModelImpClazz = BaseModel.class,
    scopeClazz = PerActivity.class,
    modules = AppModule.class,
    dependencies = AppComponent.class)
public class LoginActivity extends BaseActivity<LoginPresenter> implements ILoginView {
	
	...

}

among name You can write your name directly , Such as :"login", It can be used "." Segmentation , Such as :“login.login”, This will generate login Catalog , This directory is regenerated into the corresponding java file .

take MvpFastDagger Into your project

stay Gradle Configure settings in :

1. At the root build.gradle The configuration in the file is as follows :

allprojects {
	repositories {
	    ...
	    
	    maven { url "https://jitpack.io" }  // Add the configuration , Enable compile time from jitpack Find resource in Library 
	}
}

2. stay app Project build.gradle Add reference to the document :

android {
	...
	defaultConfig {
    	javaCompileOptions{
    	    annotationProcessorOptions{
				arguments = ["fastDaggerIndex": "org.harry.fastdagger.demo",// Configure your package name here , The generated files will be in this directory 
                         "mvpSrcDir" : file("src/main/java").getAbsolutePath()]// Main works src route , Generally, this value does not need to be modified 
    	    }
    	}
	}
}

dependencies {
	...
	
	implementation 'com.github.zhang-hai:mvpfastdagger:1.1.0'		// Use mvpfastdagger library 
	annotationProcessor 'com.github.zhang-hai:mvpfastdagger:1.1.0'	// Use mvpfastdagger Annotation processor in the library 
	
}
原网站

版权声明
本文为[seevc]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202200547583320.html