Ejemplo n.º 1
0
 public void updateToDB(final boolean icon, final boolean disPalyName, final boolean url) {
   UpdateDBThread.getInstance()
       .process(
           new Runnable() {
             public void run() {
               String where = ObjectInfoColumns.OBJECT_ID + "=" + mID;
               ContentValues values = new ContentValues();
               if (disPalyName) {
                 values.put(ObjectInfoColumns.DISPLAY_NAME, mDisplayName);
               }
               if (icon) {
                 if (mShortcutIcon != null && !mShortcutIcon.isRecycled()) {
                   HomeUtils.writeBitmap(values, mShortcutIcon);
                 } else {
                   mShortcutIcon = null;
                   values.putNull(ObjectInfoColumns.SHORTCUT_URL);
                 }
               }
               if (url) {
                 values.put(ObjectInfoColumns.SHORTCUT_URL, mShortcutUrl);
               }
               mContentResolver.update(ObjectInfoColumns.CONTENT_URI, values, where, null);
             }
           });
 }
Ejemplo n.º 2
0
 public void releaseDB() {
   UpdateDBThread.getInstance()
       .process(
           new Runnable() {
             public void run() {
               String where = ObjectInfoColumns._ID + "=" + mID;
               mContentResolver.delete(ObjectInfoColumns.CONTENT_URI, where, null);
             }
           });
 }
Ejemplo n.º 3
0
 public void updateSlotTypeDB() {
   UpdateDBThread.getInstance()
       .process(
           new Runnable() {
             public void run() {
               String where = ObjectInfoColumns._ID + "=" + mID;
               ContentValues values = new ContentValues();
               values.put(ObjectInfoColumns.SLOT_TYPE, mSlotType);
               mContentResolver.update(ObjectInfoColumns.CONTENT_URI, values, where, null);
             }
           });
 }
Ejemplo n.º 4
0
 public void updateSlotDB() {
   UpdateDBThread.getInstance()
       .process(
           new Runnable() {
             public void run() {
               String where = VesselColumns.OBJECT_ID + "=" + mID;
               ContentValues values = new ContentValues();
               saveSlotToDB(values);
               mContentResolver.update(VesselColumns.CONTENT_URI, values, where, null);
             }
           });
 }
Ejemplo n.º 5
0
 public void updateFaceColor(int color) {
   mFaceColor = color;
   UpdateDBThread.getInstance()
       .process(
           new Runnable() {
             public void run() {
               String where = ObjectInfoColumns._ID + "=" + mID;
               ContentValues values = new ContentValues();
               values.put(ObjectInfoColumns.FACE_COLOR, mFaceColor);
               mContentResolver.update(ObjectInfoColumns.CONTENT_URI, values, where, null);
             }
           });
 }
Ejemplo n.º 6
0
 public void saveToDB(final Runnable finishListener) {
   UpdateDBThread.getInstance()
       .process(
           new Runnable() {
             public void run() {
               if (mID >= 0) {
                 updateSlotDB();
                 if (finishListener != null) {
                   finishListener.run();
                 }
                 return;
               }
               ContentValues values = new ContentValues();
               saveToDB(values);
               Uri insertUri = mContentResolver.insert(ObjectInfoColumns.CONTENT_URI, values);
               if (insertUri != null) {
                 long rowId = ContentUris.parseId(insertUri);
                 mID = (int) rowId;
                 mObjectSlot.mObjectID = mID;
                 if (mVesselName != null) {
                   String where =
                       ObjectInfoColumns.OBJECT_NAME
                           + "='"
                           + mVesselName
                           + "' and "
                           + ObjectInfoColumns.SCENE_NAME
                           + "='"
                           + mSceneName
                           + "' and "
                           + ObjectInfoColumns.OBJECT_INDEX
                           + "="
                           + mVesselIndex;
                   String[] columns = {ObjectInfoColumns.OBJECT_ID};
                   Cursor cursor =
                       mContentResolver.query(
                           ObjectInfoColumns.CONTENT_URI, columns, where, null, null);
                   if (cursor != null) {
                     if (cursor.moveToFirst()) {
                       mObjectSlot.mVesselID = cursor.getInt(0);
                     }
                     cursor.close();
                   }
                 }
                 saveSlotToDB();
               }
               if (finishListener != null) {
                 finishListener.run();
               }
             }
           });
 }
Ejemplo n.º 7
0
 public void updateComponentName(ComponentName name) {
   mComponentName = name;
   mShortcutUrl = null;
   mShortcutIcon = null;
   mDisplayName = null;
   UpdateDBThread.getInstance()
       .process(
           new Runnable() {
             public void run() {
               String where = ObjectInfoColumns._ID + "=" + mID;
               ContentValues values = new ContentValues();
               values.put(ObjectInfoColumns.COMPONENT_NAME, mComponentName.flattenToShortString());
               values.putNull(ObjectInfoColumns.SHORTCUT_URL);
               values.putNull(ObjectInfoColumns.SHORTCUT_ICON);
               values.putNull(ObjectInfoColumns.DISPLAY_NAME);
               mContentResolver.update(ObjectInfoColumns.CONTENT_URI, values, where, null);
             }
           });
   mIntent = null;
 }
Ejemplo n.º 8
0
 public ComponentName getCategoryComponentName() {
   if (mComponentName == null && mIsNativeObject) {
     if (mModelInfo.mComponentName != null) {
       mComponentName = mModelInfo.mComponentName;
     } else {
       mComponentName = HomeUtils.getCategoryComponentName(mContext, mModelInfo.mKeyWords);
     }
     if (mComponentName != null) {
       UpdateDBThread.getInstance()
           .process(
               new Runnable() {
                 public void run() {
                   String where = ObjectInfoColumns._ID + "=" + mID;
                   ContentValues values = new ContentValues();
                   values.put(
                       ObjectInfoColumns.COMPONENT_NAME, mComponentName.flattenToShortString());
                   mContentResolver.update(ObjectInfoColumns.CONTENT_URI, values, where, null);
                 }
               });
     }
   }
   return mComponentName;
 }