Ejemplo n.º 1
0
 public boolean contain(ObjectSlot slot) {
   if (left() <= slot.left()
       && right() >= slot.right()
       && top() <= slot.top()
       && bottom() >= slot.bottom()) {
     return true;
   }
   return false;
 }
Ejemplo n.º 2
0
 public void saveToDB(SQLiteDatabase db) {
   String where =
       ObjectInfoColumns.OBJECT_NAME
           + "='"
           + mName
           + "' and "
           + ObjectInfoColumns.SCENE_NAME
           + "='"
           + mSceneName
           + "' and "
           + ObjectInfoColumns.OBJECT_INDEX
           + "="
           + mIndex;
   Cursor cursor = null;
   try {
     cursor = db.query(Tables.OBJECTS_INFO, null, where, null, null, null, null);
     if (cursor != null) {
       if (cursor.moveToFirst()) {
         return;
       }
     }
   } finally {
     if (cursor != null) {
       cursor.close();
     }
   }
   ContentValues values = new ContentValues();
   saveToDB(values);
   mID = (int) db.insert(Tables.OBJECTS_INFO, null, values);
   mObjectSlot.mObjectID = mID;
   if (mVesselName != null) {
     where =
         ObjectInfoColumns.OBJECT_NAME
             + "='"
             + mVesselName
             + "' and "
             + ObjectInfoColumns.SCENE_NAME
             + "='"
             + mSceneName
             + "' and "
             + ObjectInfoColumns.OBJECT_INDEX
             + "="
             + mVesselIndex;
     String[] columns = {ObjectInfoColumns.OBJECT_ID};
     cursor = db.query(Tables.OBJECTS_INFO, columns, where, null, null, null, null);
     if (cursor != null) {
       if (cursor.moveToFirst()) {
         mObjectSlot.mVesselID = cursor.getInt(0);
       }
       cursor.close();
     }
   }
   saveSlotToDB(db);
 }
Ejemplo n.º 3
0
 @Override
 public ObjectSlot clone() {
   ObjectSlot newSlot = new ObjectSlot();
   newSlot.mSlotIndex = mSlotIndex;
   newSlot.mStartX = mStartX;
   newSlot.mStartY = mStartY;
   newSlot.mSpanX = mSpanX;
   newSlot.mSpanY = mSpanY;
   newSlot.mVesselID = mVesselID;
   return newSlot;
 }
Ejemplo n.º 4
0
 public void setModelInfo(ModelInfo modelInfo) {
   mModelInfo = modelInfo;
   if (mModelInfo != null) {
     mActionStatus = mModelInfo.mActionStatus;
     if (mSlotType == SLOT_TYPE_UNKNOWN) {
       mSlotType = mModelInfo.mSlotType;
     }
     mName = mModelInfo.mName;
     mType = mModelInfo.mType;
     if (mObjectSlot.mSpanX <= 0) {
       mObjectSlot.mSpanX = mModelInfo.mSpanX;
     }
     if (mObjectSlot.mSpanY <= 0) {
       mObjectSlot.mSpanY = mModelInfo.mSpanY;
     }
     mIsNativeObject = true;
     mMinPoint = mModelInfo.mMinPoint.clone();
     mMaxPoint = mModelInfo.mMaxPoint.clone();
     if (mModelInfo.mSlotType == ObjectInfo.SLOT_TYPE_DESKTOP) {
       mObjectSlot.mSpanX = 1;
       mObjectSlot.mSpanY = 1;
     }
   }
 }
Ejemplo n.º 5
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;
  }
Ejemplo n.º 6
0
 public boolean isRight(ObjectSlot other) {
   return left() >= other.right() && right() >= other.right();
 }
Ejemplo n.º 7
0
 public boolean isLeft(ObjectSlot other) {
   return left() <= other.left() && right() <= other.left();
 }
Ejemplo n.º 8
0
 public boolean isBelow(ObjectSlot other) {
   return top() >= other.bottom() && bottom() >= other.bottom();
 }
Ejemplo n.º 9
0
 public boolean isAbove(ObjectSlot other) {
   return top() <= other.top() && bottom() <= other.top();
 }
Ejemplo n.º 10
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;
  }
Ejemplo n.º 11
0
 public void setSpanY(int spanY) {
   mObjectSlot.mSpanY = spanY;
 }
Ejemplo n.º 12
0
 public void setSpanX(int spanX) {
   mObjectSlot.mSpanX = spanX;
 }