This file contains hidden or 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
pragma solidity ^0.4.7; | |
contract Report { | |
struct report { | |
uint id; | |
string detail; | |
} | |
mapping(uint => report) public reports; |
This file contains hidden or 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
fun ImageView.show(imageUrl: String = "") { | |
if (context == null) return | |
if (context is Activity && ((context as Activity).isFinishing || (context as Activity).isDestroyed)) return | |
Glide.with(context) | |
.load(imageUrl) | |
.crossFade() | |
.signature(StringSignature(UUID.randomUUID().toString())) | |
.into(this) |
This file contains hidden or 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
public static void main(String[] args) throws IOException { | |
MvpPoet poet = new MvpPoet("com.babedev.javapoetcodelab", "Sample"); | |
poet.generateMvp(); | |
} |
This file contains hidden or 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
package com.babedev.javapoetcodelab.sample; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import java.lang.Override; | |
class SampleActivity extends Activity implements SampleView { | |
private SamplePresenter mPresenter; |
This file contains hidden or 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(); |
This file contains hidden or 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
package com.babedev.javapoetcodelab.sample; | |
class SamplePresenter { | |
private SampleView mView; | |
/** | |
* Attach View | |
*/ | |
void attachView(SampleView view) { |
This file contains hidden or 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
ClassName.bestGuess(packageName + "." + featureName.toLowerCase() + "." + featureName + "View"); |
This file contains hidden or 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
package com.babedev.javapoetcodelab.sample; | |
interface SampleView { | |
} |
This file contains hidden or 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 generatePresenter() throws IOException { | |
MethodSpec attachView = MethodSpec.methodBuilder("attachView") | |
.addJavadoc(CodeBlock.of("Attach View")) | |
.addParameter(getViewType(), "view") | |
.addStatement("mView = view") | |
.build(); | |
TypeSpec mvpPresenter = TypeSpec.classBuilder(featureName + "Presenter") | |
.addMethod(attachView) | |
.addField(getViewType(), "mView", Modifier.PRIVATE) |
This file contains hidden or 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 generateView() throws IOException { | |
TypeSpec mvpView = TypeSpec.interfaceBuilder(featureName + "View") | |
.build(); | |
JavaFile javaFile = JavaFile.builder(packageName + "." + featureName.toLowerCase(), mvpView) | |
.build(); | |
File file = new File("app/src/main/java"); | |
javaFile.writeTo(file); | |
} |