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;
 }
 public final int getChangingConfigurations() {
   return a.getChangingConfigurations();
 }
 public final boolean canApplyTheme() {
   return a.canApplyTheme();
 }
Ejemplo n.º 9
0
 public static int getImgState(Context c, Drawable.ConstantState d) {
   if (d.equals(ContextCompat.getDrawable(c, R.drawable.left_gray).getConstantState()))
     return ChairState.LEFT_GRAY;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.right_gray).getConstantState()))
     return ChairState.RIGHT_GRAY;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.top_gray).getConstantState()))
     return ChairState.TOP_GRAY;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.bottom_gray).getConstantState()))
     return ChairState.BOTTOM_GRAY;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.left_green).getConstantState()))
     return ChairState.LEFT_GREEN;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.right_green).getConstantState()))
     return ChairState.RIGHT_GREEN;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.top_green).getConstantState()))
     return ChairState.TOP_GREEN;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.bottom_green).getConstantState()))
     return ChairState.BOTTOM_GREEN;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.left_yellow).getConstantState()))
     return ChairState.LEFT_YELLOW;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.right_yellow).getConstantState()))
     return ChairState.RIGHT_YELLOW;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.top_yellow).getConstantState()))
     return ChairState.TOP_YELLOW;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.bottom_yellow).getConstantState()))
     return ChairState.BOTTOM_YELLOW;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.left_turquoise).getConstantState()))
     return ChairState.LEFT_TURQUOISE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.right_turquoise).getConstantState()))
     return ChairState.RIGHT_TURQUOISE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.top_turquoise).getConstantState()))
     return ChairState.TOP_TURQUOISE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.bottom_turquoise).getConstantState()))
     return ChairState.BOTTOM_TURQUOISE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.left_orange).getConstantState()))
     return ChairState.LEFT_ORANGE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.right_orange).getConstantState()))
     return ChairState.RIGHT_ORANGE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.top_orange).getConstantState()))
     return ChairState.TOP_ORANGE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.bottom_orange).getConstantState()))
     return ChairState.BOTTOM_ORANGE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.left_purple).getConstantState()))
     return ChairState.LEFT_PURPLE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.right_purple).getConstantState()))
     return ChairState.RIGHT_PURPLE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.top_purple).getConstantState()))
     return ChairState.TOP_PURPLE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.bottom_purple).getConstantState()))
     return ChairState.BOTTOM_PURPLE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.left_blue).getConstantState()))
     return ChairState.LEFT_BLUE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.right_blue).getConstantState()))
     return ChairState.RIGHT_BLUE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.top_blue).getConstantState()))
     return ChairState.TOP_BLUE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.bottom_blue).getConstantState()))
     return ChairState.BOTTOM_BLUE;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.left_red).getConstantState()))
     return ChairState.LEFT_RED;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.right_red).getConstantState()))
     return ChairState.RIGHT_RED;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.top_red).getConstantState()))
     return ChairState.TOP_RED;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.bottom_red).getConstantState()))
     return ChairState.BOTTOM_RED;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.left_pink).getConstantState()))
     return ChairState.LEFT_PINK;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.right_pink).getConstantState()))
     return ChairState.RIGHT_PINK;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.top_pink).getConstantState()))
     return ChairState.TOP_PINK;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.bottom_pink).getConstantState()))
     return ChairState.BOTTOM_PINK;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.left_grown).getConstantState()))
     return ChairState.LEFT_GROWN;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.right_grown).getConstantState()))
     return ChairState.RIGHT_GROWN;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.top_grown).getConstantState()))
     return ChairState.TOP_GROWN;
   else if (d.equals(ContextCompat.getDrawable(c, R.drawable.bottom_grown).getConstantState()))
     return ChairState.BOTTOM_GROWN;
   else Log.d("ERROR_DRAWABLE", "Initialisation d'une ChairImageView avec un Drawable inconnu ?!");
   return 0;
 }