use of com.android.launcher3.ItemInfoWithIcon in project android_packages_apps_404Launcher by P-404.
the class IconCache method getTitlesAndIconsInBulk.
/**
* Load and fill icons requested in iconRequestInfos using a single bulk sql query.
*/
public synchronized <T extends ItemInfoWithIcon> void getTitlesAndIconsInBulk(List<IconRequestInfo<T>> iconRequestInfos) {
Map<Pair<UserHandle, Boolean>, List<IconRequestInfo<T>>> iconLoadSubsectionsMap = iconRequestInfos.stream().collect(groupingBy(iconRequest -> Pair.create(iconRequest.itemInfo.user, iconRequest.useLowResIcon)));
Trace.beginSection("loadIconsInBulk");
iconLoadSubsectionsMap.forEach((sectionKey, filteredList) -> {
Map<ComponentName, List<IconRequestInfo<T>>> duplicateIconRequestsMap = filteredList.stream().collect(groupingBy(iconRequest -> iconRequest.itemInfo.getTargetComponent()));
Trace.beginSection("loadIconSubsectionInBulk");
try (Cursor c = createBulkQueryCursor(filteredList, /* user = */
sectionKey.first, /* useLowResIcons = */
sectionKey.second)) {
int componentNameColumnIndex = c.getColumnIndexOrThrow(IconDB.COLUMN_COMPONENT);
while (c.moveToNext()) {
ComponentName cn = ComponentName.unflattenFromString(c.getString(componentNameColumnIndex));
List<IconRequestInfo<T>> duplicateIconRequests = duplicateIconRequestsMap.get(cn);
if (cn != null) {
CacheEntry entry = cacheLocked(cn, /* user = */
sectionKey.first, () -> duplicateIconRequests.get(0).launcherActivityInfo, mLauncherActivityInfoCachingLogic, c, /* usePackageIcon= */
false, /* useLowResIcons = */
sectionKey.second);
for (IconRequestInfo<T> iconRequest : duplicateIconRequests) {
applyCacheEntry(entry, iconRequest.itemInfo);
}
}
}
} catch (SQLiteException e) {
Log.d(TAG, "Error reading icon cache", e);
} finally {
Trace.endSection();
}
});
Trace.endSection();
}
use of com.android.launcher3.ItemInfoWithIcon in project android_packages_apps_404Launcher by P-404.
the class ThirdPartyDrawableFactory method newIcon.
@Override
public FastBitmapDrawable newIcon(Context context, ItemInfoWithIcon info) {
if (info != null && info.getTargetComponent() != null && info.itemType == ITEM_TYPE_APPLICATION) {
ComponentKey key = new ComponentKey(info.getTargetComponent(), info.user);
IconResolver resolver = mManager.resolve(key);
mCalendars.setIsDynamic(key, (resolver != null && resolver.isCalendar()) || info.getTargetComponent().getPackageName().equals(DynamicCalendar.CALENDAR));
if (Utilities.ATLEAST_OREO) {
if (resolver != null) {
if (resolver.isClock()) {
Drawable drawable = resolver.getIcon(0, () -> null);
if (drawable != null) {
FastBitmapDrawable fb = mCustomClockDrawer.drawIcon(info, drawable, resolver.clockData());
fb.setIsDisabled(info.isDisabled());
return fb;
}
}
} else if (info.getTargetComponent().equals(DynamicClock.DESK_CLOCK)) {
return mDynamicClockDrawer.drawIcon(info);
}
}
}
return super.newIcon(context, info);
}
use of com.android.launcher3.ItemInfoWithIcon in project android_packages_apps_404Launcher by P-404.
the class BubbleTextView method applyProgressLevel.
/**
* Applies the given progress level to the this icon's progress bar.
*/
@Nullable
public PreloadIconDrawable applyProgressLevel() {
if (!(getTag() instanceof ItemInfoWithIcon)) {
return null;
}
ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
int progressLevel = info.getProgressLevel();
if (progressLevel >= 100) {
setContentDescription(info.contentDescription != null ? info.contentDescription : "");
} else if (progressLevel > 0) {
setDownloadStateContentDescription(info, progressLevel);
} else {
setContentDescription(getContext().getString(R.string.app_waiting_download_title, info.title));
}
if (mIcon != null) {
PreloadIconDrawable preloadIconDrawable;
if (mIcon instanceof PreloadIconDrawable) {
preloadIconDrawable = (PreloadIconDrawable) mIcon;
preloadIconDrawable.setLevel(progressLevel);
preloadIconDrawable.setIsDisabled(!info.isAppStartable());
} else {
preloadIconDrawable = makePreloadIcon();
setIcon(preloadIconDrawable);
}
return preloadIconDrawable;
}
return null;
}
use of com.android.launcher3.ItemInfoWithIcon in project android_packages_apps_404Launcher by P-404.
the class BubbleTextView method verifyHighRes.
/**
* Verifies that the current icon is high-res otherwise posts a request to load the icon.
*/
public void verifyHighRes() {
if (mIconLoadRequest != null) {
mIconLoadRequest.cancel();
mIconLoadRequest = null;
}
if (getTag() instanceof ItemInfoWithIcon) {
ItemInfoWithIcon info = (ItemInfoWithIcon) getTag();
if (info.usingLowResIcon()) {
mIconLoadRequest = LauncherAppState.getInstance(getContext()).getIconCache().updateIconInBackground(BubbleTextView.this, info);
}
}
}
use of com.android.launcher3.ItemInfoWithIcon in project android_packages_apps_404Launcher by P-404.
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;
}
Aggregations