Search in sources :

Example 41 with JMethod

use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.

the class EFragmentHolder method setOnOptionsItemSelected.

private void setOnOptionsItemSelected() {
    JMethod method = generatedClass.method(JMod.PUBLIC, getCodeModel().BOOLEAN, "onOptionsItemSelected");
    method.annotate(Override.class);
    JBlock methodBody = method.body();
    onOptionsItemSelectedItem = method.param(getClasses().MENU_ITEM, "item");
    onOptionsItemSelectedItemId = methodBody.decl(getCodeModel().INT, "itemId_", onOptionsItemSelectedItem.invoke("getItemId"));
    onOptionsItemSelectedMiddleBlock = methodBody.blockSimple();
    methodBody._return(invoke(_super(), method).arg(onOptionsItemSelectedItem));
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod)

Example 42 with JMethod

use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.

the class EFragmentHolder method setOnCreate.

private void setOnCreate() {
    JMethod onCreate = generatedClass.method(PUBLIC, getCodeModel().VOID, "onCreate");
    onCreate.annotate(Override.class);
    JVar onCreateSavedInstanceState = onCreate.param(getClasses().BUNDLE, "savedInstanceState");
    JBlock onCreateBody = onCreate.body();
    JVar previousNotifier = viewNotifierHelper.replacePreviousNotifier(onCreateBody);
    setFindViewById();
    onCreateBody.invoke(getInit()).arg(onCreateSavedInstanceState);
    onCreateBody.invoke(_super(), onCreate).arg(onCreateSavedInstanceState);
    onCreateAfterSuperBlock = onCreateBody.blockSimple();
    viewNotifierHelper.resetPreviousNotifier(onCreateBody, previousNotifier);
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 43 with JMethod

use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.

the class EFragmentHolder method setFindViewById.

private void setFindViewById() {
    JMethod findViewById = generatedClass.method(PUBLIC, getClasses().VIEW, "findViewById");
    findViewById.annotate(Override.class);
    JVar idParam = findViewById.param(getCodeModel().INT, "id");
    JBlock body = findViewById.body();
    JFieldVar contentView = getContentView();
    //
    body._if(contentView.eq(_null()))._then()._return(_null());
    body._return(contentView.invoke(findViewById).arg(idParam));
}
Also used : JFieldVar(com.helger.jcodemodel.JFieldVar) JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 44 with JMethod

use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.

the class EFragmentHolder method setOnCreateOptionsMenu.

private void setOnCreateOptionsMenu() {
    JMethod method = generatedClass.method(PUBLIC, getCodeModel().VOID, "onCreateOptionsMenu");
    method.annotate(Override.class);
    JBlock methodBody = method.body();
    onCreateOptionsMenuMenuParam = method.param(getClasses().MENU, "menu");
    onCreateOptionsMenuMenuInflaterVar = method.param(getClasses().MENU_INFLATER, "inflater");
    onCreateOptionsMenuMethodInflateBody = methodBody.blockSimple();
    onCreateOptionsMenuMethodBody = methodBody.blockSimple();
    methodBody.invoke(_super(), method).arg(onCreateOptionsMenuMenuParam).arg(onCreateOptionsMenuMenuInflaterVar);
    getInitBody().invoke("setHasOptionsMenu").arg(JExpr.TRUE);
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod)

Example 45 with JMethod

use of com.helger.jcodemodel.JMethod in project androidannotations by androidannotations.

the class EActivityHolder method setOnStart.

// CHECKSTYLE:OFF
private void setOnStart() {
    JMethod method = generatedClass.method(JMod.PUBLIC, getCodeModel().VOID, "onStart");
    method.annotate(Override.class);
    JBlock body = method.body();
    onStartBeforeSuperBlock = body.blockSimple();
    body.invoke(_super(), method);
    onStartAfterSuperBlock = body.blockSimple();
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod)

Aggregations

JMethod (com.helger.jcodemodel.JMethod)122 JBlock (com.helger.jcodemodel.JBlock)73 JVar (com.helger.jcodemodel.JVar)56 AbstractJClass (com.helger.jcodemodel.AbstractJClass)36 JInvocation (com.helger.jcodemodel.JInvocation)26 JDefinedClass (com.helger.jcodemodel.JDefinedClass)20 IJExpression (com.helger.jcodemodel.IJExpression)15 ExecutableElement (javax.lang.model.element.ExecutableElement)13 JFieldVar (com.helger.jcodemodel.JFieldVar)10 JConditional (com.helger.jcodemodel.JConditional)8 JTryBlock (com.helger.jcodemodel.JTryBlock)7 JTypeVar (com.helger.jcodemodel.JTypeVar)7 TypeMirror (javax.lang.model.type.TypeMirror)7 VariableElement (javax.lang.model.element.VariableElement)6 JFieldRef (com.helger.jcodemodel.JFieldRef)5 JPrimitiveType (com.helger.jcodemodel.JPrimitiveType)5 ArrayList (java.util.ArrayList)5 VisitorDefinition (com.github.sviperll.adt4j.model.config.VisitorDefinition)4 GenerationProcess (com.github.sviperll.adt4j.model.util.GenerationProcess)4 AbstractJType (com.helger.jcodemodel.AbstractJType)4