java类android.graphics.drawable.DrawableContainer的实例源码

ThemeUtils.java 文件源码 项目:Mix 阅读 29 收藏 0 点赞 0 评论 0
public static boolean containsNinePatch(Drawable drawable) {
    drawable = getWrapperDrawable(drawable);
    if (drawable instanceof NinePatchDrawable
            || drawable instanceof InsetDrawable
            || drawable instanceof LayerDrawable) {
        return true;
    } else if (drawable instanceof StateListDrawable) {
        final DrawableContainer.DrawableContainerState containerState = ((DrawableContainer.DrawableContainerState) drawable.getConstantState());
        //can't getBaseApplication containState from drawable which is containing DrawableWrapperDonut
        //https://code.google.com/p/android/issues/detail?id=169920
        if (containerState == null) {
            return true;
        }
        for (Drawable dr : containerState.getChildren()) {
            dr = getWrapperDrawable(dr);
            if (dr instanceof NinePatchDrawable
                    || dr instanceof InsetDrawable
                    || dr instanceof LayerDrawable) {
                return true;
            }
        }
    }
    return false;
}
DrawableUtils.java 文件源码 项目:boohee_v5.6 阅读 36 收藏 0 点赞 0 评论 0
private static boolean setContainerConstantStateV9(DrawableContainer drawable, ConstantState constantState) {
    if (!sSetConstantStateMethodFetched) {
        try {
            sSetConstantStateMethod = DrawableContainer.class.getDeclaredMethod("setConstantState", new Class[]{DrawableContainerState.class});
            sSetConstantStateMethod.setAccessible(true);
        } catch (NoSuchMethodException e) {
            Log.e(LOG_TAG, "Could not fetch setConstantState(). Oh well.");
        }
        sSetConstantStateMethodFetched = true;
    }
    if (sSetConstantStateMethod != null) {
        try {
            sSetConstantStateMethod.invoke(drawable, new Object[]{constantState});
            return true;
        } catch (Exception e2) {
            Log.e(LOG_TAG, "Could not invoke setConstantState(). Oh well.");
        }
    }
    return false;
}
DrawableUtils.java 文件源码 项目:boohee_v5.6 阅读 34 收藏 0 点赞 0 评论 0
private static boolean setContainerConstantStateV7(DrawableContainer drawable, ConstantState constantState) {
    if (!sDrawableContainerStateFieldFetched) {
        try {
            sDrawableContainerStateField = DrawableContainer.class.getDeclaredField("mDrawableContainerStateField");
            sDrawableContainerStateField.setAccessible(true);
        } catch (NoSuchFieldException e) {
            Log.e(LOG_TAG, "Could not fetch mDrawableContainerStateField. Oh well.");
        }
        sDrawableContainerStateFieldFetched = true;
    }
    if (sDrawableContainerStateField != null) {
        try {
            sDrawableContainerStateField.set(drawable, constantState);
            return true;
        } catch (Exception e2) {
            Log.e(LOG_TAG, "Could not set mDrawableContainerStateField. Oh well.");
        }
    }
    return false;
}
ThemeUtils.java 文件源码 项目:MagicaSakura 阅读 36 收藏 0 点赞 0 评论 0
public static boolean containsNinePatch(Drawable drawable) {
    drawable = getWrapperDrawable(drawable);
    if (drawable instanceof NinePatchDrawable
            || drawable instanceof InsetDrawable
            || drawable instanceof LayerDrawable) {
        return true;
    } else if (drawable instanceof StateListDrawable) {
        final DrawableContainer.DrawableContainerState containerState = ((DrawableContainer.DrawableContainerState) drawable.getConstantState());
        //can't get containState from drawable which is containing DrawableWrapperDonut
        //https://code.google.com/p/android/issues/detail?id=169920
        if (containerState == null) {
            return true;
        }
        for (Drawable dr : containerState.getChildren()) {
            dr = getWrapperDrawable(dr);
            if (dr instanceof NinePatchDrawable
                    || dr instanceof InsetDrawable
                    || dr instanceof LayerDrawable) {
                return true;
            }
        }
    }
    return false;
}
ButtonsAdapter.java 文件源码 项目:BrainPhaser 阅读 19 收藏 0 点赞 0 评论 0
/**
 * Inflates the view and creates the ViewHolder
 *
 * @param parent   Get the context from it
 * @param viewType Ignored
 * @return The created ViewHolder
 */
@Override
public ButtonViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.multiplechoice_button, parent, false);

    // Clone drawable to allow modifications
    ToggleButton button = (ToggleButton) v.findViewById(R.id.toggleButton);
    StateListDrawable drawable = (StateListDrawable) button.getBackground();
    drawable = (StateListDrawable) drawable.mutate();
    button.setBackgroundDrawable(drawable.getConstantState().newDrawable());
    drawable = (StateListDrawable) button.getBackground();
    // Deep Clone (necessary for API Version 15 apparently)
    DrawableContainer.DrawableContainerState drawableContainerState = (DrawableContainer.DrawableContainerState) drawable.getConstantState();
    for (int i = 0; i < drawableContainerState.getChildren().length; i++) {
        if (drawableContainerState.getChildren()[i] != null) {
            drawableContainerState.getChildren()[i] = drawableContainerState.getChildren()[i].getConstantState().newDrawable().mutate();
        }
    }

    return new ButtonViewHolder(v);
}
EmTintManager.java 文件源码 项目:AndroidTint 阅读 60 收藏 0 点赞 0 评论 0
private static boolean shouldMutateBackground(Drawable drawable) {
    if (Build.VERSION.SDK_INT >= 16) {
        // For SDK 16+, we should be fine mutating the drawable
        return true;
    }

    if (drawable instanceof LayerDrawable) {
        return Build.VERSION.SDK_INT >= 16;
    } else if (drawable instanceof InsetDrawable) {
        return Build.VERSION.SDK_INT >= 14;
    } else if (drawable instanceof DrawableContainer) {
        // If we have a DrawableContainer, let's traverse it's child array
        final Drawable.ConstantState state = drawable.getConstantState();
        if (state instanceof DrawableContainer.DrawableContainerState) {
            final DrawableContainer.DrawableContainerState containerState =
                    (DrawableContainer.DrawableContainerState) state;
            for (Drawable child : containerState.getChildren()) {
                if (!shouldMutateBackground(child)) {
                    return false;
                }
            }
        }
    }
    return true;
}
DrawableCompatLollipop.java 文件源码 项目:MyCTFWriteUps 阅读 19 收藏 0 点赞 0 评论 0
public static Drawable wrapForTinting(Drawable drawable)
    {
        Object obj;
label0:
        {
            if (!(drawable instanceof GradientDrawable))
            {
                obj = drawable;
                if (!(drawable instanceof DrawableContainer))
                {
                    break label0;
                }
            }
            obj = new DrawableWrapperLollipop(drawable);
        }
        return ((Drawable) (obj));
    }
PXDrawableUtil.java 文件源码 项目:pixate-freestyle-android 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Check if two Drawables are equal. A regular check for a Drawable equals
 * just checks for the instance reference, while this check is doing a
 * deeper equals when dealing with {@link DrawableContainer} instances. In
 * these cases, the method will run equals on each of the child drawables in
 * the container (order is importance as well).
 * 
 * @param d1
 * @param d2
 * @return <code>true</code> if the drawables are equal, <code>false</code>
 *         otherwise.
 */
public static boolean isEquals(Drawable d1, Drawable d2) {
    if (d1 == d2) {
        return true;
    }
    if (d1 == null || d2 == null) {
        return false;
    }
    if (d1 instanceof DrawableContainer && d2 instanceof DrawableContainer) {
        // Try to match the content of those containers
        DrawableContainerState containerState1 = (DrawableContainerState) ((DrawableContainer) d1)
                .getConstantState();
        DrawableContainerState containerState2 = (DrawableContainerState) ((DrawableContainer) d2)
                .getConstantState();

        return Arrays.equals(containerState1.getChildren(), containerState2.getChildren());
    }
    return d1.equals(d2);
}
DrawableUtils.java 文件源码 项目:cwac-crossport 阅读 33 收藏 0 点赞 0 评论 0
/**
 * Some drawable implementations have problems with mutation. This method returns false if
 * there is a known issue in the given drawable's implementation.
 */
public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
    if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
        return false;
    }  else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
        // GradientDrawable has a bug pre-ICS which results in mutate() resulting
        // in loss of color
        return false;
    } else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
        return false;
    }

    if (drawable instanceof DrawableContainer) {
        // If we have a DrawableContainer, let's traverse its child array
        final Drawable.ConstantState state = drawable.getConstantState();
        if (state instanceof DrawableContainer.DrawableContainerState) {
            final DrawableContainer.DrawableContainerState containerState =
                    (DrawableContainer.DrawableContainerState) state;
            for (final Drawable child : containerState.getChildren()) {
                if (!canSafelyMutateDrawable(child)) {
                    return false;
                }
            }
        }
    } else if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v4.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    } /*else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v7.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    }*/ else if (drawable instanceof ScaleDrawable) {
        return canSafelyMutateDrawable(((ScaleDrawable) drawable).getDrawable());
    }

    return true;
}
TextInputLayout.java 文件源码 项目:cwac-crossport 阅读 18 收藏 0 点赞 0 评论 0
private void ensureBackgroundDrawableStateWorkaround() {
  final int sdk = Build.VERSION.SDK_INT;
  if (sdk != 21 && sdk != 22) {
    // The workaround is only required on API 21-22
    return;
  }
  final Drawable bg = mEditText.getBackground();
  if (bg == null) {
    return;
  }

  if (!mHasReconstructedEditTextBackground) {
    // This is gross. There is an issue in the platform which affects container Drawables
    // where the first drawable retrieved from resources will propagate any changes
    // (like color filter) to all instances from the cache. We'll try to workaround it...

    final Drawable newBg = bg.getConstantState().newDrawable();

    if (bg instanceof DrawableContainer) {
      // If we have a Drawable container, we can try and set it's constant state via
      // reflection from the new Drawable
      mHasReconstructedEditTextBackground =
          com.commonsware.cwac.crossport.design.widget.DrawableUtils.setContainerConstantState(
              (DrawableContainer) bg, newBg.getConstantState());
    }

    if (!mHasReconstructedEditTextBackground) {
      // If we reach here then we just need to set a brand new instance of the Drawable
      // as the background. This has the unfortunate side-effect of wiping out any
      // user set padding, but I'd hope that use of custom padding on an EditText
      // is limited.
      ViewCompat.setBackground(mEditText, newBg);
      mHasReconstructedEditTextBackground = true;
    }
  }
}
DrawableWrapperLollipop.java 文件源码 项目:boohee_v5.6 阅读 26 收藏 0 点赞 0 评论 0
protected boolean isCompatTintEnabled() {
    if (VERSION.SDK_INT != 21) {
        return false;
    }
    Drawable drawable = this.mDrawable;
    if ((drawable instanceof GradientDrawable) || (drawable instanceof DrawableContainer) || (drawable instanceof InsetDrawable)) {
        return true;
    }
    return false;
}
TextInputLayout.java 文件源码 项目:boohee_v5.6 阅读 20 收藏 0 点赞 0 评论 0
private void ensureBackgroundDrawableStateWorkaround() {
    Drawable bg = this.mEditText.getBackground();
    if (bg != null && !this.mHasReconstructedEditTextBackground) {
        Drawable newBg = bg.getConstantState().newDrawable();
        if (bg instanceof DrawableContainer) {
            this.mHasReconstructedEditTextBackground = DrawableUtils.setContainerConstantState((DrawableContainer) bg, newBg.getConstantState());
        }
        if (!this.mHasReconstructedEditTextBackground) {
            this.mEditText.setBackgroundDrawable(newBg);
            this.mHasReconstructedEditTextBackground = true;
        }
    }
}
SkinCompatDrawableUtils.java 文件源码 项目:Android-skin-support 阅读 27 收藏 0 点赞 0 评论 0
/**
 * Some drawable implementations have problems with mutation. This method returns false if
 * there is a known issue in the given drawable's implementation.
 */
public static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
    if (Build.VERSION.SDK_INT < 15 && drawable instanceof InsetDrawable) {
        return false;
    }  else if (Build.VERSION.SDK_INT < 15 && drawable instanceof GradientDrawable) {
        // GradientDrawable has a bug pre-ICS which results in mutate() resulting
        // in loss of color
        return false;
    } else if (Build.VERSION.SDK_INT < 17 && drawable instanceof LayerDrawable) {
        return false;
    }

    if (drawable instanceof DrawableContainer) {
        // If we have a DrawableContainer, let's traverse it's child array
        final Drawable.ConstantState state = drawable.getConstantState();
        if (state instanceof DrawableContainer.DrawableContainerState) {
            final DrawableContainer.DrawableContainerState containerState =
                    (DrawableContainer.DrawableContainerState) state;
            for (final Drawable child : containerState.getChildren()) {
                if (!canSafelyMutateDrawable(child)) {
                    return false;
                }
            }
        }
    } else if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v4.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    } else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v7.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    } else if (drawable instanceof ScaleDrawable) {
        return canSafelyMutateDrawable(((ScaleDrawable) drawable).getDrawable());
    }

    return true;
}
bt.java 文件源码 项目:solved-hacking-problem 阅读 29 收藏 0 点赞 0 评论 0
public static boolean m2634b(Drawable drawable) {
    if (drawable instanceof LayerDrawable) {
        return VERSION.SDK_INT >= 16;
    } else if (drawable instanceof InsetDrawable) {
        return VERSION.SDK_INT >= 14;
    } else {
        if (drawable instanceof StateListDrawable) {
            return VERSION.SDK_INT >= 8;
        } else {
            if (drawable instanceof GradientDrawable) {
                return VERSION.SDK_INT >= 14;
            } else {
                if (!(drawable instanceof DrawableContainer)) {
                    return drawable instanceof C0063q ? m2634b(((C0063q) drawable).m469a()) : drawable instanceof C0244a ? m2634b(((C0244a) drawable).m1984a()) : drawable instanceof ScaleDrawable ? m2634b(((ScaleDrawable) drawable).getDrawable()) : true;
                } else {
                    ConstantState constantState = drawable.getConstantState();
                    if (!(constantState instanceof DrawableContainerState)) {
                        return true;
                    }
                    for (Drawable b : ((DrawableContainerState) constantState).getChildren()) {
                        if (!m2634b(b)) {
                            return false;
                        }
                    }
                    return true;
                }
            }
        }
    }
}
aa.java 文件源码 项目:solved-hacking-problem 阅读 24 收藏 0 点赞 0 评论 0
protected boolean m487c() {
    if (VERSION.SDK_INT != 21) {
        return false;
    }
    Drawable drawable = this.c;
    return (drawable instanceof GradientDrawable) || (drawable instanceof DrawableContainer) || (drawable instanceof InsetDrawable);
}
bt.java 文件源码 项目:solved-hacking-problem 阅读 40 收藏 0 点赞 0 评论 0
public static boolean m2634b(Drawable drawable) {
    if (drawable instanceof LayerDrawable) {
        return VERSION.SDK_INT >= 16;
    } else if (drawable instanceof InsetDrawable) {
        return VERSION.SDK_INT >= 14;
    } else {
        if (drawable instanceof StateListDrawable) {
            return VERSION.SDK_INT >= 8;
        } else {
            if (drawable instanceof GradientDrawable) {
                return VERSION.SDK_INT >= 14;
            } else {
                if (!(drawable instanceof DrawableContainer)) {
                    return drawable instanceof C0063q ? m2634b(((C0063q) drawable).m469a()) : drawable instanceof C0244a ? m2634b(((C0244a) drawable).m1984a()) : drawable instanceof ScaleDrawable ? m2634b(((ScaleDrawable) drawable).getDrawable()) : true;
                } else {
                    ConstantState constantState = drawable.getConstantState();
                    if (!(constantState instanceof DrawableContainerState)) {
                        return true;
                    }
                    for (Drawable b : ((DrawableContainerState) constantState).getChildren()) {
                        if (!m2634b(b)) {
                            return false;
                        }
                    }
                    return true;
                }
            }
        }
    }
}
aa.java 文件源码 项目:solved-hacking-problem 阅读 26 收藏 0 点赞 0 评论 0
protected boolean m487c() {
    if (VERSION.SDK_INT != 21) {
        return false;
    }
    Drawable drawable = this.c;
    return (drawable instanceof GradientDrawable) || (drawable instanceof DrawableContainer) || (drawable instanceof InsetDrawable);
}
DrawableWrapperLollipop.java 文件源码 项目:permissionsModule 阅读 32 收藏 0 点赞 0 评论 0
@Override
protected boolean isCompatTintEnabled() {
    if (Build.VERSION.SDK_INT == 21) {
        final Drawable drawable = mDrawable;
        return drawable instanceof GradientDrawable || drawable instanceof DrawableContainer
                || drawable instanceof InsetDrawable;
    }
    return false;
}
DrawableUtils.java 文件源码 项目:permissionsModule 阅读 35 收藏 0 点赞 0 评论 0
static boolean setContainerConstantState(DrawableContainer drawable,
        Drawable.ConstantState constantState) {
    if (Build.VERSION.SDK_INT >= 9) {
        // We can use getDeclaredMethod() on v9+
        return setContainerConstantStateV9(drawable, constantState);
    } else {
        // Else we'll just have to set the field directly
        return setContainerConstantStateV7(drawable, constantState);
    }
}
TextInputLayout.java 文件源码 项目:permissionsModule 阅读 35 收藏 0 点赞 0 评论 0
private void ensureBackgroundDrawableStateWorkaround() {
    final Drawable bg = mEditText.getBackground();
    if (bg == null) {
        return;
    }

    if (!mHasReconstructedEditTextBackground) {
        // This is gross. There is an issue in the platform which affects container Drawables
        // where the first drawable retrieved from resources will propogate any changes
        // (like color filter) to all instances from the cache. We'll try to workaround it...

        final Drawable newBg = bg.getConstantState().newDrawable();

        if (bg instanceof DrawableContainer) {
            // If we have a Drawable container, we can try and set it's constant state via
            // reflection from the new Drawable
            mHasReconstructedEditTextBackground =
                    DrawableUtils.setContainerConstantState(
                            (DrawableContainer) bg, newBg.getConstantState());
        }

        if (!mHasReconstructedEditTextBackground) {
            // If we reach here then we just need to set a brand new instance of the Drawable
            // as the background. This has the unfortunate side-effect of wiping out any
            // user set padding, but I'd hope that use of custom padding on an EditText
            // is limited.
            mEditText.setBackgroundDrawable(newBg);
            mHasReconstructedEditTextBackground = true;
        }
    }
}
DrawableUtils.java 文件源码 项目:permissionsModule 阅读 36 收藏 0 点赞 0 评论 0
/**
 * Some drawable implementations have problems with mutation. This method returns false if
 * there is a known issue in the given drawable's implementation.
 */
static boolean canSafelyMutateDrawable(@NonNull Drawable drawable) {
    if (drawable instanceof LayerDrawable) {
        return Build.VERSION.SDK_INT >= 16;
    } else if (drawable instanceof InsetDrawable) {
        return Build.VERSION.SDK_INT >= 14;
    } else if (drawable instanceof StateListDrawable) {
        // StateListDrawable has a bug in mutate() on API 7
        return Build.VERSION.SDK_INT >= 8;
    } else if (drawable instanceof GradientDrawable) {
        // GradientDrawable has a bug pre-ICS which results in mutate() resulting
        // in loss of color
        return Build.VERSION.SDK_INT >= 14;
    } else if (drawable instanceof DrawableContainer) {
        // If we have a DrawableContainer, let's traverse it's child array
        final Drawable.ConstantState state = drawable.getConstantState();
        if (state instanceof DrawableContainer.DrawableContainerState) {
            final DrawableContainer.DrawableContainerState containerState =
                    (DrawableContainer.DrawableContainerState) state;
            for (Drawable child : containerState.getChildren()) {
                if (!canSafelyMutateDrawable(child)) {
                    return false;
                }
            }
        }
    } else if (drawable instanceof android.support.v4ox.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v4ox.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    } else if (drawable instanceof android.support.v7ox.graphics.drawable.DrawableWrapper) {
        return canSafelyMutateDrawable(
                ((android.support.v7ox.graphics.drawable.DrawableWrapper) drawable)
                        .getWrappedDrawable());
    }
    return true;
}
BufferTextInputLayout.java 文件源码 项目:BufferTextInputLayout 阅读 33 收藏 0 点赞 0 评论 0
private void ensureBackgroundDrawableStateWorkaround() {
    final int sdk = Build.VERSION.SDK_INT;
    if (sdk != 21 && sdk != 22) {
        // The workaround is only required on API 21-22
        return;
    }
    final Drawable bg = editText.getBackground();
    if (bg == null) {
        return;
    }
    if (!hasReconstructedEditTextBackground) {
        // This is gross. There is an issue in the platform which affects container Drawables
        // where the first drawable retrieved from resources will propagate any changes
        // (like color filter) to all instances from the cache. We'll try to workaround it...
        final Drawable newBg = bg.getConstantState().newDrawable();
        if (bg instanceof DrawableContainer) {
            // If we have a Drawable container, we can try and set it's constant state via
            // reflection from the new Drawable
            hasReconstructedEditTextBackground =
                    DrawableUtils.setContainerConstantState(
                            (DrawableContainer) bg, newBg.getConstantState());
        }
        if (!hasReconstructedEditTextBackground) {
            // If we reach here then we just need to set a brand new instance of the Drawable
            // as the background. This has the unfortunate side-effect of wiping out any
            // user set padding, but I'd hope that use of custom padding on an EditText
            // is limited.
            ViewCompat.setBackground(editText, newBg);
            hasReconstructedEditTextBackground = true;
        }
    }
}
TextInputLayout.java 文件源码 项目:material-components-android 阅读 20 收藏 0 点赞 0 评论 0
private void ensureBackgroundDrawableStateWorkaround() {
  final int sdk = Build.VERSION.SDK_INT;
  if (sdk != 21 && sdk != 22) {
    // The workaround is only required on API 21-22
    return;
  }
  final Drawable bg = editText.getBackground();
  if (bg == null) {
    return;
  }

  if (!hasReconstructedEditTextBackground) {
    // This is gross. There is an issue in the platform which affects container Drawables
    // where the first drawable retrieved from resources will propagate any changes
    // (like color filter) to all instances from the cache. We'll try to work around it...

    final Drawable newBg = bg.getConstantState().newDrawable();

    if (bg instanceof DrawableContainer) {
      // If we have a Drawable container, we can try and set its constant state via
      // reflection from the new Drawable
      hasReconstructedEditTextBackground =
          DrawableUtils.setContainerConstantState(
              (DrawableContainer) bg, newBg.getConstantState());
    }

    if (!hasReconstructedEditTextBackground) {
      // If we reach here then we just need to set a brand new instance of the Drawable
      // as the background. This has the unfortunate side-effect of wiping out any
      // user set padding, but I'd hope that use of custom padding on an EditText
      // is limited.
      ViewCompat.setBackground(editText, newBg);
      hasReconstructedEditTextBackground = true;
      // Re-apply box background mode to set the EditText's box padding if in box mode.
      onApplyBoxBackgroundMode();
    }
  }
}
SwitchButton.java 文件源码 项目:umeng_community_android 阅读 41 收藏 0 点赞 0 评论 0
private static Bitmap getBitmapFromDrawable(Drawable drawable) {
    if (drawable == null) {
        return null;
    }

    if (drawable instanceof DrawableContainer) {
        return getBitmapFromDrawable(drawable.getCurrent());
    } else if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else {
        return null;
    }
}
TintManager.java 文件源码 项目:FMTech 阅读 36 收藏 0 点赞 0 评论 0
private static boolean shouldMutateBackground(Drawable paramDrawable)
{
  if (Build.VERSION.SDK_INT >= 16) {}
  for (;;)
  {
    return true;
    if ((paramDrawable instanceof LayerDrawable))
    {
      if (Build.VERSION.SDK_INT < 16) {
        return false;
      }
    }
    else if ((paramDrawable instanceof InsetDrawable))
    {
      if (Build.VERSION.SDK_INT < 14) {
        return false;
      }
    }
    else if ((paramDrawable instanceof DrawableContainer))
    {
      Drawable.ConstantState localConstantState = paramDrawable.getConstantState();
      if ((localConstantState instanceof DrawableContainer.DrawableContainerState))
      {
        Drawable[] arrayOfDrawable = ((DrawableContainer.DrawableContainerState)localConstantState).getChildren();
        int i = arrayOfDrawable.length;
        for (int j = 0; j < i; j++) {
          if (!shouldMutateBackground(arrayOfDrawable[j])) {
            return false;
          }
        }
      }
    }
  }
}
DrawableCompat.java 文件源码 项目:FMTech 阅读 27 收藏 0 点赞 0 评论 0
public Drawable wrap(Drawable paramDrawable)
{
  if (((paramDrawable instanceof GradientDrawable)) || ((paramDrawable instanceof DrawableContainer))) {
    paramDrawable = new DrawableWrapperLollipop(paramDrawable);
  }
  return paramDrawable;
}
gq.java 文件源码 项目:FMTech 阅读 24 收藏 0 点赞 0 评论 0
public Drawable c(Drawable paramDrawable)
{
  if (((paramDrawable instanceof GradientDrawable)) || ((paramDrawable instanceof DrawableContainer))) {
    paramDrawable = new gx(paramDrawable);
  }
  return paramDrawable;
}
SwitchButton.java 文件源码 项目:AndroidGeek 阅读 32 收藏 0 点赞 0 评论 0
private static Bitmap getBitmapFromDrawable(Drawable drawable) {
    if (drawable == null) {
        return null;
    }

    if (drawable instanceof DrawableContainer) {
        return getBitmapFromDrawable(drawable.getCurrent());
    } else if (drawable instanceof BitmapDrawable) {
        return ((BitmapDrawable) drawable).getBitmap();
    } else {
        return null;
    }
}
CcDrawableUtils.java 文件源码 项目:CodeColors 阅读 19 收藏 0 点赞 0 评论 0
private static void forceStateChangeOnChildrenCompat(Drawable drawable) {
    Drawable.ConstantState drawableState = drawable.getConstantState();
    if (drawableState instanceof DrawableContainer.DrawableContainerState) {
        DrawableContainer.DrawableContainerState drawableContainerState =
                (DrawableContainer.DrawableContainerState) drawableState;

        Drawable[] children = drawableContainerState.getChildren();
        if (children != null) {
            for (Drawable child : children) {
                forceStateChange(child, true);
            }
        }
    }
}
CcDrawableUtils.java 文件源码 项目:CodeColors 阅读 18 收藏 0 点赞 0 评论 0
@TargetApi(Build.VERSION_CODES.KITKAT)
private static void forceStateChangeOnChildren(Drawable drawable) {
    Drawable.ConstantState drawableState = drawable.getConstantState();
    if (drawableState instanceof DrawableContainer.DrawableContainerState) {
        DrawableContainer.DrawableContainerState drawableContainerState =
                (DrawableContainer.DrawableContainerState) drawableState;

        for (int i = 0; i < drawableContainerState.getChildCount(); i++) {
            Drawable child = drawableContainerState.getChild(i);
            forceStateChange(child, true);
        }
    }
}


问题


面经


文章

微信
公众号

扫码关注公众号