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); } }); }
public void releaseDB() { UpdateDBThread.getInstance() .process( new Runnable() { public void run() { String where = ObjectInfoColumns._ID + "=" + mID; mContentResolver.delete(ObjectInfoColumns.CONTENT_URI, where, null); } }); }
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); } }); }
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); } }); }
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); } }); }
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(); } } }); }
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; }
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; }