Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 941c6a87 authored by Santiago Etchebehere's avatar Santiago Etchebehere Committed by Automerger Merge Worker
Browse files

Merge "Request Workspace preview in a background thread" into sc-dev am: 0d25a47e

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/ThemePicker/+/14793518

Change-Id: Ib7127829fb5ed0887d3cb25b49900d2231fafd52
parents 08c29e3d 0d25a47e
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.customization.module.CustomizationInjector;
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 @@ public class GridOptionsManager implements CustomizationManager<GridOption> {
    }

    /** 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>> {
+4 −2
Original line number Diff line number Diff line
@@ -111,10 +111,12 @@ public class LauncherGridOptionsProvider {
     * @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) {
+5 −4
Original line number Diff line number Diff line
@@ -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 android.view.ViewGroup;
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 @@ class GridOptionPreviewer {
        }

        @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);
        }
    }
}