use of com.android.launcher3.BubbleTextView in project android_packages_apps_Launcher3 by AOSPA.
the class LauncherBindableItemsContainer method updateWorkspaceItems.
/**
* Called to update workspace items as a result of
* {@link com.android.launcher3.model.BgDataModel.Callbacks#bindWorkspaceItemsChanged(List)}
*/
default void updateWorkspaceItems(List<WorkspaceItemInfo> shortcuts, ActivityContext context) {
final HashSet<WorkspaceItemInfo> updates = new HashSet<>(shortcuts);
ItemOperator op = (info, v) -> {
if (v instanceof BubbleTextView && updates.contains(info)) {
WorkspaceItemInfo si = (WorkspaceItemInfo) info;
BubbleTextView shortcut = (BubbleTextView) v;
Drawable oldIcon = shortcut.getIcon();
boolean oldPromiseState = (oldIcon instanceof PreloadIconDrawable) && ((PreloadIconDrawable) oldIcon).hasNotCompleted();
shortcut.applyFromWorkspaceItem(si, si.isPromise() != oldPromiseState);
} else if (info instanceof FolderInfo && v instanceof FolderIcon) {
((FolderIcon) v).updatePreviewItems(updates::contains);
}
// Iterate all items
return false;
};
mapOverItems(op);
Folder openFolder = Folder.getOpen(context);
if (openFolder != null) {
openFolder.iterateOverItems(op);
}
}
use of com.android.launcher3.BubbleTextView in project android_packages_apps_Launcher3 by AOSPA.
the class FloatingIconView method fetchIcon.
/**
* Loads the icon drawable on a worker thread to reduce latency between swapping views.
*/
@UiThread
public static IconLoadResult fetchIcon(Launcher l, View v, ItemInfo info, boolean isOpening) {
RectF position = new RectF();
getLocationBoundsForView(l, v, isOpening, position);
final FastBitmapDrawable btvIcon;
if (v instanceof BubbleTextView) {
BubbleTextView btv = (BubbleTextView) v;
if (info instanceof ItemInfoWithIcon && (((ItemInfoWithIcon) info).runtimeStatusFlags & ItemInfoWithIcon.FLAG_SHOW_DOWNLOAD_PROGRESS_MASK) != 0) {
btvIcon = btv.makePreloadIcon();
} else {
btvIcon = btv.getIcon();
}
} else {
btvIcon = null;
}
IconLoadResult result = new IconLoadResult(info, btvIcon == null ? false : btvIcon.isThemed());
result.btvDrawable = btvIcon;
final long fetchIconId = sFetchIconId++;
MODEL_EXECUTOR.getHandler().postAtFrontOfQueue(() -> {
if (fetchIconId < sRecycledFetchIconId) {
return;
}
getIconResult(l, v, info, position, btvIcon, result);
});
sIconLoadResult = result;
return result;
}
use of com.android.launcher3.BubbleTextView in project android_packages_apps_Launcher3 by AOSPA.
the class LauncherPreviewRenderer method inflateAndAddIcon.
private void inflateAndAddIcon(WorkspaceItemInfo info) {
CellLayout screen = mWorkspaceScreens.get(info.screenId);
BubbleTextView icon = (BubbleTextView) mHomeElementInflater.inflate(R.layout.app_icon, screen, false);
icon.applyFromWorkspaceItem(info);
addInScreenFromBind(icon, info);
}
use of com.android.launcher3.BubbleTextView in project android_packages_apps_Launcher3 by AOSPA.
the class FolderPagedView method createNewView.
@SuppressLint("InflateParams")
public View createNewView(WorkspaceItemInfo item) {
if (item == null) {
return null;
}
final BubbleTextView textView = mViewCache.getView(R.layout.folder_application, getContext(), null);
textView.applyFromWorkspaceItem(item);
textView.setOnClickListener(ItemClickHandler.INSTANCE);
textView.setOnLongClickListener(mFolder);
textView.setOnFocusChangeListener(mFocusIndicatorHelper);
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) textView.getLayoutParams();
if (lp == null) {
textView.setLayoutParams(new CellLayout.LayoutParams(item.cellX, item.cellY, item.spanX, item.spanY));
} else {
lp.cellX = item.cellX;
lp.cellY = item.cellY;
lp.cellHSpan = lp.cellVSpan = 1;
}
return textView;
}
use of com.android.launcher3.BubbleTextView in project android_packages_apps_Launcher3 by AOSPA.
the class FolderPagedView method arrangeChildren.
/**
* Updates position and rank of all the children in the view.
* It essentially removes all views from all the pages and then adds them again in appropriate
* page.
*
* @param list the ordered list of children.
*/
@SuppressLint("RtlHardcoded")
public void arrangeChildren(List<View> list) {
int itemCount = list.size();
ArrayList<CellLayout> pages = new ArrayList<>();
for (int i = 0; i < getChildCount(); i++) {
CellLayout page = (CellLayout) getChildAt(i);
page.removeAllViews();
pages.add(page);
}
mOrganizer.setFolderInfo(mFolder.getInfo());
setupContentDimensions(itemCount);
Iterator<CellLayout> pageItr = pages.iterator();
CellLayout currentPage = null;
int position = 0;
int rank = 0;
for (int i = 0; i < itemCount; i++) {
View v = list.size() > i ? list.get(i) : null;
if (currentPage == null || position >= mOrganizer.getMaxItemsPerPage()) {
// Next page
if (pageItr.hasNext()) {
currentPage = pageItr.next();
} else {
currentPage = createAndAddNewPage();
}
position = 0;
}
if (v != null) {
CellLayout.LayoutParams lp = (CellLayout.LayoutParams) v.getLayoutParams();
ItemInfo info = (ItemInfo) v.getTag();
lp.setCellXY(mOrganizer.getPosForRank(rank));
currentPage.addViewToCellLayout(v, -1, info.getViewId(), lp, true);
if (mOrganizer.isItemInPreview(rank) && v instanceof BubbleTextView) {
((BubbleTextView) v).verifyHighRes();
}
}
rank++;
position++;
}
// Remove extra views.
boolean removed = false;
while (pageItr.hasNext()) {
removeView(pageItr.next());
removed = true;
}
if (removed) {
setCurrentPage(0);
}
setEnableOverscroll(getPageCount() > 1);
// Update footer
mPageIndicator.setVisibility(getPageCount() > 1 ? View.VISIBLE : View.GONE);
// Set the gravity as LEFT or RIGHT instead of START, as START depends on the actual text.
mFolder.mFolderName.setGravity(getPageCount() > 1 ? (mIsRtl ? Gravity.RIGHT : Gravity.LEFT) : Gravity.CENTER_HORIZONTAL);
}
Aggregations