Example usage for android.content ComponentName toShortString

List of usage examples for android.content ComponentName toShortString

Introduction

In this page you can find the example usage for android.content ComponentName toShortString.

Prototype

public String toShortString() 

Source Link

Document

Return string representation of this class without the class's name as a prefix.

Usage

From source file:com.android.leanlauncher.IconCache.java

/**
 * Retrieves the entry from the cache. If the entry is not present, it creates a new entry.
 * This method is not thread safe, it must be called from a synchronized method.
 *//*w  w w .j  a v a 2  s .  co m*/
private CacheEntry cacheLocked(ItemInfo itemInfo, ComponentName componentName, LauncherActivityInfoCompat info,
        UserHandleCompat user, Map<Object, CharSequence> labelCache, boolean usePackageIcon) {
    CacheKey cacheKey = new CacheKey(componentName, user);
    CacheEntry entry = mCache.get(cacheKey);
    if (entry == null || entry.icon == null) {
        entry = new CacheEntry();

        if (info != null) {
            ComponentName labelKey = info.getComponentName();
            if (labelCache != null && labelCache.containsKey(labelKey)) {
                entry.title = labelCache.get(labelKey).toString();
            } else {
                entry.title = info.getLabel().toString();
                if (labelCache != null) {
                    labelCache.put(labelKey, entry.title);
                }
            }

            entry.contentDescription = mUserManager.getBadgedLabelForUser(entry.title, user);
            Drawable defaultDrawable = info.getBadgedIcon(mIconDpi);
            if (itemInfo != null && itemInfo.iconResource != null && itemInfo.iconResource.resourceName != null
                    && mCurrentIconTheme.equals(itemInfo.iconResource.packageName)) {
                // no icon theme changes, so fetch from theme directly
                entry.icon = createIconBitmapFromTheme(itemInfo.iconResource.resourceName, defaultDrawable);
            } else if (!TextUtils.isEmpty(mCurrentIconTheme)) {
                entry.icon = createNewIconBitmap(itemInfo, componentName.getPackageName(),
                        componentName.getClassName(), defaultDrawable);
            }

            if (entry.icon == null) {
                // pick default icon
                entry.icon = Utilities.createIconBitmap(defaultDrawable, mContext);
            }

            mCache.put(cacheKey, entry);
        } else {
            entry.title = "";
            if (usePackageIcon) {
                entry = getEntryForPackage(componentName.getPackageName(), user);
                Log.d(TAG, "using package default icon for " + componentName.toShortString());
            }
            if (entry.icon == null) {
                Log.d(TAG, "using default icon for " + componentName.toShortString());
                entry.icon = getDefaultUserIcon(user);
            }
        }
    }
    return entry;
}