Search in sources :

Example 41 with JBlock

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

the class RoboGuiceHandler method onRestartMethod.

private void onRestartMethod(EActivityHolder holder, JFieldVar eventManager) {
    JBlock onRestartAfterSuperBlock = holder.getOnRestartAfterSuperBlock();
    fireEvent(eventManager, onRestartAfterSuperBlock, getJClass(RoboGuiceClasses.ON_RESTART_EVENT));
}
Also used : JBlock(com.helger.jcodemodel.JBlock)

Example 42 with JBlock

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

the class RoboGuiceHandler method onNewIntentMethod.

private void onNewIntentMethod(EActivityHolder holder, JFieldVar eventManager) {
    JBlock onNewIntentAfterSuperBlock = holder.getOnNewIntentAfterSuperBlock();
    fireEvent(eventManager, onNewIntentAfterSuperBlock, getJClass(RoboGuiceClasses.ON_NEW_INTENT_EVENT));
}
Also used : JBlock(com.helger.jcodemodel.JBlock)

Example 43 with JBlock

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

the class RoboGuiceHandler method onActivityResultMethod.

private void onActivityResultMethod(EActivityHolder holder, JFieldVar eventManager) {
    JBlock onActivityResultAfterSuperBlock = holder.getOnActivityResultAfterSuperBlock();
    JVar requestCode = holder.getOnActivityResultRequestCodeParam();
    JVar resultCode = holder.getOnActivityResultResultCodeParam();
    JVar data = holder.getOnActivityResultDataParam();
    fireEvent(eventManager, onActivityResultAfterSuperBlock, getJClass(RoboGuiceClasses.ON_ACTIVITY_RESULT_EVENT), requestCode, resultCode, data);
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JVar(com.helger.jcodemodel.JVar)

Example 44 with JBlock

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

the class RoboGuiceHandler method beforeCreateMethod.

private void beforeCreateMethod(EActivityHolder holder, JFieldVar scope, JFieldVar scopedObjects, JFieldVar eventManager) {
    JBlock body = holder.getInitBody();
    AbstractJClass keyWildCard = getJClass(RoboGuiceClasses.KEY).narrow(getCodeModel().wildcard());
    AbstractJClass scopedHashMap = getClasses().HASH_MAP.narrow(keyWildCard, getClasses().OBJECT);
    body.assign(scopedObjects, JExpr._new(scopedHashMap));
    JVar injector = body.decl(getJClass(RoboGuiceClasses.ROBO_INJECTOR), "injector_", getJClass(RoboGuiceClasses.ROBO_GUICE).staticInvoke("getInjector").arg(_this()));
    body.assign(scope, invoke(injector, "getInstance").arg(getJClass(RoboGuiceClasses.CONTEXT_SCOPE).dotclass()));
    body.assign(eventManager, invoke(injector, "getInstance").arg(getJClass(RoboGuiceClasses.EVENT_MANAGER).dotclass()));
    body.add(injector.invoke("injectMembersWithoutViews").arg(_this()));
    fireEvent(eventManager, body, getJClass(RoboGuiceClasses.ON_CREATE_EVENT), holder.getInitSavedInstanceParam());
}
Also used : JBlock(com.helger.jcodemodel.JBlock) AbstractJClass(com.helger.jcodemodel.AbstractJClass) JVar(com.helger.jcodemodel.JVar)

Example 45 with JBlock

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

the class RoboGuiceHandler method onStopMethod.

private void onStopMethod(EActivityHolder holder, JFieldVar eventManager) {
    JBlock onStopBlock = new JBlock().bracesRequired(false).indentRequired(false);
    JTryBlock tryBlock = onStopBlock._try();
    fireEvent(eventManager, tryBlock.body(), getJClass(RoboGuiceClasses.ON_STOP_EVENT));
    JBlock finallyBody = tryBlock._finally();
    finallyBody.invoke(_super(), "onStop");
    JMethod onStop = holder.getOnStop();
    codeModelHelper.replaceSuperCall(onStop, onStopBlock);
}
Also used : JBlock(com.helger.jcodemodel.JBlock) JTryBlock(com.helger.jcodemodel.JTryBlock) 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