cool hit counter Blessed are those who use MVP and Dagger in their projects!!! Absolute efficiency gains_Intefrankly

Blessed are those who use MVP and Dagger in their projects!!! Absolute efficiency gains

Original article address:

Blessed are those who use MVP and Dagger in their projects!!! Absolute efficiency gains

  • In the previous in the article Mentions why we use theMVP,Dagger,Rxjava , which answers the questions of many people who are just getting into these techniques
  • As the project iterates, Increase in code volume, The benefits they bring to us will become increasingly apparent, nevertheless (located) at Pre-development in There is definitely one thing that bothers a lot of my friends, That's every page written, They all write a lot moreMVP harmonyDagger classes harmony interface, Although it can be reused, But there's still a lot of copying and pasting to be done., Actually, these documents It's all just some stencil code, Most of them just change it. documents nothing more than a name, So is there a way to automatically generate these template codes?

Generating Template Code with Template

note!!! current (located) at Template This article is based on an upgrade that supports one-click generation of all documents and is highly configurable. Please do remember, Star. Thank you.

(located) at JessYan With the tireless efforts of the company, it can now even One click generates the entire Module Please don't miss it!

If it has been used beforeTemplate Then you can skip to the end. It's attached.MVPArms frameworksMVP andDagger Templates for related classes, current (located) at Can be used very easilyMVPArms framework, build your ownMVP+Dagger2+Retrofit+Rxjava project, you just focus on the logic and leave the rest toMVPArms

1.Add Template


2.Using templates to generate related classes


caveat emptor

  • As for what this framework is going to generate for a page documents, please useDemo inmvp charteredUserActivity as an example, Refer again to the following caveat emptor
  • Generate the MVP and Dagger code for the corresponding page through Template, please note that the name entered in the input box must be the same
  • Since the package structure of each project is not necessarily the same, you need to import the package name for each generated file, you can set the automatic import package name in the settings
  • invite (located) at The corresponding code is generated under the corresponding package in the following order,Contract->Model->Presenter->Activity->Module->Component, If I want to create a new name for aUser ofActivity generate a counterpart documents, Well, I'm going to start. (located) atContract use under a packageContract Template GenerationUserContract, Follow this sequence until you have generatedUserComponent
  • Because when the Activity is generated in this order, the Module and Component are not yet generated, but there are references to them in the Activity, so an error will be reported, but ignore it
  • After generating the Module and Component, compile the project and go back to the Activity and change a method name in the setupActivityComponent() method as prompted
  • If you want to generate a Fragment related file, replace the Activity in the above build order with a Fragment and change the parameters of the inject method in the Component interface generated by the template to this Fragment
  • If you do not use this framework can also be adjusted according to their own needs or create their own templates, automatically generate their own desiredmvp harmonydagger documents


Template rules are in the project root of theMVP_generator_solution file

Hello My name is Jessyan, if you like my articles, you can follow me on the following platforms?

1、To improve AR object classification Facebook opensources Detectron computer vision algorithm
2、MIT uses deep learning techniques to identify objects in photos taken in the dark
3、Apple patent developing selfdriving VR ride system for an immersive ride experience
4、Digital currency cash machines have been installed video of digital currency ATMs taking cash throughout
5、ASME2017 full set of electronic versions and other standards

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送