List of usage examples for android.view View setHapticFeedbackEnabled
public void setHapticFeedbackEnabled(boolean hapticFeedbackEnabled)
From source file:com.andrewsummers.otashu.DepthPageTransformer.java
/** * transformPage used to apply a custom transformation (animation) to page view scrolling. * //from ww w . j a v a 2 s .c o m * @param view Incoming view. * @param position Current position of page relative to current "front and center" page. As per * the official ViewPager documentation, possible values are: -1 is one page position * to the left 0 is front and center. 1 is one page position to the right */ public void transformPage(View view, float position) { int pageWidth = view.getWidth(); // if application touch feedback setting is set, enable touch feedback if (pref_touch_feedback_enabled) { view.setHapticFeedbackEnabled(true); view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } // current page setting: [-Infinity, -1) if (position < -1) { // this page is way off-screen to the left view.setAlpha(0); } // current page setting: [-1, 0] else if (position <= 0) { // use the default slide transition when moving to the left page view.setAlpha(1); // view.setHapticFeedbackEnabled(hapticFeedbackEnabled); view.setTranslationY(pageWidth * position); view.setScaleX(1); view.setScaleY(1); } // current page setting: (0, 1) else if (position <= 1) { // fade page out view.setAlpha(1 - position); // counteract the default slide transition view.setTranslationY(pageWidth * -position); // scale the page down (between MIN_SCALE and 1) float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position)); view.setScaleX(scaleFactor); view.setScaleY(scaleFactor); } // current page setting: (1, +Infinity] else { // this page is way off-screen to the right view.setAlpha(0); } }
From source file:com.android.leanlauncher.Workspace.java
/** * Adds the specified child in the specified screen. The position and dimension of * the child are defined by x, y, spanX and spanY. * * @param child The child to add in one of the workspace's screens. * @param x The X position of the child in the screen's grid. * @param y The Y position of the child in the screen's grid. * @param spanX The number of cells spanned horizontally by the child. * @param spanY The number of cells spanned vertically by the child. * @param insert When true, the child is inserted at the beginning of the children list. *///from w w w.j a va 2s . com void addInScreen(View child, long container, int x, int y, int spanX, int spanY, boolean insert) { if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { if (getScreen() == null) { Log.e(TAG, "Skipping child, screen not found"); // DEBUGGING - Print out the stack trace to see where we are adding from new Throwable().printStackTrace(); return; } } final CellLayout layout; layout = getScreen(); child.setOnKeyListener(new IconKeyEventListener()); ViewGroup.LayoutParams genericLp = child.getLayoutParams(); CellLayout.LayoutParams lp; if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) { lp = new CellLayout.LayoutParams(x, y, spanX, spanY); } else { lp = (CellLayout.LayoutParams) genericLp; lp.cellX = x; lp.cellY = y; lp.cellHSpan = spanX; lp.cellVSpan = spanY; } if (spanX < 0 && spanY < 0) { lp.isLockedToGrid = false; } // Get the canonical child id to uniquely represent this view in this screen ItemInfo info = (ItemInfo) child.getTag(); int childId = LauncherAppState.getInstance().getViewIdForItem(info); if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, true)) { // TODO: This branch occurs when the workspace is adding views // outside of the defined grid // maybe we should be deleting these items from the LauncherModel? Log.d(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout"); } child.setHapticFeedbackEnabled(false); child.setOnLongClickListener(mLauncher); if (child instanceof DropTarget) { mDragController.addDropTarget((DropTarget) child); } }
From source file:com.zyk.launcher.AsyncTaskCallback.java
/** * Adds the specified child in the specified screen. The position and dimension of * the child are defined by x, y, spanX and spanY. * * @param child The child to add in one of the workspace's screens. * @param screenId The screen in which to add the child. * @param x The X position of the child in the screen's grid. * @param y The Y position of the child in the screen's grid. * @param spanX The number of cells spanned horizontally by the child. * @param spanY The number of cells spanned vertically by the child. * @param insert When true, the child is inserted at the beginning of the children list. * @param computeXYFromRank When true, we use the rank (stored in screenId) to compute * the x and y position in which to place hotseat items. Otherwise * we use the x and y position to compute the rank. *//*from w w w . ja va 2 s . c o m*/ void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert, boolean computeXYFromRank) { if (container == LauncherSettings.Allapps.CONTAINER_ALLAPPS) { if (getScreenWithId(screenId) == null) { Log.e(TAG, "Skipping child, screenId " + screenId + " not found"); // DEBUGGING - Print out the stack trace to see where we are adding from new Throwable().printStackTrace(); return; } } if (screenId == Workspace.EXTRA_EMPTY_SCREEN_ID) { // This should never happen throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID"); } final CellLayout layout; if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { layout = mLauncher.getHotseat().getLayout(); child.setOnKeyListener(new HotseatIconKeyEventListener()); // Hide folder title in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(false); } if (computeXYFromRank) { x = mLauncher.getHotseat().getCellXFromOrder((int) screenId); y = mLauncher.getHotseat().getCellYFromOrder((int) screenId); } else { screenId = mLauncher.getHotseat().getOrderInHotseat(x, y); } } else { // Show folder title if not in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(true); } layout = getScreenWithId(screenId); child.setOnKeyListener(new IconKeyEventListener()); } ViewGroup.LayoutParams genericLp = child.getLayoutParams(); CellLayout.LayoutParams lp; if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) { lp = new CellLayout.LayoutParams(x, y, spanX, spanY); } else { lp = (CellLayout.LayoutParams) genericLp; lp.cellX = x; lp.cellY = y; lp.cellHSpan = spanX; lp.cellVSpan = spanY; } if (spanX < 0 && spanY < 0) { lp.isLockedToGrid = false; } // Get the canonical child id to uniquely represent this view in this screen ItemInfo info = (ItemInfo) child.getTag(); int childId = mLauncher.getAllAppsViewIdForItem(info); boolean markCellsAsOccupied = !(child instanceof Folder); if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) { // TODO: This branch occurs when the workspace is adding views // outside of the defined grid // maybe we should be deleting these items from the LauncherModel? System.out.println("Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout"); Launcher.addDumpLog(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout", true); } if (!(child instanceof Folder)) { child.setHapticFeedbackEnabled(false); child.setOnLongClickListener(mLongClickListener); } if (child instanceof DropTarget) { mDragController.addDropTarget((DropTarget) child); } }
From source file:com.android.launcher2.Workspace.java
/** * Adds the specified child in the specified screen. The position and dimension of * the child are defined by x, y, spanX and spanY. * * @param child The child to add in one of the workspace's screens. * @param screen The screen in which to add the child. * @param x The X position of the child in the screen's grid. * @param y The Y position of the child in the screen's grid. * @param spanX The number of cells spanned horizontally by the child. * @param spanY The number of cells spanned vertically by the child. * @param insert When true, the child is inserted at the beginning of the children list. *//*from www . j a va2 s. co m*/ void addInScreen(View child, long container, int screen, int x, int y, int spanX, int spanY, boolean insert) { if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { if (screen < 0 || screen >= getChildCount()) { Log.e(TAG, "The screen must be >= 0 and < " + getChildCount() + " (was " + screen + "); skipping child"); return; } } final CellLayout layout; if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { layout = mLauncher.getHotseat().getLayout(); child.setOnKeyListener(null); // Hide folder title in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(false); } if (screen < 0) { screen = mLauncher.getHotseat().getOrderInHotseat(x, y); } else { // Note: We do this to ensure that the hotseat is always laid out in the orientation // of the hotseat in order regardless of which orientation they were added x = mLauncher.getHotseat().getCellXFromOrder(screen); y = mLauncher.getHotseat().getCellYFromOrder(screen); } } else { // Show folder title if not in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(true); } layout = (CellLayout) getChildAt(screen); child.setOnKeyListener(new IconKeyEventListener()); } LayoutParams genericLp = child.getLayoutParams(); CellLayout.LayoutParams lp; if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) { lp = new CellLayout.LayoutParams(x, y, spanX, spanY); } else { lp = (CellLayout.LayoutParams) genericLp; lp.cellX = x; lp.cellY = y; lp.cellHSpan = spanX; lp.cellVSpan = spanY; } if (spanX < 0 && spanY < 0) { lp.isLockedToGrid = false; } // Get the canonical child id to uniquely represent this view in this screen int childId = LauncherModel.getCellLayoutChildId(container, screen, x, y, spanX, spanY); boolean markCellsAsOccupied = !(child instanceof Folder); if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) { // TODO: This branch occurs when the workspace is adding views // outside of the defined grid // maybe we should be deleting these items from the LauncherModel? Log.w(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout"); } if (!(child instanceof Folder)) { child.setHapticFeedbackEnabled(false); child.setOnLongClickListener(mLongClickListener); } if (child instanceof DropTarget) { mDragController.addDropTarget((DropTarget) child); } }
From source file:com.fairphone.fplauncher3.Workspace.java
/** * Adds the specified child in the specified screen. The position and dimension of * the child are defined by x, y, spanX and spanY. * * @param child The child to add in one of the workspace's screens. * @param screenId The screen in which to add the child. * @param x The X position of the child in the screen's grid. * @param y The Y position of the child in the screen's grid. * @param spanX The number of cells spanned horizontally by the child. * @param spanY The number of cells spanned vertically by the child. * @param insert When true, the child is inserted at the beginning of the children list. * @param computeXYFromRank When true, we use the rank (stored in screenId) to compute * the x and y position in which to place hotseat items. Otherwise * we use the x and y position to compute the rank. *//* www. ja va2 s. c o m*/ void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert, boolean computeXYFromRank) { if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { if (getScreenWithId(screenId) == null) { Log.e(TAG, "Skipping child, screenId " + screenId + " not found"); // DEBUGGING - Print out the stack trace to see where we are adding from new Throwable().printStackTrace(); return; } } if (screenId == EXTRA_EMPTY_SCREEN_ID) { // This should never happen throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID"); } final CellLayout layout; // Show folder title if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(true); } layout = getScreenWithId(screenId); child.setOnKeyListener(new IconKeyEventListener()); ViewGroup.LayoutParams genericLp = child.getLayoutParams(); CellLayout.LayoutParams lp; if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) { lp = new CellLayout.LayoutParams(x, y, spanX, spanY); } else { lp = (CellLayout.LayoutParams) genericLp; lp.cellX = x; lp.cellY = y; lp.cellHSpan = spanX; lp.cellVSpan = spanY; } if (spanX < 0 && spanY < 0) { lp.isLockedToGrid = false; } // Get the canonical child id to uniquely represent this view in this screen ItemInfo info = (ItemInfo) child.getTag(); int childId = mLauncher.getViewIdForItem(info); boolean markCellsAsOccupied = !(child instanceof Folder); if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) { // TODO: This branch occurs when the workspace is adding views // outside of the defined grid // maybe we should be deleting these items from the LauncherModel? Launcher.addDumpLog(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout", true); } if (!(child instanceof Folder)) { child.setHapticFeedbackEnabled(false); child.setOnLongClickListener(mLongClickListener); } if (child instanceof DropTarget) { mDragController.addDropTarget((DropTarget) child); } }
From source file:cc.flydev.launcher.Workspace.java
/** * Adds the specified child in the specified screen. The position and dimension of * the child are defined by x, y, spanX and spanY. * * @param child The child to add in one of the workspace's screens. * @param screenId The screen in which to add the child. * @param x The X position of the child in the screen's grid. * @param y The Y position of the child in the screen's grid. * @param spanX The number of cells spanned horizontally by the child. * @param spanY The number of cells spanned vertically by the child. * @param insert When true, the child is inserted at the beginning of the children list. * @param computeXYFromRank When true, we use the rank (stored in screenId) to compute * the x and y position in which to place hotseat items. Otherwise * we use the x and y position to compute the rank. *//*from w w w. j a va2s .co m*/ void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert, boolean computeXYFromRank) { if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { if (getScreenWithId(screenId) == null) { Log.e(TAG, "Skipping child, screenId " + screenId + " not found"); // DEBUGGING - Print out the stack trace to see where we are adding from new Throwable().printStackTrace(); return; } } if (screenId == EXTRA_EMPTY_SCREEN_ID) { // This should never happen throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID"); } final CellLayout layout; if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { layout = mLauncher.getHotseat().getLayout(); child.setOnKeyListener(null); // Hide folder title in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(false); } if (computeXYFromRank) { x = mLauncher.getHotseat().getCellXFromOrder((int) screenId); y = mLauncher.getHotseat().getCellYFromOrder((int) screenId); } else { screenId = mLauncher.getHotseat().getOrderInHotseat(x, y); } } else { // Show folder title if not in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(true); } layout = getScreenWithId(screenId); child.setOnKeyListener(new IconKeyEventListener()); } ViewGroup.LayoutParams genericLp = child.getLayoutParams(); CellLayout.LayoutParams lp; if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) { lp = new CellLayout.LayoutParams(x, y, spanX, spanY); } else { lp = (CellLayout.LayoutParams) genericLp; lp.cellX = x; lp.cellY = y; lp.cellHSpan = spanX; lp.cellVSpan = spanY; } if (spanX < 0 && spanY < 0) { lp.isLockedToGrid = false; } // Get the canonical child id to uniquely represent this view in this screen int childId = LauncherModel.getCellLayoutChildId(container, screenId, x, y, spanX, spanY); boolean markCellsAsOccupied = !(child instanceof Folder); if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) { // TODO: This branch occurs when the workspace is adding views // outside of the defined grid // maybe we should be deleting these items from the LauncherModel? Launcher.addDumpLog(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout", true); } if (!(child instanceof Folder)) { child.setHapticFeedbackEnabled(false); child.setOnLongClickListener(mLongClickListener); } if (child instanceof DropTarget) { mDragController.addDropTarget((DropTarget) child); } }
From source file:com.example.launcher3.Workspace.java
/** * Adds the specified child in the specified screen. The position and * dimension of the child are defined by x, y, spanX and spanY. * * @param child/*from w w w . j a va 2s.c o m*/ * The child to add in one of the workspace's screens. * @param screenId * The screen in which to add the child. * @param x * The X position of the child in the screen's grid. * @param y * The Y position of the child in the screen's grid. * @param spanX * The number of cells spanned horizontally by the child. * @param spanY * The number of cells spanned vertically by the child. * @param insert * When true, the child is inserted at the beginning of the * children list. * @param computeXYFromRank * When true, we use the rank (stored in screenId) to compute the * x and y position in which to place hotseat items. Otherwise we * use the x and y position to compute the rank. */ void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert, boolean computeXYFromRank) { if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { if (getScreenWithId(screenId) == null) { Log.e(TAG, "Skipping child, screenId " + screenId + " not found"); // DEBUGGING - Print out the stack trace to see where we are // adding from new Throwable().printStackTrace(); return; } } if (screenId == EXTRA_EMPTY_SCREEN_ID) { // This should never happen throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID"); } final CellLayout layout; if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { layout = mLauncher.getHotseat().getLayout(); child.setOnKeyListener(null); // Hide folder title in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(false); } if (computeXYFromRank) { x = mLauncher.getHotseat().getCellXFromOrder((int) screenId); y = mLauncher.getHotseat().getCellYFromOrder((int) screenId); } else { screenId = mLauncher.getHotseat().getOrderInHotseat(x, y); } } else { // Show folder title if not in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(true); } layout = getScreenWithId(screenId); child.setOnKeyListener(new IconKeyEventListener()); } ViewGroup.LayoutParams genericLp = child.getLayoutParams(); CellLayout.LayoutParams lp; if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) { lp = new CellLayout.LayoutParams(x, y, spanX, spanY); } else { lp = (CellLayout.LayoutParams) genericLp; lp.cellX = x; lp.cellY = y; lp.cellHSpan = spanX; lp.cellVSpan = spanY; } if (spanX < 0 && spanY < 0) { lp.isLockedToGrid = false; } // Get the canonical child id to uniquely represent this view in this // screen int childId = LauncherModel.getCellLayoutChildId(container, screenId, x, y, spanX, spanY); boolean markCellsAsOccupied = !(child instanceof Folder); if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) { // TODO: This branch occurs when the workspace is adding views // outside of the defined grid // maybe we should be deleting these items from the LauncherModel? Launcher.addDumpLog(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout", true); } if (!(child instanceof Folder)) { child.setHapticFeedbackEnabled(false); child.setOnLongClickListener(mLongClickListener); } if (child instanceof DropTarget) { mDragController.addDropTarget((DropTarget) child); } }
From source file:com.aidy.launcher3.ui.workspace.Workspace.java
/** * Adds the specified child in the specified screen. The position and * dimension of the child are defined by x, y, spanX and spanY. * /*from w w w . ja va 2 s.c om*/ * @param child * The child to add in one of the workspace's screens. * @param screenId * The screen in which to add the child. * @param x * The X position of the child in the screen's grid. * @param y * The Y position of the child in the screen's grid. * @param spanX * The number of cells spanned horizontally by the child. * @param spanY * The number of cells spanned vertically by the child. * @param insert * When true, the child is inserted at the beginning of the * children list. * @param computeXYFromRank * When true, we use the rank (stored in screenId) to compute the * x and y position in which to place hotseat items. Otherwise we * use the x and y position to compute the rank. */ public void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert, boolean computeXYFromRank) { if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { if (getScreenWithId(screenId) == null) { Log.e(TAG, "Skipping child, screenId " + screenId + " not found"); // DEBUGGING - Print out the stack trace to see where we are // adding from new Throwable().printStackTrace(); return; } } if (screenId == EXTRA_EMPTY_SCREEN_ID) { // This should never happen throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID"); } final CellLayout layout; if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { layout = mLauncher.getHotseat().getLayout(); child.setOnKeyListener(null); // Hide folder title in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(false); } if (computeXYFromRank) { x = mLauncher.getHotseat().getCellXFromOrder((int) screenId); y = mLauncher.getHotseat().getCellYFromOrder((int) screenId); } else { screenId = mLauncher.getHotseat().getOrderInHotseat(x, y); } } else { // Show folder title if not in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(true); } layout = getScreenWithId(screenId); child.setOnKeyListener(new IconKeyEventListener()); } ViewGroup.LayoutParams genericLp = child.getLayoutParams(); CellLayout.LayoutParams lp; if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) { lp = new CellLayout.LayoutParams(x, y, spanX, spanY); } else { lp = (CellLayout.LayoutParams) genericLp; lp.cellX = x; lp.cellY = y; lp.cellHSpan = spanX; lp.cellVSpan = spanY; } if (spanX < 0 && spanY < 0) { lp.isLockedToGrid = false; } // Get the canonical child id to uniquely represent this view in this // screen int childId = LauncherModel.getCellLayoutChildId(container, screenId, x, y, spanX, spanY); boolean markCellsAsOccupied = !(child instanceof Folder); if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) { // TODO: This branch occurs when the workspace is adding views // outside of the defined grid // maybe we should be deleting these items from the LauncherModel? Launcher.addDumpLog(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout", true); } if (!(child instanceof Folder)) { child.setHapticFeedbackEnabled(false); child.setOnLongClickListener(mLongClickListener); } if (child instanceof DropTarget) { mDragController.addDropTarget((DropTarget) child); } }
From source file:com.auratech.launcher.Workspace.java
/** * Adds the specified child in the specified screen. The position and dimension of * the child are defined by x, y, spanX and spanY. * * @param child The child to add in one of the workspace's screens. * @param screenId The screen in which to add the child. * @param x The X position of the child in the screen's grid. * @param y The Y position of the child in the screen's grid. * @param spanX The number of cells spanned horizontally by the child. * @param spanY The number of cells spanned vertically by the child. * @param insert When true, the child is inserted at the beginning of the children list. * @param computeXYFromRank When true, we use the rank (stored in screenId) to compute * the x and y position in which to place hotseat items. Otherwise * we use the x and y position to compute the rank. */// w w w .j a va2 s .co m void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert, boolean computeXYFromRank) { if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { if (getScreenWithId(screenId) == null) { Log.e(TAG, "Skipping child, screenId " + screenId + " not found"); // DEBUGGING - Print out the stack trace to see where we are adding from new Throwable().printStackTrace(); return; } } if (screenId == EXTRA_EMPTY_SCREEN_ID) { // This should never happen throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID"); } final CellLayout layout; if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { layout = mLauncher.getHotseat().getLayout(); child.setOnKeyListener(null); // Hide folder title in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(false); } if (computeXYFromRank) { x = mLauncher.getHotseat().getCellXFromOrder((int) screenId); y = mLauncher.getHotseat().getCellYFromOrder((int) screenId); } else { screenId = mLauncher.getHotseat().getOrderInHotseat(x, y); } } else { // Show folder title if not in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(true); } layout = getScreenWithId(screenId); child.setOnKeyListener(new IconKeyEventListener()); } ViewGroup.LayoutParams genericLp = child.getLayoutParams(); CellLayout.LayoutParams lp; if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) { lp = new CellLayout.LayoutParams(x, y, spanX, spanY); } else { lp = (CellLayout.LayoutParams) genericLp; lp.cellX = x; lp.cellY = y; lp.cellHSpan = spanX; lp.cellVSpan = spanY; } if (spanX < 0 && spanY < 0) { lp.isLockedToGrid = false; } // Get the canonical child id to uniquely represent this view in this screen ItemInfo info = (ItemInfo) child.getTag(); int childId = mLauncher.getViewIdForItem(info); boolean markCellsAsOccupied = !(child instanceof Folder); if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) { // TODO: This branch occurs when the workspace is adding views // outside of the defined grid // maybe we should be deleting these items from the LauncherModel? Launcher.addDumpLog(TAG, "Failed to add to item at (" + lp.cellX + "," + lp.cellY + ") to CellLayout", true); } if (!(child instanceof Folder)) { child.setHapticFeedbackEnabled(false); child.setOnLongClickListener(mLongClickListener); } if (child instanceof DropTarget) { mDragController.addDropTarget((DropTarget) child); } }
From source file:com.phonemetra.turbo.launcher.Workspace.java
/** * Adds the specified child in the specified screen. The position and dimension of * the child are defined by x, y, spanX and spanY. * * @param child The child to add in one of the workspace's screens. * @param screenId The screen in which to add the child. * @param x The X position of the child in the screen's grid. * @param y The Y position of the child in the screen's grid. * @param spanX The number of cells spanned horizontally by the child. * @param spanY The number of cells spanned vertically by the child. * @param insert When true, the child is inserted at the beginning of the children list. * @param computeXYFromRank When true, we use the rank (stored in screenId) to compute * the x and y position in which to place hotseat items. Otherwise * we use the x and y position to compute the rank. */// w ww.j a va 2 s . c o m void addInScreen(View child, long container, long screenId, int x, int y, int spanX, int spanY, boolean insert, boolean computeXYFromRank) { //Reload settings reloadSettings(); if (container == LauncherSettings.Favorites.CONTAINER_DESKTOP) { if (getScreenWithId(screenId) == null) { Log.e(TAG, "Skipping child, screenId " + screenId + " not found"); // DEBUGGING - Print out the stack trace to see where we are adding from new Throwable().printStackTrace(); return; } } if (screenId == EXTRA_EMPTY_SCREEN_ID) { // This should never happen throw new RuntimeException("Screen id should not be EXTRA_EMPTY_SCREEN_ID"); } final CellLayout layout; if (container == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { layout = mLauncher.getHotseat().getLayout(); child.setOnKeyListener(null); // Hide folder title in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(false); } if (computeXYFromRank) { x = mLauncher.getHotseat().getCellXFromOrder((int) screenId); y = mLauncher.getHotseat().getCellYFromOrder((int) screenId); } else { screenId = mLauncher.getHotseat().getOrderInHotseat(x, y); } } else { // Show folder title if not in the hotseat if (child instanceof FolderIcon) { ((FolderIcon) child).setTextVisible(!mHideIconLabels); } else if (child instanceof BubbleTextView) { ((BubbleTextView) child).setTextVisibility(!mHideIconLabels); } layout = getScreenWithId(screenId); child.setOnKeyListener(new IconKeyEventListener()); } ViewGroup.LayoutParams genericLp = child.getLayoutParams(); CellLayout.LayoutParams lp; if (genericLp == null || !(genericLp instanceof CellLayout.LayoutParams)) { lp = new CellLayout.LayoutParams(x, y, spanX, spanY); } else { lp = (CellLayout.LayoutParams) genericLp; lp.cellX = x; lp.cellY = y; lp.cellHSpan = spanX; lp.cellVSpan = spanY; } if (spanX < 0 && spanY < 0) { lp.isLockedToGrid = false; } // Get the canonical child id to uniquely represent this view in this screen ItemInfo info = (ItemInfo) child.getTag(); int childId = mLauncher.getViewIdForItem(info); boolean markCellsAsOccupied = !(child instanceof Folder); if (!layout.addViewToCellLayout(child, insert ? 0 : -1, childId, lp, markCellsAsOccupied)) { } if (!(child instanceof Folder)) { if (container != LauncherSettings.Favorites.CONTAINER_HOTSEAT) { child.setHapticFeedbackEnabled(false); } child.setOnLongClickListener(mLongClickListener); } if (child instanceof DropTarget) { mDragController.addDropTarget((DropTarget) child); } }