Exemple #1
0
  public static ObjectInfo CreateFromXml(XmlPullParser parser) {
    ObjectInfo info = new ObjectInfo();
    info.mName = parser.getAttributeValue(null, ObjectInfoColumns.OBJECT_NAME);
    String shaderType = parser.getAttributeValue(null, ObjectInfoColumns.SHADER_TYPE);
    if (shaderType != null) {
      info.mShaderType = Integer.parseInt(shaderType);
    }
    info.mSceneName = parser.getAttributeValue(null, ObjectInfoColumns.SCENE_NAME);
    String componentName = parser.getAttributeValue(null, ObjectInfoColumns.COMPONENT_NAME);
    if (componentName != null) {
      info.mComponentName = ComponentName.unflattenFromString(componentName);
    }
    String slotType = parser.getAttributeValue(null, ObjectInfoColumns.SLOT_TYPE);
    if ("wall".equals(slotType)) {
      info.mSlotType = ObjectInfo.SLOT_TYPE_WALL;
    } else if ("desktop".equals(slotType)) {
      info.mSlotType = ObjectInfo.SLOT_TYPE_DESKTOP;
    } else if ("ground".equals(slotType)) {
      info.mSlotType = ObjectInfo.SLOT_TYPE_GROUND;
    } else if ("sky".equals(slotType)) {
      info.mSlotType = ObjectInfo.SLOT_TYPE_SKY;
    }

    info.mVesselName = parser.getAttributeValue(null, "vesselName");
    String vesselIndex = parser.getAttributeValue(null, "vesselIndex");
    if (!TextUtils.isEmpty(vesselIndex)) {
      info.mVesselIndex = Integer.parseInt(vesselIndex);
    }

    String slotIndex = parser.getAttributeValue(null, "slotIndex");
    if (!TextUtils.isEmpty(slotIndex)) {
      info.mObjectSlot.mSlotIndex = Integer.parseInt(slotIndex);
    }
    String slotStartX = parser.getAttributeValue(null, "slotStartX");
    if (!TextUtils.isEmpty(slotStartX)) {
      info.mObjectSlot.mStartX = Integer.parseInt(slotStartX);
    }
    String slotStartY = parser.getAttributeValue(null, "slotStartY");
    if (!TextUtils.isEmpty(slotStartY)) {
      info.mObjectSlot.mStartY = Integer.parseInt(slotStartY);
    }
    String slotSpanX = parser.getAttributeValue(null, "slotSpanX");
    if (!TextUtils.isEmpty(slotSpanX)) {
      info.mObjectSlot.mSpanX = Integer.parseInt(slotSpanX);
    }
    String slotSpanY = parser.getAttributeValue(null, "slotSpanY");
    if (!TextUtils.isEmpty(slotSpanY)) {
      info.mObjectSlot.mSpanY = Integer.parseInt(slotSpanY);
    }

    String className = parser.getAttributeValue(null, ObjectInfoColumns.CLASS_NAME);
    if (!TextUtils.isEmpty(className)) {
      info.mClassName = className;
    }

    String isnative = parser.getAttributeValue(null, ObjectInfoColumns.IS_NATIVE_OBJ);
    if (!TextUtils.isEmpty(isnative)) {
      if (Integer.parseInt(isnative) > 0) {
        info.mIsNativeObject = true;
      } else {
        info.mIsNativeObject = false;
      }
    }

    String index = parser.getAttributeValue(null, ObjectInfoColumns.OBJECT_INDEX);
    if (!TextUtils.isEmpty(index)) {
      info.mIndex = Integer.parseInt(index);
    }
    String type = parser.getAttributeValue(null, ObjectInfoColumns.OBJECT_TYPE);
    if (!TextUtils.isEmpty(type)) {
      info.mType = type;
    }

    return info;
  }