Example #1
0
  protected boolean cachedIconHelper(ImageView taskIcon, ComponentName componentTask) {
    Drawable iconPackIcon;
    String cachedIconString = IconCacheHelper.getPreloadedComponentUri(mContext, componentTask);
    ResolveInfo rInfo =
        new Tools().cachedImageResolveInfo(mContext, componentTask.getPackageName());
    if (rInfo == null) return false;

    mCount++;

    if (cachedIconString == null) {
      if (ich == null) {
        ich = new IconCacheHelper(mContext);
        Tools.HangarLog("Loading new IconCacheHelper instance");
      }
      iconPackIcon = ich.getFullResIcon(rInfo);
      cachedIconString =
          IconCacheHelper.preloadComponent(
              mContext,
              componentTask,
              Tools.drawableToBitmap(iconPackIcon),
              Tools.dpToPx(mContext, Settings.CACHED_ICON_SIZE));
    }
    taskIcon.setImageURI(Uri.parse(cachedIconString));
    return true;
  }
Example #2
0
  protected Bitmap cachedResourceIconHelper(String resourceName) {
    Drawable iconPackIcon = null;
    String cachedIconString = IconCacheHelper.getPreloadedIconUri(mContext, resourceName);

    if (cachedIconString == null) {
      if (ich == null) {
        ich = new IconCacheHelper(mContext);
        Tools.HangarLog("Loading new IconCacheHelper instance");
      }
      if (resourceName.equals(Settings.MORE_APPS_PACKAGE)) {
        iconPackIcon = mContext.getResources().getDrawable(Settings.MORE_APPS_DRAWABLE_RESOURCE);
        IconCacheHelper.preloadIcon(
            mContext,
            resourceName,
            Tools.drawableToBitmap(iconPackIcon),
            Tools.dpToPx(mContext, Settings.CACHED_ICON_SIZE));
      } else {
        Intent intent = mContext.getPackageManager().getLaunchIntentForPackage(resourceName);
        ResolveInfo rInfo = mContext.getPackageManager().resolveActivity(intent, 0);
        if (rInfo == null) return null;

        iconPackIcon = new IconCacheHelper(mContext).getFullResIcon(rInfo.activityInfo, true);
        IconCacheHelper.preloadIcon(
            mContext,
            resourceName,
            Tools.drawableToBitmap(iconPackIcon),
            Tools.dpToPx(mContext, Settings.CACHED_ICON_SIZE));
      }
    }
    if (iconPackIcon == null) {
      return IconCacheHelper.getPreloadedIcon(mContext, resourceName);
    } else {
      return Tools.drawableToBitmap(iconPackIcon);
    }
  }
Example #3
0
  protected Bitmap cachedIconHelper(ComponentName componentTask) {
    Drawable iconPackIcon = null;
    String cachedIconString = IconCacheHelper.getPreloadedComponentUri(mContext, componentTask);
    ResolveInfo rInfo =
        new Tools().cachedImageResolveInfo(mContext, componentTask.getPackageName());
    if (rInfo == null) return null;

    mCount++;

    if (cachedIconString == null) {
      if (ich == null) {
        ich = new IconCacheHelper(mContext);
        Tools.HangarLog("Loading new IconCacheHelper instance");
      }
      iconPackIcon = ich.getFullResIcon(rInfo);
      IconCacheHelper.preloadComponent(
          mContext,
          componentTask,
          Tools.drawableToBitmap(iconPackIcon),
          Tools.dpToPx(mContext, Settings.CACHED_ICON_SIZE));
    }
    if (iconPackIcon == null) {
      return IconCacheHelper.getPreloadedComponent(mContext, componentTask);
    } else {
      return Tools.drawableToBitmap(iconPackIcon);
    }
  }