private Drawable checkIconCache(String resourceUri) {
   Drawable.ConstantState cached = mOutsideDrawablesCache.get(resourceUri);
   if (cached == null) {
     return null;
   }
   if (DBG) Log.d(LOG_TAG, "Found icon in cache: " + resourceUri);
   return cached.newDrawable();
 }
Ejemplo n.º 2
0
 /**
  * @param drawable Drawable from menu item
  * @return Drawable resized 32dp x 32dp and colored with color textColorSecondary
  */
 private Drawable icon(Drawable drawable) {
   if (drawable != null) {
     Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
     Drawable resizeIcon =
         new BitmapDrawable(
             getContext().getResources(), Bitmap.createScaledBitmap(bitmap, icon, icon, true));
     Drawable.ConstantState state = resizeIcon.getConstantState();
     resizeIcon = DrawableCompat.wrap(state == null ? resizeIcon : state.newDrawable()).mutate();
     DrawableCompat.setTintList(resizeIcon, BottomUtils.colorStateListIcon(getContext()));
     return resizeIcon;
   }
   return null;
 }
 /**
  * Gets the activity or application icon for an activity. Uses the local icon cache for fast
  * repeated lookups.
  *
  * @param component Name of an activity.
  * @return A drawable, or {@code null} if neither the activity nor the application has an icon
  *     set.
  */
 private Drawable getActivityIconWithCache(ComponentName component) {
   // First check the icon cache
   String componentIconKey = component.flattenToShortString();
   // Using containsKey() since we also store null values.
   if (mOutsideDrawablesCache.containsKey(componentIconKey)) {
     Drawable.ConstantState cached = mOutsideDrawablesCache.get(componentIconKey);
     return cached == null ? null : cached.newDrawable(mProviderContext.getResources());
   }
   // Then try the activity or application icon
   Drawable drawable = getActivityIcon(component);
   // Stick it in the cache so we don't do this lookup again.
   Drawable.ConstantState toCache = drawable == null ? null : drawable.getConstantState();
   mOutsideDrawablesCache.put(componentIconKey, toCache);
   return drawable;
 }
 @Test
 public void testForegroundDrawables() {
   Drawable foregroundDrawable = mock(Drawable.class);
   Drawable foregroundBearingDrawable = mock(Drawable.class);
   Drawable.ConstantState constantState = mock(Drawable.ConstantState.class);
   when(foregroundDrawable.getConstantState()).thenReturn(constantState);
   when(constantState.newDrawable()).thenReturn(foregroundDrawable);
   locationViewSettings.setForegroundDrawable(foregroundDrawable, foregroundBearingDrawable);
   assertEquals(
       "foreground should match",
       foregroundDrawable,
       locationViewSettings.getForegroundDrawable());
   assertEquals(
       "foreground bearing should match",
       foregroundBearingDrawable,
       locationViewSettings.getForegroundBearingDrawable());
 }
 public final Drawable newDrawable(Resources paramResources, Resources.Theme paramTheme) {
   dt localdt = new dt();
   b = ((VectorDrawable) a.newDrawable(paramResources, paramTheme));
   return localdt;
 }
 public final Drawable newDrawable() {
   dt localdt = new dt();
   b = ((VectorDrawable) a.newDrawable());
   return localdt;
 }