private void setOrilIcon(Object dragInfo) { if (!mIsFolderIconMode) { return; } if (dragInfo instanceof UserFolderInfo) { // it is a foler icon return return; } final ShortcutInfo info = (ShortcutInfo) getTag(); if (info.container >= 0) { // i am in a folder return return; } final Bitmap mFolderIcon = info.getIcon(mLauncher.getIconCache()); mContent.setIphoneIcon(mFolderIcon); if (AnimManager.getInstance().isAnim()) showUninstallBtn(true); mIsFolderIconMode = false; }
public void removeSelfInParent(DragController dragController) { clearAnimation(); AnimManager.getInstance().removeControllers(this); dragController.removeDropTarget((DropTarget) this); ((CellLayout) getParent()).removeView(this); }
public void onDrop( DragSource source, int x, int y, int xOffset, int yOffset, DragView dragView, Object dragInfo) { // get workspace ViewParent parent = getParent(); if (parent == null) { return; } Workspace mTargetWorkspace = (Workspace) parent.getParent(); final int workspaceType = mTargetWorkspace.getType(); int container = 0; switch (workspaceType) { case Workspace.WORKSPACE_NAVIGATEBAR: container = LauncherSettings.Favorites.CONTAINER_NAVIGATEBAR; break; case Workspace.WORKSPACE_WORKSPACE: container = LauncherSettings.Favorites.CONTAINER_DESKTOP; break; default: return; } final CellLayout.LayoutParams currentLp = (CellLayout.LayoutParams) getLayoutParams(); // CellLayout targetCelllayout = (CellLayout) getParent(); // remove my in parent removeSelfInParent(mLauncher.getDragController()); // clearAnimation(); // targetCelllayout.removeView(this); // make the folder info. final UserFolderInfo folderInfo = new UserFolderInfo(); folderInfo.title = getResources().getText(R.string.folder_name); // add folder into db LauncherModel.addItemToDatabase( getContext(), folderInfo, container, mTargetWorkspace.getCurrentScreen(), currentLp.cellX, currentLp.cellY, true); // add into new folder // CellLayout.CellInfo cellInfo = mSourceWorkspace.getCurrentDragInfo(); final ShortcutInfo thisTag = (ShortcutInfo) getTag(); final ShortcutInfo sourceTag = (ShortcutInfo) dragInfo; final int oldSourceScreen = sourceTag.screen; folderInfo.add(thisTag); folderInfo.add(sourceTag); // add folder items into db LauncherModel.addOrMoveItemInDatabase(mLauncher, thisTag, folderInfo.id, 0, 0, 0); LauncherModel.addOrMoveItemInDatabase(mLauncher, sourceTag, folderInfo.id, 0, 0, 0); // Create the view final FolderIcon newFolder = FolderIcon.fromXml( R.layout.folder_icon, mLauncher, (ViewGroup) mTargetWorkspace.getChildAt(mTargetWorkspace.getCurrentScreen()), folderInfo); // add into target cell mTargetWorkspace.addInCurrentScreen(newFolder, currentLp.cellX, currentLp.cellY, 1, 1, false); // start anim AnimManager.getInstance().startSingle(newFolder); // range cell Workspace sourceWorkspace = (Workspace) source; CellLayout sourceCellLayout = (CellLayout) sourceWorkspace.getChildAt(oldSourceScreen); sourceCellLayout.rangeChilds(false); // open folder mTargetWorkspace .getHandler() .postDelayed( new Runnable() { public void run() { mLauncher.handleIphoneFolderClick(folderInfo, newFolder); } }, 200); }