Example #1
0
  public static ObjectInfo CreateFromDB(Cursor cursor) {
    ObjectInfo info = new ObjectInfo();
    info.mAppWidgetId = cursor.getInt(cursor.getColumnIndexOrThrow(ObjectInfoColumns.WIDGET_ID));
    info.mName = cursor.getString(cursor.getColumnIndexOrThrow(ObjectInfoColumns.OBJECT_NAME));
    info.mType = cursor.getString(cursor.getColumnIndexOrThrow(ObjectInfoColumns.OBJECT_TYPE));
    info.mID = cursor.getInt(cursor.getColumnIndexOrThrow(ObjectInfoColumns._ID));
    info.mShaderType = cursor.getInt(cursor.getColumnIndexOrThrow(ObjectInfoColumns.SHADER_TYPE));
    info.mSceneName = cursor.getString(cursor.getColumnIndexOrThrow(ObjectInfoColumns.SCENE_NAME));
    String componentName =
        cursor.getString(cursor.getColumnIndexOrThrow(ObjectInfoColumns.COMPONENT_NAME));
    if (componentName != null) {
      info.mComponentName = ComponentName.unflattenFromString(componentName);
    }
    info.mSlotType = cursor.getInt(cursor.getColumnIndexOrThrow(ObjectInfoColumns.SLOT_TYPE));
    info.mObjectSlot.mObjectID =
        cursor.getInt(cursor.getColumnIndexOrThrow(VesselColumns.OBJECT_ID));
    info.mObjectSlot.mVesselID =
        cursor.getInt(cursor.getColumnIndexOrThrow(VesselColumns.VESSEL_ID));
    info.mObjectSlot.mSlotIndex =
        cursor.getInt(cursor.getColumnIndexOrThrow(VesselColumns.SLOT_INDEX));
    info.mObjectSlot.mStartX =
        cursor.getInt(cursor.getColumnIndexOrThrow(VesselColumns.SLOT_StartX));
    info.mObjectSlot.mStartY =
        cursor.getInt(cursor.getColumnIndexOrThrow(VesselColumns.SLOT_StartY));
    info.mObjectSlot.mSpanX = cursor.getInt(cursor.getColumnIndexOrThrow(VesselColumns.SLOT_SpanX));
    info.mObjectSlot.mSpanY = cursor.getInt(cursor.getColumnIndexOrThrow(VesselColumns.SLOT_SpanY));

    info.mClassName = cursor.getString(cursor.getColumnIndexOrThrow(ObjectInfoColumns.CLASS_NAME));
    byte[] bytes = cursor.getBlob(cursor.getColumnIndexOrThrow(ObjectInfoColumns.SHORTCUT_ICON));
    if (bytes != null) {
      info.mShortcutIcon = BitmapFactory.decodeByteArray(bytes, 0, bytes.length, null);
    }

    int nativeObj = cursor.getInt(cursor.getColumnIndexOrThrow(ObjectInfoColumns.IS_NATIVE_OBJ));
    if (nativeObj > 0) {
      info.mIsNativeObject = true;
    } else {
      info.mIsNativeObject = false;
    }
    info.mShortcutUrl =
        cursor.getString(cursor.getColumnIndexOrThrow(ObjectInfoColumns.SHORTCUT_URL));
    info.mIndex = cursor.getInt(cursor.getColumnIndexOrThrow(ObjectInfoColumns.OBJECT_INDEX));
    info.mDisplayName =
        cursor.getString(cursor.getColumnIndexOrThrow(ObjectInfoColumns.DISPLAY_NAME));
    info.mFaceColor = cursor.getInt(cursor.getColumnIndexOrThrow(ObjectInfoColumns.FACE_COLOR));
    return info;
  }
Example #2
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;
  }