Merge "Handle nullable CellLayout when removing app icon from folder" into udc-qpr-dev

This commit is contained in:
Fengjiang Li
2023-07-15 02:44:31 +00:00
committed by Android (Google) Code Review
2 changed files with 4 additions and 6 deletions
+4 -3
View File
@@ -1402,9 +1402,10 @@ public class Launcher extends StatefulActivity<LauncherState>
* @param info The data structure describing the shortcut.
* @return A View inflated from layoutResId.
*/
public View createShortcut(ViewGroup parent, WorkspaceItemInfo info) {
BubbleTextView favorite = (BubbleTextView) LayoutInflater.from(parent.getContext())
.inflate(R.layout.app_icon, parent, false);
public View createShortcut(@Nullable ViewGroup parent, WorkspaceItemInfo info) {
BubbleTextView favorite =
(BubbleTextView) LayoutInflater.from(parent != null ? parent.getContext() : this)
.inflate(R.layout.app_icon, parent, false);
favorite.applyFromWorkspaceItem(info);
favorite.setOnClickListener(getItemOnClickListener());
favorite.setOnFocusChangeListener(mFocusHandler);
@@ -94,9 +94,6 @@ public class LauncherDelegate {
// folder
CellLayout cellLayout = mLauncher.getCellLayout(info.container,
mLauncher.getCellPosMapper().mapModelToPresenter(info).screenId);
if (cellLayout == null) {
return;
}
finalItem = info.contents.remove(0);
newIcon = mLauncher.createShortcut(cellLayout, finalItem);
mLauncher.getModelWriter().addOrMoveItemInDatabase(finalItem,