use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.
the class FolderPagedView method findNearestArea.
/**
* @return the rank of the cell nearest to the provided pixel position.
*/
public int findNearestArea(int pixelX, int pixelY) {
int pageIndex = getNextPage();
CellLayout page = getPageAt(pageIndex);
page.findNearestArea(pixelX, pixelY, 1, 1, sTmpArray);
if (mFolder.isLayoutRtl()) {
sTmpArray[0] = page.getCountX() - sTmpArray[0] - 1;
}
return Math.min(mAllocatedContentSize - 1, pageIndex * mOrganizer.getMaxItemsPerPage() + sTmpArray[1] * mGridCountX + sTmpArray[0]);
}
use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.
the class Folder method shouldUseHardwareLayerForAnimation.
private boolean shouldUseHardwareLayerForAnimation(CellLayout currentCellLayout) {
if (ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS.get())
return true;
int folderCount = 0;
final ShortcutAndWidgetContainer container = currentCellLayout.getShortcutsAndWidgets();
for (int i = container.getChildCount() - 1; i >= 0; --i) {
final View child = container.getChildAt(i);
if (child instanceof AppWidgetHostView)
return false;
if (child instanceof FolderIcon)
++folderCount;
}
return folderCount >= MIN_FOLDERS_FOR_HARDWARE_OPTIMIZATION;
}
use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.
the class Folder method replaceFolderWithFinalItem.
@Thunk
void replaceFolderWithFinalItem() {
// Add the last remaining child to the workspace in place of the folder
Runnable onCompleteRunnable = new Runnable() {
@Override
public void run() {
int itemCount = getItemCount();
if (itemCount <= 1) {
View newIcon = null;
WorkspaceItemInfo finalItem = null;
if (itemCount == 1) {
// Move the item from the folder to the workspace, in the position of the
// folder
CellLayout cellLayout = mLauncher.getCellLayout(mInfo.container, mInfo.screenId);
finalItem = mInfo.contents.remove(0);
newIcon = mLauncher.createShortcut(cellLayout, finalItem);
mLauncher.getModelWriter().addOrMoveItemInDatabase(finalItem, mInfo.container, mInfo.screenId, mInfo.cellX, mInfo.cellY);
}
// Remove the folder
mLauncher.removeItem(mFolderIcon, mInfo, true);
if (mFolderIcon instanceof DropTarget) {
mDragController.removeDropTarget((DropTarget) mFolderIcon);
}
if (newIcon != null) {
// We add the child after removing the folder to prevent both from existing
// at the same time in the CellLayout. We need to add the new item with
// addInScreenFromBind() to ensure that hotseat items are placed correctly.
mLauncher.getWorkspace().addInScreenFromBind(newIcon, mInfo);
// Focus the newly created child
newIcon.requestFocus();
}
if (finalItem != null) {
mLauncher.folderConvertedToItem(mFolderIcon.getFolder(), finalItem);
}
}
}
};
View finalChild = mContent.getLastItem();
if (finalChild != null) {
mFolderIcon.performDestroyAnimation(onCompleteRunnable);
} else {
onCompleteRunnable.run();
}
mDestroyed = true;
}
use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.
the class FolderPagedView method setFixedSize.
public void setFixedSize(int width, int height) {
width -= (getPaddingLeft() + getPaddingRight());
height -= (getPaddingTop() + getPaddingBottom());
for (int i = getChildCount() - 1; i >= 0; i--) {
((CellLayout) getChildAt(i)).setFixedSize(width, height);
}
}
use of com.android.launcher3.CellLayout in project android_packages_apps_Trebuchet by LineageOS.
the class FolderPagedView method verifyVisibleHighResIcons.
/**
* Ensures that all the icons on the given page are of high-res
*/
public void verifyVisibleHighResIcons(int pageNo) {
CellLayout page = getPageAt(pageNo);
if (page != null) {
ShortcutAndWidgetContainer parent = page.getShortcutsAndWidgets();
for (int i = parent.getChildCount() - 1; i >= 0; i--) {
BubbleTextView icon = ((BubbleTextView) parent.getChildAt(i));
icon.verifyHighRes();
// Set the callback back to the actual icon, in case
// it was captured by the FolderIcon
Drawable d = icon.getCompoundDrawables()[1];
if (d != null) {
d.setCallback(icon);
}
}
}
}
Aggregations