Search in sources :

Example 51 with IJExpression

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

the class ReceiverRegistrationDelegate method createIntentFilterField.

private JFieldVar createIntentFilterField(IntentFilterData intentFilterData) {
    String intentFilterName = "intentFilter" + (intentFilterFields.size() + 1) + generationSuffix();
    IJExpression newIntentFilterExpr = _new(getClasses().INTENT_FILTER);
    JFieldVar intentFilterField = getGeneratedClass().field(PRIVATE | FINAL, getClasses().INTENT_FILTER, intentFilterName, newIntentFilterExpr);
    JBlock intentFilterTarget = holder.getIntentFilterInitializationBlock(intentFilterData);
    for (String action : intentFilterData.getActionSet()) {
        intentFilterTarget.invoke(intentFilterField, "addAction").arg(action);
    }
    for (String dataScheme : intentFilterData.getDataSchemeSet()) {
        intentFilterTarget.invoke(intentFilterField, "addDataScheme").arg(dataScheme);
    }
    return intentFilterField;
}
Also used : JFieldVar(com.helger.jcodemodel.JFieldVar) IJExpression(com.helger.jcodemodel.IJExpression) JBlock(com.helger.jcodemodel.JBlock)

Example 52 with IJExpression

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

the class AbstractResHandler method assignValue.

@Override
public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, EComponentHolder holder, Element element, Element param) {
    IRClass.Res resInnerClass = androidRes.getRInnerClass();
    JFieldRef idRef = annotationHelper.extractOneAnnotationFieldRef(element, resInnerClass, true);
    IJExpression resourceInstance = getInstanceInvocation(holder, idRef, fieldRef, targetBlock);
    if (resourceInstance != null) {
        targetBlock.add(fieldRef.assign(resourceInstance));
    }
}
Also used : JFieldRef(com.helger.jcodemodel.JFieldRef) IRClass(org.androidannotations.rclass.IRClass) IJExpression(com.helger.jcodemodel.IJExpression)

Example 53 with IJExpression

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

the class ExtraParameterHandler method getExtraValue.

public IJExpression getExtraValue(VariableElement parameter, JVar extras, JBlock block, JMethod annotatedMethod, JDefinedClass generatedClass) {
    String parameterName = parameter.getSimpleName().toString();
    AbstractJClass parameterClass = codeModelHelper.typeMirrorToJClass(parameter.asType());
    String extraKey = getAnnotationValue(parameter);
    if (extraKey == null || extraKey.isEmpty()) {
        extraKey = parameterName;
    }
    BundleHelper bundleHelper = new BundleHelper(getEnvironment(), parameter.asType());
    IJExpression restoreMethodCall = bundleHelper.getExpressionToRestoreFromBundle(parameterClass, extras, getStaticExtraField(generatedClass, extraKey), annotatedMethod);
    return block.decl(parameterClass, parameterName, restoreMethodCall);
}
Also used : IJExpression(com.helger.jcodemodel.IJExpression) AbstractJClass(com.helger.jcodemodel.AbstractJClass) BundleHelper(org.androidannotations.helper.BundleHelper)

Example 54 with IJExpression

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

the class PreferencesDelegate method createFoundPreferenceAndIfNotNullBlock.

private FoundPreferenceHolder createFoundPreferenceAndIfNotNullBlock(JFieldRef idRef, AbstractJClass preferenceClass, IJAssignmentTarget fieldRef) {
    IJExpression findPreferenceExpression = findPreferenceByKey(idRef);
    JBlock block = getAddPreferencesFromResourceInjectionBlock();
    if (preferenceClass == null) {
        preferenceClass = basePreferenceClass;
    } else if (!preferenceClass.equals(basePreferenceClass)) {
        findPreferenceExpression = cast(preferenceClass, findPreferenceExpression);
    }
    IJAssignmentTarget foundPref = fieldRef;
    if (foundPref == null) {
        foundPref = block.decl(preferenceClass, "preference_" + idRef.name(), findPreferenceExpression);
    } else {
        block.add(foundPref.assign(findPreferenceExpression));
    }
    return new FoundPreferenceHolder(this, preferenceClass, foundPref, block);
}
Also used : IJExpression(com.helger.jcodemodel.IJExpression) JBlock(com.helger.jcodemodel.JBlock) IJAssignmentTarget(com.helger.jcodemodel.IJAssignmentTarget)

Aggregations

IJExpression (com.helger.jcodemodel.IJExpression)54 JVar (com.helger.jcodemodel.JVar)32 JBlock (com.helger.jcodemodel.JBlock)31 JInvocation (com.helger.jcodemodel.JInvocation)27 AbstractJClass (com.helger.jcodemodel.AbstractJClass)23 TypeMirror (javax.lang.model.type.TypeMirror)20 ExecutableElement (javax.lang.model.element.ExecutableElement)16 JFieldRef (com.helger.jcodemodel.JFieldRef)15 JMethod (com.helger.jcodemodel.JMethod)15 VariableElement (javax.lang.model.element.VariableElement)12 JFieldVar (com.helger.jcodemodel.JFieldVar)7 JConditional (com.helger.jcodemodel.JConditional)6 JDefinedClass (com.helger.jcodemodel.JDefinedClass)5 BundleHelper (org.androidannotations.helper.BundleHelper)5 JTryBlock (com.helger.jcodemodel.JTryBlock)4 JCatchBlock (com.helger.jcodemodel.JCatchBlock)3 PageChangeHolder (org.androidannotations.holder.PageChangeHolder)3 TextWatcherHolder (org.androidannotations.holder.TextWatcherHolder)3 IJAssignmentTarget (com.helger.jcodemodel.IJAssignmentTarget)2 OnSeekBarChangeListenerHolder (org.androidannotations.holder.OnSeekBarChangeListenerHolder)2