Search in sources :

Example 1 with BindingAttributeMappings

use of org.robobinding.viewbinding.BindingAttributeMappings in project RoboBinding by RoboBinding.

the class ViewBindingObjectClassGen method defineMapBindingAttributesMethod.

/**
 *    	@Override
 *    	public void mapBindingAttributes(BindingAttributeMappings<ImageView> mappings) {
 *    		mappings.mapOneWayProperty(ImageAlphaAttribute.class, "imageAlpha");
 *    		mappings.mapOneWayProperty(MaxWidthAttribute.class, "maxWidth");
 *    		mappings.mapOneWayProperty(MaxHeightAttribute.class, "maxHeight");
 *
 *    		customViewBinding.mapBindingAttributes(mappings);
 *    	}
 */
public void defineMapBindingAttributesMethod() {
    JMethod method = definedClass.method(JMod.PUBLIC, codeModel.VOID, "mapBindingAttributes");
    method.annotate(Override.class);
    AbstractJClass bindingAttributeMappingsType = codeModel.ref(BindingAttributeMappings.class).narrow(viewClass);
    JVar mappingsParam = method.param(bindingAttributeMappingsType, "mappings");
    JBlock body = method.body();
    for (SimpleOneWayPropertyInfo info : simpleOneWayPropertyInfoList) {
        body.invoke(mappingsParam, "mapOneWayProperty").arg(info.getBindingClass().dotclass()).arg(info.propertyName());
    }
    body.invoke(customViewBindingFieldWithoutThis, "mapBindingAttributes").arg(mappingsParam);
}
Also used : BindingAttributeMappings(org.robobinding.viewbinding.BindingAttributeMappings) JBlock(com.helger.jcodemodel.JBlock) AbstractJClass(com.helger.jcodemodel.AbstractJClass) JMethod(com.helger.jcodemodel.JMethod) JVar(com.helger.jcodemodel.JVar)

Aggregations

AbstractJClass (com.helger.jcodemodel.AbstractJClass)1 JBlock (com.helger.jcodemodel.JBlock)1 JMethod (com.helger.jcodemodel.JMethod)1 JVar (com.helger.jcodemodel.JVar)1 BindingAttributeMappings (org.robobinding.viewbinding.BindingAttributeMappings)1