Search in sources :

Example 16 with JBlock

use of com.helger.jcodemodel.JBlock 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);
    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 17 with JBlock

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

the class EFragmentHolder method setOnCreateView.

private void setOnCreateView() {
    JMethod onCreateView = generatedClass.method(PUBLIC, getClasses().VIEW, "onCreateView");
    onCreateView.annotate(Override.class);
    inflater = onCreateView.param(getClasses().LAYOUT_INFLATER, "inflater");
    container = onCreateView.param(getClasses().VIEW_GROUP, "container");
    JVar savedInstanceState = onCreateView.param(getClasses().BUNDLE, "savedInstanceState");
    boolean forceInjection = getAnnotatedElement().getAnnotation(EFragment.class).forceLayoutInjection();
    JBlock body = onCreateView.body();
    if (!forceInjection) {
        body.assign(contentView, _super().invoke(onCreateView).arg(inflater).arg(container).arg(savedInstanceState));
    }
    setContentViewBlock = body.blockSimple();
    body._return(contentView);
}
Also used : JBlock(com.helger.jcodemodel.JBlock) EFragment(org.androidannotations.annotations.EFragment) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 18 with JBlock

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

the class EFragmentHolder method setOnViewCreated.

private void setOnViewCreated() {
    JMethod onViewCreated = generatedClass.method(PUBLIC, getCodeModel().VOID, "onViewCreated");
    onViewCreated.annotate(Override.class);
    JVar view = onViewCreated.param(getClasses().VIEW, "view");
    JVar savedInstanceState = onViewCreated.param(getClasses().BUNDLE, "savedInstanceState");
    JBlock onViewCreatedBody = onViewCreated.body();
    onViewCreatedBody.invoke(_super(), onViewCreated).arg(view).arg(savedInstanceState);
    viewNotifierHelper.invokeViewChanged(onViewCreatedBody);
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 19 with JBlock

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

the class EFragmentHolder method setOnAttach.

private void setOnAttach() {
    JMethod onAttach = generatedClass.method(PUBLIC, getCodeModel().VOID, "onAttach");
    onAttach.annotate(Override.class);
    JVar activityParam = onAttach.param(getClasses().ACTIVITY, "activity");
    JBlock onAttachBody = onAttach.body();
    onAttachBody.invoke(_super(), onAttach).arg(activityParam);
    onAttachAfterSuperBlock = onAttachBody.blockSimple();
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Example 20 with JBlock

use of com.helger.jcodemodel.JBlock 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)

Aggregations

JBlock (com.helger.jcodemodel.JBlock)155 JVar (com.helger.jcodemodel.JVar)86 JMethod (com.helger.jcodemodel.JMethod)75 AbstractJClass (com.helger.jcodemodel.AbstractJClass)40 JInvocation (com.helger.jcodemodel.JInvocation)38 IJExpression (com.helger.jcodemodel.IJExpression)31 ExecutableElement (javax.lang.model.element.ExecutableElement)26 JFieldRef (com.helger.jcodemodel.JFieldRef)19 JDefinedClass (com.helger.jcodemodel.JDefinedClass)15 VariableElement (javax.lang.model.element.VariableElement)15 JFieldVar (com.helger.jcodemodel.JFieldVar)13 TypeMirror (javax.lang.model.type.TypeMirror)13 JConditional (com.helger.jcodemodel.JConditional)10 JTryBlock (com.helger.jcodemodel.JTryBlock)9 JCatchBlock (com.helger.jcodemodel.JCatchBlock)4 TypeElement (javax.lang.model.element.TypeElement)3 PageChangeHolder (org.androidannotations.holder.PageChangeHolder)3 AbstractJType (com.helger.jcodemodel.AbstractJType)2 IJAssignmentTarget (com.helger.jcodemodel.IJAssignmentTarget)2 IJStatement (com.helger.jcodemodel.IJStatement)2