summaryrefslogtreecommitdiffstats
path: root/src/org/cyanogenmod/themes/provider/ThemesProvider.java
diff options
context:
space:
mode:
authorRichard MacGregor <rmacgregor@cyngn.com>2015-05-21 16:00:39 -0700
committerRichard MacGregor <rmacgregor@cyngn.com>2015-05-29 00:25:21 +0000
commit93634c9468b4c466c3ed4604ffd7285bd40f5e12 (patch)
tree72cab54e85b4202ac2c13d73795fad8d166025df /src/org/cyanogenmod/themes/provider/ThemesProvider.java
parent0d4fca36a06c9b03005a4c8ccc55e152849beff8 (diff)
downloadandroid_packages_providers_ThemesProvider-93634c9468b4c466c3ed4604ffd7285bd40f5e12.tar.gz
android_packages_providers_ThemesProvider-93634c9468b4c466c3ed4604ffd7285bd40f5e12.tar.bz2
android_packages_providers_ThemesProvider-93634c9468b4c466c3ed4604ffd7285bd40f5e12.zip
Delete preview table rows on theme update
Handle the case where a theme is updated with less wallpapers than it had when originally installed. Delete the rows for previews associated with the updated theme Change-Id: I79abf4d69f7656cbff2c0847cd3f82a737f9e6c2
Diffstat (limited to 'src/org/cyanogenmod/themes/provider/ThemesProvider.java')
-rw-r--r--src/org/cyanogenmod/themes/provider/ThemesProvider.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/src/org/cyanogenmod/themes/provider/ThemesProvider.java b/src/org/cyanogenmod/themes/provider/ThemesProvider.java
index 384d814..418faf0 100644
--- a/src/org/cyanogenmod/themes/provider/ThemesProvider.java
+++ b/src/org/cyanogenmod/themes/provider/ThemesProvider.java
@@ -102,15 +102,20 @@ public class ThemesProvider extends ContentProvider {
@Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
+ SQLiteDatabase sqlDB = null;
+ int idx = -1;
+ String[] columns = null;
+ Cursor c = null;
+ int rowsDeleted = 0;
int match = sUriMatcher.match(uri);
switch (match) {
case THEMES:
- SQLiteDatabase sqlDB = mDatabase.getWritableDatabase();
+ sqlDB = mDatabase.getWritableDatabase();
// Get the theme's _id and delete preview images
- int idx = -1;
- String[] columns = new String[] { ThemesColumns._ID, ThemesColumns.PKG_NAME };
- Cursor c = sqlDB.query(ThemesTable.TABLE_NAME, columns, selection,
+ idx = -1;
+ columns = new String[] { ThemesColumns._ID, ThemesColumns.PKG_NAME };
+ c = sqlDB.query(ThemesTable.TABLE_NAME, columns, selection,
selectionArgs, null, null, null);
if (c == null) return 0;
if (c.moveToFirst()) {
@@ -128,9 +133,25 @@ public class ThemesProvider extends ContentProvider {
}
c.close();
- int rowsDeleted = sqlDB.delete(ThemesTable.TABLE_NAME, selection, selectionArgs);
+ rowsDeleted = sqlDB.delete(ThemesTable.TABLE_NAME, selection, selectionArgs);
getContext().getContentResolver().notifyChange(uri, null);
return rowsDeleted;
+ case PREVIEWS:
+ sqlDB = mDatabase.getWritableDatabase();
+
+ // Get the theme's _id and delete preview images
+ idx = -1;
+ columns = new String[] { ThemesColumns._ID };
+ c = sqlDB.query(ThemesTable.TABLE_NAME, columns, selection,
+ selectionArgs, null, null, null);
+ if (c == null) return 0;
+ if (c.moveToFirst()) {
+ idx = c.getColumnIndex(ThemesColumns._ID);
+ rowsDeleted = sqlDB.delete(PreviewsTable.TABLE_NAME,
+ PreviewColumns.THEME_ID + "=" + c.getInt(idx), null);
+ }
+ c.close();
+ return rowsDeleted;
case MIXNMATCH:
throw new UnsupportedOperationException("Cannot delete rows in MixNMatch table");
}