获取完快捷方式的信息之后,便是如何具体的将快捷方式的名字,图标和打开方式放置到桌面上。
最后一步addAndBindAddedWorkspaceItems(
new LazyShortcutsProvider(context.getApplicationContext(), items));
先将获取的LazyShortcutsProvider,是将PendingInstallShortcutInfo放在LazyShortcutsProvider,然后传入addAndBindAddedWorkspaceItems。
这里实际是做了一个任务,工作包括获取 workspaceApps = mAppsProvider.get()。
分配该快捷方式的位置Pair<Long, int[]> coords = findSpaceForItem(app, dataModel, workspaceScreens, addedWorkspaceScreensFinal, item.spanX, item.spanY);
以及代码里面注释提到的这两句。
// Add the shortcut to the db
// Save the ShortcutInfo for binding in the workspace
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
List<ItemInfo> workspaceApps = mAppsProvider.get();
if (workspaceApps.isEmpty()) {
return;
}
Context context = app.getContext();
final ArrayList<ItemInfo> addedItemsFinal = new ArrayList<>();
final ArrayList<Long> addedWorkspaceScreensFinal = new ArrayList<>();
// Get the list of workspace screens. We need to append to this list and
// can not use sBgWorkspaceScreens because loadWorkspace() may not have been
// called.
ArrayList<Long> workspaceScreens = LauncherModel.loadWorkspaceScreensDb(context);
synchronized(dataModel) {
for (ItemInfo item : workspaceApps) {
if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION ||
it