use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class ViewByIdHandler method assignValue.
@Override
public void assignValue(JBlock targetBlock, IJAssignmentTarget fieldRef, EComponentWithViewSupportHolder holder, Element element, Element param) {
TypeMirror uiFieldTypeMirror = param.asType();
JFieldRef idRef = annotationHelper.extractOneAnnotationFieldRef(element, IRClass.Res.ID, true);
AbstractJClass viewClass = codeModelHelper.typeMirrorToJClass(uiFieldTypeMirror);
IJAssignmentTarget viewHolderTarget = null;
if (element.getKind() == ElementKind.FIELD) {
viewHolderTarget = fieldRef;
}
FoundViewHolder viewHolder = holder.getFoundViewHolder(idRef, viewClass, viewHolderTarget);
if (!viewHolder.getRef().equals(viewHolderTarget)) {
targetBlock.add(fieldRef.assign(viewHolder.getOrCastRef(viewClass)));
}
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class AnnotationParamExtractor method visitEnumConstant.
@Override
public Void visitEnumConstant(VariableElement c, String p) {
AbstractJClass annotationClass = helper.typeMirrorToJClass(c.asType());
JEnumConstantRef ref = JExpr.enumConstantRef(annotationClass, c.getSimpleName().toString());
use.param(p, ref);
return null;
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class ViewNotifierHelper method resetPreviousNotifier.
public void resetPreviousNotifier(JBlock block, JVar previousNotifier) {
AbstractJClass notifierClass = holder.getEnvironment().getJClass(OnViewChangedNotifier.class);
block.staticInvoke(notifierClass, "replaceNotifier").arg(previousNotifier);
}
use of com.helger.jcodemodel.AbstractJClass in project androidannotations by androidannotations.
the class SupposeUiThreadHandler method process.
@Override
public void process(Element element, EComponentHolder holder) throws Exception {
ExecutableElement executableElement = (ExecutableElement) element;
JMethod delegatingMethod = codeModelHelper.overrideAnnotatedMethod(executableElement, holder);
JBlock body = delegatingMethod.body();
AbstractJClass bgExecutor = getJClass(BackgroundExecutor.class);
body.pos(0);
body.staticInvoke(bgExecutor, METHOD_CHECK_UI_THREAD);
body.pos(body.getContents().size());
}
use of com.helger.jcodemodel.AbstractJClass in project RoboBinding by RoboBinding.
the class ViewBindingObjectClassGen method defineSimpleOneWayPropertyClasses.
/**
*
private static class ImageAlphaAttribute implements OneWayPropertyViewAttribute<ImageView, Integer> {
@Override
public void updateView(ImageView view, Integer newValue) {
view.setImageAlpha(newValue);
}
}
*
*/
public void defineSimpleOneWayPropertyClasses() {
for (SimpleOneWayPropertyInfo propInfo : simpleOneWayPropertyInfoList) {
JDefinedClass definedBindingAttributeClass = propInfo.defineBindingClass(new ClassDefinitionCallback() {
@Override
public JDefinedClass define(String typeName) {
try {
return definedClass._class(JMod.PUBLIC | JMod.STATIC, typeName);
} catch (JClassAlreadyExistsException e) {
throw new RuntimeException("Class '" + typeName + "' already exists", e);
}
}
});
AbstractJClass propertyClass = codeModel.ref(propInfo.propertyType());
AbstractJClass oneWayPropertyInterface = codeModel.ref(OneWayPropertyViewAttribute.class).narrow(viewClass, propertyClass);
definedBindingAttributeClass._implements(oneWayPropertyInterface);
JMethod method = definedBindingAttributeClass.method(JMod.PUBLIC, codeModel.VOID, "updateView");
method.annotate(Override.class);
JVar viewParam = method.param(viewClass, "view");
JVar newValueParam = method.param(propertyClass, "newValue");
JBlock body = method.body();
body.invoke(viewParam, propInfo.propertySetter()).arg(newValueParam);
}
}
Aggregations