Merge "Request Workspace preview in a background thread" into sc-dev
diff --git a/src/com/android/customization/model/grid/GridOptionsManager.java b/src/com/android/customization/model/grid/GridOptionsManager.java
index 1f67ad6..c1ec729 100644
--- a/src/com/android/customization/model/grid/GridOptionsManager.java
+++ b/src/com/android/customization/model/grid/GridOptionsManager.java
@@ -28,6 +28,7 @@
import com.android.customization.module.ThemesUserEventLogger;
import com.android.wallpaper.R;
import com.android.wallpaper.module.InjectorProvider;
+import com.android.wallpaper.util.PreviewUtils;
import java.util.List;
@@ -84,8 +85,9 @@
}
/** Call through content provider API to render preview */
- public Bundle renderPreview(Bundle bundle, String gridName) {
- return mProvider.renderPreview(gridName, bundle);
+ public void renderPreview(Bundle bundle, String gridName,
+ PreviewUtils.WorkspacePreviewCallback callback) {
+ mProvider.renderPreview(gridName, bundle, callback);
}
private static class FetchTask extends AsyncTask<Void, Void, List<GridOption>> {
diff --git a/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java b/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
index 06c4761..acf91b6 100644
--- a/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
+++ b/src/com/android/customization/model/grid/LauncherGridOptionsProvider.java
@@ -111,10 +111,12 @@
* @param name the grid option name
* @param bundle surface view request bundle generated from
* {@link com.android.wallpaper.util.SurfaceViewUtils#createSurfaceViewRequest(SurfaceView)}.
+ * @param callback To receive the result (will be called on the main thread)
*/
- Bundle renderPreview(String name, Bundle bundle) {
+ void renderPreview(String name, Bundle bundle,
+ PreviewUtils.WorkspacePreviewCallback callback) {
bundle.putString("name", name);
- return mPreviewUtils.renderPreview(bundle);
+ mPreviewUtils.renderPreview(bundle, callback);
}
int applyGrid(String name) {
diff --git a/src/com/android/customization/picker/grid/GridOptionPreviewer.java b/src/com/android/customization/picker/grid/GridOptionPreviewer.java
index dac3d9b..8de08cf 100644
--- a/src/com/android/customization/picker/grid/GridOptionPreviewer.java
+++ b/src/com/android/customization/picker/grid/GridOptionPreviewer.java
@@ -16,7 +16,6 @@
package com.android.customization.picker.grid;
import android.content.Context;
-import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.ViewGroup;
@@ -24,6 +23,7 @@
import com.android.customization.model.grid.GridOption;
import com.android.customization.model.grid.GridOptionsManager;
import com.android.wallpaper.picker.WorkspaceSurfaceHolderCallback;
+import com.android.wallpaper.util.PreviewUtils;
import com.android.wallpaper.util.SurfaceViewUtils;
/** A class to load the {@link GridOption} preview to the view. */
@@ -90,10 +90,11 @@
}
@Override
- protected Bundle requestPreview(SurfaceView workspaceSurface) {
- return mGridManager.renderPreview(
+ protected void requestPreview(SurfaceView workspaceSurface,
+ PreviewUtils.WorkspacePreviewCallback callback) {
+ mGridManager.renderPreview(
SurfaceViewUtils.createSurfaceViewRequest(workspaceSurface),
- mGridOption.name);
+ mGridOption.name, callback);
}
}
}