Search in sources :

Example 6 with BaseModelUpdateTask

use of com.android.launcher3.model.BaseModelUpdateTask in project android_packages_apps_Launcher3 by ProtonAOSP.

the class SearchActionItemInfo method createWorkspaceItem.

/**
 * Creates a {@link WorkspaceItemInfo} coorsponding to search action to be stored in launcher db
 */
public WorkspaceItemInfo createWorkspaceItem(LauncherModel model) {
    WorkspaceItemInfo info = new WorkspaceItemInfo();
    info.title = title;
    info.bitmap = bitmap;
    info.intent = mIntent;
    if (hasFlags(FLAG_SHOULD_START_FOR_RESULT)) {
        info.options |= WorkspaceItemInfo.FLAG_START_FOR_RESULT;
    }
    model.enqueueModelUpdateTask(new BaseModelUpdateTask() {

        @Override
        public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
            model.updateAndBindWorkspaceItem(() -> {
                PackageItemInfo pkgInfo = new PackageItemInfo(getIntentPackageName(), user);
                app.getIconCache().getTitleAndIconForApp(pkgInfo, false);
                try (LauncherIcons li = LauncherIcons.obtain(app.getContext())) {
                    info.bitmap = li.badgeBitmap(info.bitmap.icon, pkgInfo.bitmap);
                }
                return info;
            });
        }
    });
    return info;
}
Also used : BaseModelUpdateTask(com.android.launcher3.model.BaseModelUpdateTask) LauncherAppState(com.android.launcher3.LauncherAppState) BgDataModel(com.android.launcher3.model.BgDataModel) LauncherIcons(com.android.launcher3.icons.LauncherIcons) AllAppsList(com.android.launcher3.model.AllAppsList)

Aggregations

LauncherAppState (com.android.launcher3.LauncherAppState)6 AllAppsList (com.android.launcher3.model.AllAppsList)5 BaseModelUpdateTask (com.android.launcher3.model.BaseModelUpdateTask)5 BgDataModel (com.android.launcher3.model.BgDataModel)5 LauncherIcons (com.android.launcher3.icons.LauncherIcons)4 AppTarget (android.app.prediction.AppTarget)1 Bundle (android.os.Bundle)1 AnyThread (androidx.annotation.AnyThread)1 ItemInfo (com.android.launcher3.model.data.ItemInfo)1 WorkspaceItemInfo (com.android.launcher3.model.data.WorkspaceItemInfo)1 ResourceBasedOverride (com.android.launcher3.util.ResourceBasedOverride)1 ArrayList (java.util.ArrayList)1