X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/3e1aefb9e08f13f776b7ce6771555008805ab795..185aae4bc345f453479f94e2a78da62e8c9930b0:/src/com/owncloud/android/providers/FileContentProvider.java diff --git a/src/com/owncloud/android/providers/FileContentProvider.java b/src/com/owncloud/android/providers/FileContentProvider.java index f76ae94b..c84d66b0 100644 --- a/src/com/owncloud/android/providers/FileContentProvider.java +++ b/src/com/owncloud/android/providers/FileContentProvider.java @@ -24,7 +24,6 @@ import java.util.HashMap; import com.owncloud.android.R; import com.owncloud.android.db.ProviderMeta; import com.owncloud.android.db.ProviderMeta.ProviderTableMeta; -import com.owncloud.android.lib.resources.files.FileUtils; import com.owncloud.android.lib.resources.shares.ShareType; import com.owncloud.android.utils.Log_OC; @@ -142,57 +141,20 @@ public class FileContentProvider extends ContentProvider { @Override public int delete(Uri uri, String where, String[] whereArgs) { - Log_OC.d(TAG, "Deleting " + uri + " at provider " + this); + //Log_OC.d(TAG, "Deleting " + uri + " at provider " + this); int count = 0; SQLiteDatabase db = mDbHelper.getWritableDatabase(); db.beginTransaction(); - - // Get parentId to notify the change - long parentId = getParentId(uri); - - // Delete action try { count = delete(db, uri, where, whereArgs); db.setTransactionSuccessful(); } finally { db.endTransaction(); } - Log_OC.d(TAG, "Uri " + uri); getContext().getContentResolver().notifyChange(uri, null); - - // Notify the change to the parent folder - notifyChangeToParentUri(parentId); return count; } - private long getParentId(Uri uri) { - long parentId = -1; - - if (mUriMatcher.match(uri) == SINGLE_FILE || mUriMatcher.match(uri) == DIRECTORY) { - String fileId = uri.toString().substring(uri.toString().lastIndexOf(FileUtils.PATH_SEPARATOR) + 1); - Uri selectFileUri = Uri.withAppendedPath(ProviderTableMeta.CONTENT_URI_FILE, fileId); - String[] fileProjection = new String[] { ProviderTableMeta.FILE_PARENT }; - Cursor fileCursor = query(selectFileUri, fileProjection, null, null, null); - - if (fileCursor != null && fileCursor.moveToFirst()) { - parentId = fileCursor.getLong(fileCursor.getColumnIndex(ProviderTableMeta.FILE_PARENT)); - } - fileCursor.close(); - } - Log_OC.d(TAG, "getParentId = " + parentId); - return parentId; - } - - private void notifyChangeToParentUri(long parentId) { - if (parentId != -1) { - Uri parentUri = Uri.withAppendedPath( - ProviderTableMeta.CONTENT_URI_DIR, - String.valueOf(parentId)); - Log_OC.d(TAG, "ParentUri " + parentUri); - getContext().getContentResolver().notifyChange(parentUri, null); - } - } - private int delete(SQLiteDatabase db, Uri uri, String where, String[] whereArgs) { int count = 0; switch (mUriMatcher.match(uri)) { @@ -290,12 +252,9 @@ public class FileContentProvider extends ContentProvider { @Override public Uri insert(Uri uri, ContentValues values) { //Log_OC.d(TAG, "Inserting " + values.getAsString(ProviderTableMeta.FILE_PATH) + " at provider " + this); - Log_OC.d(TAG, "Uri " + uri); Uri newUri = null; SQLiteDatabase db = mDbHelper.getWritableDatabase(); db.beginTransaction(); - - // Insert action try { newUri = insert(db, uri, values); db.setTransactionSuccessful(); @@ -303,12 +262,6 @@ public class FileContentProvider extends ContentProvider { db.endTransaction(); } getContext().getContentResolver().notifyChange(newUri, null); - - // Get parentId to notify the change - long parentId = getParentId(newUri); - // Notify the change to the parent folder - notifyChangeToParentUri(parentId); - return newUri; } @@ -471,8 +424,7 @@ public class FileContentProvider extends ContentProvider { @Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { - Log_OC.d(TAG, "Updating " + values.getAsString(ProviderTableMeta.FILE_PATH) + " at provider " + this); - Log_OC.d(TAG, "Uri " + uri); + //Log_OC.d(TAG, "Updating " + values.getAsString(ProviderTableMeta.FILE_PATH) + " at provider " + this); int count = 0; SQLiteDatabase db = mDbHelper.getWritableDatabase(); db.beginTransaction(); @@ -483,12 +435,6 @@ public class FileContentProvider extends ContentProvider { db.endTransaction(); } getContext().getContentResolver().notifyChange(uri, null); - - // Get parentId to notify the change - long parentId = getParentId(uri); - // Notify the change to the parent folder - notifyChangeToParentUri(parentId); - return count; }