ShapeTranslater.java 文件源码

java
阅读 18 收藏 0 点赞 0 评论 0

项目:AndroidXMLToJava 作者:
@Override
public String translate() {
    AX2JCodeBlock codeBlock = new AX2JCodeBlock(GradientDrawable.class, getRoot().getObjectName());
    for (AX2JNode node : getRoot().getChildren()) {
        if (node.getLabelName().equals("gradient")) {
            String orientation;
            Attribute attribute = node.findAttrByName("android:angle");
            orientation = (attribute == null)? "Orientation.TOP_BOTTOM" : translateValue(codeBlock, attribute, Integer.class);
            addImport(Orientation.class);
            codeBlock.add("GradientDrawable " + getRoot().getObjectName() + " = new GradientDrawable(" +
                    orientation + ", null);\n", AX2JCode.PRIORITY_SECOND);
        } else if(node.getLabelName().equals("solid")) {
            codeBlock.add("GradientDrawable " + getRoot().getObjectName() + " = new GradientDrawable();\n", AX2JCode.PRIORITY_SECOND);
        }
    }
    addCodeBlock(codeBlock);

    return super.translate();
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号