Last active
January 5, 2017 08:51
-
-
Save babedev/f4d63b789881580cc3c03cf1b0e64491 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void generateActivity() throws IOException { | |
MethodSpec onCreate = MethodSpec.methodBuilder("onCreate") | |
.addAnnotation(Override.class) | |
.addModifiers(Modifier.PUBLIC) | |
.returns(void.class) | |
.addParameter(Bundle.class, "savedInstanceState") | |
.addComment("TODO setContentView()") | |
.addStatement("mPresenter = new $T()", getPresenterType()) | |
.addStatement("mPresenter.attachView(this)") | |
.build(); | |
TypeSpec mvpActivity = TypeSpec.classBuilder(featureName + "Activity") | |
.superclass(Activity.class) | |
.addSuperinterface(getViewType()) | |
.addField(getPresenterType(), "mPresenter", Modifier.PRIVATE) | |
.addMethod(onCreate) | |
.build(); | |
JavaFile javaFile = JavaFile.builder(packageName + "." + featureName.toLowerCase(), mvpActivity) | |
.build(); | |
File file = new File("app/src/main/java"); | |
javaFile.writeTo(file); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment