summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/LauncherModel.java13
-rw-r--r--src/com/android/launcher3/LauncherProvider.java17
2 files changed, 26 insertions, 4 deletions
diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java
index ff8a35647..f4fa10ffa 100644
--- a/src/com/android/launcher3/LauncherModel.java
+++ b/src/com/android/launcher3/LauncherModel.java
@@ -1063,18 +1063,23 @@ public class LauncherModel extends BroadcastReceiver {
Runnable r = new Runnable() {
@Override
public void run() {
+ ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>();
// Clear the table
- cr.delete(uri, null, null);
+ ops.add(ContentProviderOperation.newDelete(uri).build());
int count = screensCopy.size();
- ContentValues[] values = new ContentValues[count];
for (int i = 0; i < count; i++) {
ContentValues v = new ContentValues();
long screenId = screensCopy.get(i);
v.put(LauncherSettings.WorkspaceScreens._ID, screenId);
v.put(LauncherSettings.WorkspaceScreens.SCREEN_RANK, i);
- values[i] = v;
+ ops.add(ContentProviderOperation.newInsert(uri).withValues(v).build());
+ }
+
+ try {
+ cr.applyBatch(LauncherProvider.AUTHORITY, ops);
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
}
- cr.bulkInsert(uri, values);
synchronized (sBgLock) {
sBgWorkspaceScreens.clear();
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index cec9167f3..a69f4235d 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -22,11 +22,14 @@ import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProviderInfo;
import android.content.ComponentName;
import android.content.ContentProvider;
+import android.content.ContentProviderOperation;
+import android.content.ContentProviderResult;
import android.content.ContentResolver;
import android.content.ContentUris;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
+import android.content.OperationApplicationException;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
@@ -194,6 +197,20 @@ public class LauncherProvider extends ContentProvider {
}
@Override
+ public ContentProviderResult[] applyBatch(ArrayList<ContentProviderOperation> operations)
+ throws OperationApplicationException {
+ SQLiteDatabase db = mOpenHelper.getWritableDatabase();
+ db.beginTransaction();
+ try {
+ ContentProviderResult[] result = super.applyBatch(operations);
+ db.setTransactionSuccessful();
+ return result;
+ } finally {
+ db.endTransaction();
+ }
+ }
+
+ @Override
public int delete(Uri uri, String selection, String[] selectionArgs) {
SqlArguments args = new SqlArguments(uri, selection, selectionArgs);