Search in sources :

Example 91 with JBlock

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

the class EActivityHolder method setInitNonConfigurationInstance.

private void setInitNonConfigurationInstance() throws JClassAlreadyExistsException {
    JBlock initBody = getInitBodyInjectionBlock();
    JDefinedClass ncHolderClass = getNonConfigurationHolder().getGeneratedClass();
    initNonConfigurationInstance = initBody.decl(ncHolderClass, "nonConfigurationInstance", cast(ncHolderClass, _super().invoke(getGetLastNonConfigurationInstance())));
    initIfNonConfigurationNotNullBlock = initBody._if(initNonConfigurationInstance.ne(_null()))._then();
}
Also used : JDefinedClass(com.helger.jcodemodel.JDefinedClass) JBlock(com.helger.jcodemodel.JBlock)

Example 92 with JBlock

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

the class EActivityHolder method setOnCreate.

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

Example 93 with JBlock

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

the class EActivityHolder method setInjectExtras.

private void setInjectExtras() {
    injectExtrasMethod = generatedClass.method(PRIVATE, getCodeModel().VOID, "injectExtras" + generationSuffix());
    JBlock injectExtrasBody = injectExtrasMethod.body();
    injectExtras = injectExtrasBody.decl(getClasses().BUNDLE, "extras_", invoke("getIntent").invoke("getExtras"));
    injectExtrasBlock = injectExtrasBody._if(injectExtras.ne(_null()))._then();
    getSetIntent().body().invoke(injectExtrasMethod);
    getInitBodyInjectionBlock().invoke(injectExtrasMethod);
}
Also used : JBlock(com.helger.jcodemodel.JBlock)

Example 94 with JBlock

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

the class EActivityHolder 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 95 with JBlock

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

the class EActivityHolder method setFindNativeFragmentByTag.

@Override
protected void setFindNativeFragmentByTag() {
    JMethod method = generatedClass.method(PRIVATE, getClasses().FRAGMENT, "findNativeFragmentByTag");
    JVar tagParam = method.param(getClasses().STRING, "tag");
    JBlock body = method.body();
    body._return(invoke("getFragmentManager").invoke("findFragmentByTag").arg(tagParam));
    findNativeFragmentByTag = method;
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Aggregations

JBlock (com.helger.jcodemodel.JBlock)148 JVar (com.helger.jcodemodel.JVar)81 JMethod (com.helger.jcodemodel.JMethod)73 JInvocation (com.helger.jcodemodel.JInvocation)37 AbstractJClass (com.helger.jcodemodel.AbstractJClass)35 IJExpression (com.helger.jcodemodel.IJExpression)31 ExecutableElement (javax.lang.model.element.ExecutableElement)25 JFieldRef (com.helger.jcodemodel.JFieldRef)19 JDefinedClass (com.helger.jcodemodel.JDefinedClass)15 VariableElement (javax.lang.model.element.VariableElement)15 TypeMirror (javax.lang.model.type.TypeMirror)13 JFieldVar (com.helger.jcodemodel.JFieldVar)11 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 TextWatcherHolder (org.androidannotations.holder.TextWatcherHolder)3 AbstractJType (com.helger.jcodemodel.AbstractJType)2 IJAssignmentTarget (com.helger.jcodemodel.IJAssignmentTarget)2