Refactoring some loadWorkspace logic in a separate class
Bug: 34112546
Change-Id: I8a43ed1646056aa1957ac3d6ea82018691df6386
diff --git a/src/com/android/launcher3/util/ContentWriter.java b/src/com/android/launcher3/util/ContentWriter.java
index 1c347c0..76ba9d6 100644
--- a/src/com/android/launcher3/util/ContentWriter.java
+++ b/src/com/android/launcher3/util/ContentWriter.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
+import android.net.Uri;
import android.os.UserHandle;
import com.android.launcher3.LauncherAppState;
@@ -35,9 +36,15 @@
private final ContentValues mValues;
private final Context mContext;
+ private CommitParams mCommitParams;
private Bitmap mIcon;
private UserHandle mUser;
+ public ContentWriter(Context context, CommitParams commitParams) {
+ this(context);
+ mCommitParams = commitParams;
+ }
+
public ContentWriter(Context context) {
this(new ContentValues(), context);
}
@@ -95,4 +102,25 @@
}
return mValues;
}
+
+ public int commit() {
+ if (mCommitParams != null) {
+ return mContext.getContentResolver().update(mCommitParams.mUri, getValues(),
+ mCommitParams.mWhere, mCommitParams.mSelectionArgs);
+ }
+ return 0;
+ }
+
+ public static final class CommitParams {
+
+ final Uri mUri = LauncherSettings.Favorites.CONTENT_URI;
+ String mWhere;
+ String[] mSelectionArgs;
+
+ public CommitParams(String where, String[] selectionArgs) {
+ mWhere = where;
+ mSelectionArgs = selectionArgs;
+ }
+
+ }
}