Java 类android.support.v7.widget.AppCompatDrawableManager 实例源码

项目:boohee_v5.6    文件:FloatingActionButton.java   
public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.mShadowPadding = new Rect();
    ThemeUtils.checkAppCompatTheme(context);
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.FloatingActionButton, defStyleAttr, R.style.Widget_Design_FloatingActionButton);
    this.mBackgroundTint = a.getColorStateList(R.styleable.FloatingActionButton_backgroundTint);
    this.mBackgroundTintMode = parseTintMode(a.getInt(R.styleable.FloatingActionButton_backgroundTintMode, -1), null);
    this.mRippleColor = a.getColor(R.styleable.FloatingActionButton_rippleColor, 0);
    this.mSize = a.getInt(R.styleable.FloatingActionButton_fabSize, 0);
    this.mBorderWidth = a.getDimensionPixelSize(R.styleable.FloatingActionButton_borderWidth, 0);
    float elevation = a.getDimension(R.styleable.FloatingActionButton_elevation, 0.0f);
    float pressedTranslationZ = a.getDimension(R.styleable.FloatingActionButton_pressedTranslationZ, 0.0f);
    this.mCompatPadding = a.getBoolean(R.styleable.FloatingActionButton_useCompatPadding, false);
    a.recycle();
    this.mImageHelper = new AppCompatImageHelper(this, AppCompatDrawableManager.get());
    this.mImageHelper.loadFromAttributes(attrs, defStyleAttr);
    this.mImagePadding = (getSizeDimension() - ((int) getResources().getDimension(R.dimen.design_fab_image_size))) / 2;
    getImpl().setBackgroundDrawable(this.mBackgroundTint, this.mBackgroundTintMode, this.mRippleColor, this.mBorderWidth);
    getImpl().setElevation(elevation);
    getImpl().setPressedTranslationZ(pressedTranslationZ);
    getImpl().updatePadding();
}
项目:intra42    文件:mImage.java   
public static void setPicasso(Context context, Uri url, ImageView imageView, @DrawableRes int placeHolder) {

        Picasso picasso = Picasso.with(context);

        if (BuildConfig.DEBUG)
            picasso.setLoggingEnabled(true);

        RequestCreator requestCreator = picasso.load(url);

        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            requestCreator.placeholder(placeHolder);
            requestCreator.error(placeHolder);
        } else {
            Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, placeHolder);
            requestCreator.placeholder(drawable);
            requestCreator.error(drawable);
        }

        requestCreator.into(imageView);
    }
项目:training-epam-2016    文件:IcButton.java   
private void init(final AttributeSet attrs, final int defStyleAttr) {
    final TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs,
            R.styleable.IcButtonStyle, defStyleAttr, 0);
    try {
        final AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get();
        Drawable rightIcon = a.getDrawableIfKnown(R.styleable.IcButtonStyle_rightIcon);

        int id = a.getResourceId(R.styleable.IcButtonStyle_rightIcon, -1);
        if (id != -1) {
            rightIcon = drawableManager.getDrawable(getContext(), id);
        }
        Drawable topIcon = a.getDrawableIfKnown(R.styleable.IcButtonStyle_topIcon);
        id = a.getResourceId(R.styleable.IcButtonStyle_topIcon, -1);
        if (id != -1) {
            topIcon = drawableManager.getDrawable(getContext(), id);
        }

        setCompoundDrawablesWithIntrinsicBounds(null, topIcon, rightIcon, null);
    } finally {
        a.recycle();
    }
}
项目:Game-of-Thrones    文件:MessageRenderer.java   
private void renderMessageFromOthers(Message message) {
  User user = message.getUser();
  rootView.setGravity(Gravity.BOTTOM | Gravity.START);
  displayNameTextView.setVisibility(View.VISIBLE);
  avatarImageView.setVisibility(View.VISIBLE);

  imageLoader.builder()
      .load(user.getImageUrl())
      .placeHolder(AppCompatDrawableManager.get().getDrawable(avatarImageView.getContext(),
          R.drawable.ned_head_light))
      .into(avatarImageView)
      .circle()
      .show();

  displayNameTextView.setText(user.getName());
  displayPayLoad(message.getPayload());
  messageContainer.setBackgroundResource(R.drawable.background_message_from_others);
}
项目:Game-of-Thrones    文件:MessageRenderer.java   
private void displayPayLoad(Payload payload) {
  if (payload instanceof ImagePayload) {
    ImagePayload imagePayload = (ImagePayload) payload;
    imageLoader.builder()
        .load(imagePayload.getImageMessage())
        .placeHolder(AppCompatDrawableManager.get().getDrawable(avatarImageView.getContext(),
            R.drawable.ned_head_light))
        .into(messageImageView)
        .show();
  } else {
    messageImageView.setVisibility(View.GONE);
  }

  TextPayLoad textPayload = (TextPayLoad) payload;
  Spannable textMessage = textPayload.getTextMessage();
  messageTextView.setText(textMessage);
}
项目:Game-of-Thrones    文件:StickerRenderer.java   
@Override
public void render() {
  Message message = getContent();

  Uri sticker = ((StickerPayLoad) message.getPayload()).getSticker();
  stickerImageView.setImageURI(sticker);

  if (message.isFromMe()) {
    avatarImageView.setVisibility(View.GONE);
    rootView.setGravity(Gravity.BOTTOM | Gravity.END);
  } else {
    avatarImageView.setVisibility(View.VISIBLE);
    rootView.setGravity(Gravity.BOTTOM | Gravity.START);

    imageLoader.builder()
        .load(message.getUser().getImageUrl())
        .placeHolder(AppCompatDrawableManager.get().getDrawable(avatarImageView.getContext(),
            R.drawable.ned_head_light))
        .into(avatarImageView)
        .circle()
        .show();
  }
}
项目:material-components-android    文件:FloatingActionButton.java   
private void onApplySupportImageTint() {
  Drawable drawable = getDrawable();
  if (drawable == null) {
    return;
  }

  if (imageTint == null) {
    DrawableCompat.clearColorFilter(drawable);
    return;
  }

  int color = imageTint.getColorForState(getDrawableState(), Color.TRANSPARENT);
  Mode mode = imageMode;
  if (mode == null) {
    mode = Mode.SRC_IN;
  }

  drawable
      .mutate()
      .setColorFilter(AppCompatDrawableManager.getPorterDuffColorFilter(color, mode));
}
项目:calchoochoo    文件:DrawableUtils.java   
public static Bitmap getBitmapFromVectorDrawable(Context context, int drawableId, float scale) {
  Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, drawableId);
  int scaledWidth = (int)(drawable.getIntrinsicWidth() * scale);
  int scaledHeight = (int)(drawable.getIntrinsicHeight() * scale);

  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    drawable = (DrawableCompat.wrap(drawable)).mutate();
  }

  Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
  Canvas canvas = new Canvas(bitmap);
  drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
  drawable.draw(canvas);

  Bitmap bitmapResized = Bitmap.createScaledBitmap(bitmap, scaledWidth, scaledHeight, false);
  bitmap.recycle();

  return bitmapResized;
}
项目:AppCompat-Extension-Library    文件:PickerThemeUtils.java   
public static void setNavButtonDrawable(Context context, ImageButton left, ImageButton right,
                                        int monthTextAppearanceResId) {
    // Retrieve the previous and next drawables
    AppCompatDrawableManager dm = AppCompatDrawableManager.get();
    Drawable prevDrawable = dm.getDrawable(context, R.drawable.ic_chevron_left_black_24dp);
    Drawable nextDrawable = dm.getDrawable(context, R.drawable.ic_chevron_right_black_24dp);

    // Proxy the month text color into the previous and next drawables.
    final TypedArray ta = context.obtainStyledAttributes(null,
            new int[]{android.R.attr.textColor}, 0, monthTextAppearanceResId);
    final ColorStateList monthColor = ta.getColorStateList(0);
    if (monthColor != null) {
        DrawableCompat.setTint(DrawableCompat.wrap(prevDrawable), monthColor.getDefaultColor());
        DrawableCompat.setTint(DrawableCompat.wrap(nextDrawable), monthColor.getDefaultColor());
    }
    ta.recycle();

    // Set the previous and next drawables
    left.setImageDrawable(prevDrawable);
    right.setImageDrawable(nextDrawable);
}
项目:AppCompat-Extension-Library    文件:FloatingActionMenu.java   
private void init(Context context, AttributeSet attributeSet) {
    mButtonSpacing = getResources().getDimensionPixelSize(R.dimen.fam_spacing);
    mLabelsMargin = getResources().getDimensionPixelSize(R.dimen.fam_label_spacing);
    mLabelsVerticalOffset = 0;

    TypedArray attr = context.obtainStyledAttributes(attributeSet, R.styleable.FloatingActionMenu, 0, 0);
    mExpandDirection = attr.getInt(R.styleable.FloatingActionMenu_fabMenuExpandDirection, EXPAND_UP);
    mLabelsPosition = attr.getInt(R.styleable.FloatingActionMenu_fabMenuLabelPosition, LABELS_ON_LEFT_SIDE);
    mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_fabMenuLabelStyle, 0);
    int mCloseDrawableResourceId = attr.getResourceId(R.styleable.FloatingActionMenu_fabMenuCloseIconSrc, 0);
    mCloseDrawable = mCloseDrawableResourceId == 0 ? null : AppCompatDrawableManager.get().getDrawable(getContext(), mCloseDrawableResourceId);
    mCloseAngle = attr.getFloat(R.styleable.FloatingActionMenu_fabMenuCloseIconAngle, 0);
    mButtonSpacing = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_fabMenuSpacing, mButtonSpacing);
    attr.recycle();

    if (mLabelsStyle != 0 && expandsHorizontally()) {
        throw new IllegalStateException("Action labels in horizontal expand orientation is not supported.");
    }

    // So we can catch the back button
    setFocusableInTouchMode(true);
}
项目:AnimatedPencil    文件:AnimatedPencil.java   
private void init(Context context, AttributeSet attrs) {
    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.AnimatedPencil);
    if (typedArray != null) {
        color = typedArray.getColor(R.styleable.AnimatedPencil_pencil_color, color);
        typedArray.recycle();
    }
    imageView = new AppCompatImageView(getContext());
    addView(imageView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    drawable = AppCompatDrawableManager.get().getDrawable(getContext(), R.drawable.awsb_ic_edit_animated_24);
    drawable = DrawableCompat.wrap(drawable).mutate();
    DrawableCompat.setTint(drawable, color);
    imageView.setImageDrawable(drawable);
}
项目:qmui    文件:QMUIDrawableHelper.java   
public static @Nullable Drawable getVectorDrawable(Context context, @DrawableRes int resVector) {
    try {
        return AppCompatDrawableManager.get().getDrawable(context, resVector);
    } catch (Exception e) {
        QMUILog.d(TAG, "Error in getVectorDrawable. resVector=" + resVector + ", resName=" + context.getResources().getResourceName(resVector) + e.getMessage());
        return null;
    }
}
项目:Farmacias    文件:ImageUtils.java   
public Bitmap getBitmapFromVectorDrawable(Context context, int drawableId) {
    Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, drawableId);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        drawable = (DrawableCompat.wrap(drawable)).mutate();
    }

    Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
            drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);

    return bitmap;
}
项目:Mire    文件:DrawableHelpers.java   
@Nullable
public static int getDrawableInt(@NonNull Context context, @DrawableRes int res)
{
    Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, res);
    drawable.mutate();

    return res;
}
项目:Mire    文件:DrawableHelpers.java   
@Nullable
public static int getTintedDrawableInt(@NonNull Context context, @DrawableRes int res, @ColorInt int color)
{
    Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, res);
    drawable.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
    drawable.mutate();

    return res;
}
项目:Mire    文件:DrawableHelpers.java   
@Nullable
   public static Drawable getTintedDrawable(@NonNull Context context, @DrawableRes int res, @ColorInt int color)
{
       try 
    {
           Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, res);
           drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);

        return drawable.mutate();
       } 
    catch (OutOfMemoryError e)
    {
           return null;
       }
   }
项目:Mire    文件:DrawableHelper.java   
@Nullable
public static Drawable getDrawable(@NonNull Context context, @DrawableRes int res)
{
    Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, res);

    return drawable.mutate();
}
项目:Mire    文件:DrawableHelper.java   
@Nullable
@ColorInt
public static int getDrawableInt(@NonNull Context context, @DrawableRes int res, @ColorInt int color)
{
    Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, res);
    drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);
    drawable.mutate();

    return color;
}
项目:Mire    文件:DrawableHelper.java   
@Nullable
   public static Drawable getTintedDrawable(@NonNull Context context, @DrawableRes int res, @ColorInt int color)
{
       try 
    {
           Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, res);
           drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN);

        return drawable.mutate();
       } 
    catch (OutOfMemoryError e)
    {
           return null;
       }
   }
项目:ButtonProgressBar    文件:ButtonProgressBar.java   
/**
 * Get mTickBitmap image from vector drawable defined in xml
 * @param context - context to load drawable from resources
 * @param drawableId - drawable id of the vector drawable
 * @return - mTickBitmap image
 */
private Bitmap getBitmapFromVectorDrawable(Context context, int drawableId) {
    Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, drawableId);
    if (Build.VERSION.SDK_INT < API_LEVEL_LOLLIPOP) {
        drawable = (DrawableCompat.wrap(drawable)).mutate();
    }
    Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
            drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(topX, topY, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}
项目:boohee_v5.6    文件:MenuItemImpl.java   
public Drawable getIcon() {
    if (this.mIconDrawable != null) {
        return this.mIconDrawable;
    }
    if (this.mIconResId == 0) {
        return null;
    }
    Drawable icon = AppCompatDrawableManager.get().getDrawable(this.mMenu.getContext(), this.mIconResId);
    this.mIconResId = 0;
    this.mIconDrawable = icon;
    return icon;
}
项目:boohee_v5.6    文件:TabLayout.java   
@NonNull
public Tab setIcon(@DrawableRes int resId) {
    if (this.mParent != null) {
        return setIcon(AppCompatDrawableManager.get().getDrawable(this.mParent.getContext(), resId));
    }
    throw new IllegalArgumentException("Tab not attached to a TabLayout");
}
项目:boohee_v5.6    文件:TabLayout.java   
public TabView(Context context) {
    super(context);
    if (TabLayout.this.mTabBackgroundResId != 0) {
        setBackgroundDrawable(AppCompatDrawableManager.get().getDrawable(context, TabLayout.this.mTabBackgroundResId));
    }
    ViewCompat.setPaddingRelative(this, TabLayout.this.mTabPaddingStart, TabLayout.this.mTabPaddingTop, TabLayout.this.mTabPaddingEnd, TabLayout.this.mTabPaddingBottom);
    setGravity(17);
    setOrientation(1);
    setClickable(true);
}
项目:boohee_v5.6    文件:TextInputLayout.java   
private void updateEditTextBackground() {
    ensureBackgroundDrawableStateWorkaround();
    Drawable editTextBackground = this.mEditText.getBackground();
    if (editTextBackground != null) {
        if (this.mErrorShown && this.mErrorView != null) {
            editTextBackground.setColorFilter(AppCompatDrawableManager.getPorterDuffColorFilter(this.mErrorView.getCurrentTextColor(), Mode.SRC_IN));
        } else if (!this.mCounterOverflowed || this.mCounterView == null) {
            editTextBackground.clearColorFilter();
            this.mEditText.refreshDrawableState();
        } else {
            editTextBackground.setColorFilter(AppCompatDrawableManager.getPorterDuffColorFilter(this.mCounterView.getCurrentTextColor(), Mode.SRC_IN));
        }
    }
}
项目:cafebar    文件:CafeBarUtil.java   
@Nullable
static Drawable getDrawable(@NonNull Context context, @DrawableRes int res) {
    try {
        Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, res);
        return drawable.mutate();
    } catch (OutOfMemoryError e) {
        return null;
    }
}
项目:BufferTextInputLayout    文件:BufferTextInputLayout.java   
private void updateEditTextBackground() {
    if (editText == null) {
        return;
    }
    Drawable editTextBackground = editText.getBackground();
    if (editTextBackground == null) {
        return;
    }
    ensureBackgroundDrawableStateWorkaround();
    if (android.support.v7.widget.DrawableUtils.canSafelyMutateDrawable(editTextBackground)) {
        editTextBackground = editTextBackground.mutate();
    }
    if (errorShown && errorView != null) {
        // Set a color filter of the error color
        editTextBackground.setColorFilter(
                AppCompatDrawableManager.getPorterDuffColorFilter(
                        errorView.getCurrentTextColor(), PorterDuff.Mode.SRC_IN));
    } else if (counterOverflowed && counterView != null) {
        // Set a color filter of the counter color
        editTextBackground.setColorFilter(
                AppCompatDrawableManager.getPorterDuffColorFilter(
                        counterView.getCurrentTextColor(), PorterDuff.Mode.SRC_IN));
    } else {
        // Else reset the color filter and refresh the drawable state so that the
        // normal tint is used
        DrawableCompat.clearColorFilter(editTextBackground);
        editText.refreshDrawableState();
    }
}
项目:material-components-android    文件:TextInputLayout.java   
void updateEditTextBackground() {
  if (editText == null) {
    return;
  }

  Drawable editTextBackground = editText.getBackground();
  if (editTextBackground == null) {
    return;
  }

  ensureBackgroundDrawableStateWorkaround();

  if (android.support.v7.widget.DrawableUtils.canSafelyMutateDrawable(editTextBackground)) {
    editTextBackground = editTextBackground.mutate();
  }

  if (indicatorViewController.errorShouldBeShown()) {
    // Set a color filter for the error color
    editTextBackground.setColorFilter(
        AppCompatDrawableManager.getPorterDuffColorFilter(
            indicatorViewController.getErrorViewCurrentTextColor(), PorterDuff.Mode.SRC_IN));
  } else if (counterOverflowed && counterView != null) {
    // Set a color filter of the counter color
    editTextBackground.setColorFilter(
        AppCompatDrawableManager.getPorterDuffColorFilter(
            counterView.getCurrentTextColor(), PorterDuff.Mode.SRC_IN));
  } else {
    // Else reset the color filter and refresh the drawable state so that the
    // normal tint is used
    DrawableCompat.clearColorFilter(editTextBackground);
    editText.refreshDrawableState();
  }
}
项目:PieViewGroup    文件:LegendItemView.java   
public LegendItemView(@NonNull Context context, @NonNull LegendItem item) {
    super(context);
    this.mContext = context;
    this.setText(item.text);
    this.setClickable(false);
    this.setFocusable(false);
    this.setTextSize(item.textsize);
    this.setCompoundDrawablePadding(6);
    this.setSingleLine(true);
    if (item.typeface!=null) this.setTypeface(item.typeface);
    this.setGravity(Gravity.CENTER_VERTICAL);
    this.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT));
    // detect RTL environment
    final boolean rtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL;
    Drawable start, end;
    // Account for RTL and
    if (item.iconid==0) {
        final Drawable marker = createMarker(item.color);
        start = rtl ? null : marker;
        end = rtl ? marker : null;
    } else {
        // Obtain DrawableManager
        final AppCompatDrawableManager dm = AppCompatDrawableManager.get();
        start = rtl ? null : dm.getDrawable(context, item.iconid);
        end = rtl ? dm.getDrawable(context, item.iconid) : null;
        Utils.PVGColors.tintMyDrawable(start, item.color);
    }
    // apply the compound Drawables
    setCompoundDrawablesWithIntrinsicBounds(start, null, end, null);
}
项目:RecyclerExt    文件:FastScroll.java   
/**
 * A utility method to retrieve a drawable that correctly abides by the
 * theme in Lollipop (API 23) +
 *
 * @param resourceId The resource id for the drawable
 * @return The drawable associated with {@code resourceId}
 */
@Nullable
@SuppressLint("RestrictedApi")
protected Drawable getDrawable(@DrawableRes int resourceId) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        return getResources().getDrawable(resourceId, getContext().getTheme());
    }

    return AppCompatDrawableManager.get().getDrawable(getContext(), resourceId);
}
项目:RecyclerExt    文件:FastScroll.java   
/**
 * Retrieves the specified image drawable in a manner that will correctly
 * wrap VectorDrawables on platforms that don't natively support them
 *
 * @param typedArray The TypedArray containing the attributes for the view
 * @param index The index in the {@code typedArray} for the drawable
 */
@Nullable
@SuppressLint("RestrictedApi")
protected Drawable getDrawable(@NonNull TypedArray typedArray, int index) {
    int imageResId = typedArray.getResourceId(index, 0);
    if (imageResId == 0) {
        return null;
    }

    return AppCompatDrawableManager.get().getDrawable(getContext(), imageResId);
}
项目:AppCompat-Extension-Library    文件:AccountAdapter.java   
private static void setupCheckBox(CheckBox checkBox) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        checkBox.setButtonDrawable(R.drawable.btn_checkbox_circle);
        checkBox.setBackgroundResource(R.drawable.btn_checkbox_circle_background);
    } else {
        Context context = checkBox.getContext();
        AppCompatDrawableManager dm = AppCompatDrawableManager.get();

        StateListDrawable button = new StateListDrawable();
        button.addState(new int[]{android.R.attr.state_checked},
                dm.getDrawable(context, R.drawable.ic_checkbox_circle_checked));
        button.addState(new int[]{},
                dm.getDrawable(context, R.drawable.ic_checkbox_circle_unchecked));
        ColorStateList buttonTint = new ColorStateList(new int[][]{ // states
                new int[]{android.R.attr.state_checked},
                new int[]{} // state_default
        }, new int[]{ // colors
                ThemeUtils.getThemeAttrColor(context, R.attr.colorControlActivated),
                ThemeUtils.getThemeAttrColor(context, R.attr.colorControlNormal)
        });
        Drawable buttonCompat = DrawableCompat.wrap(button);
        DrawableCompat.setTintList(buttonCompat, buttonTint);
        checkBox.setButtonDrawable(buttonCompat);

        ShapeDrawable background = new ShapeDrawable(new OvalShape());
        int backgroundTint = ThemeUtils.getThemeAttrColor(context, android.R.attr.colorBackground);
        Drawable backgroundCompat = DrawableCompat.wrap(background);
        DrawableCompat.setTint(backgroundCompat, backgroundTint);
        ViewCompatUtils.setBackground(checkBox, backgroundCompat);
    }
}
项目:CodeColors    文件:CcAppCompatDrawableWrapper.java   
protected void updateTintList() {
    if (mUpdateTintList) {
        mUpdateTintList = false;

        Drawable rootDrawable = getRootDrawable(this);
        View view = getView(rootDrawable);
        Context context = getContext(view);
        if (context != null) {
            AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get();
            // The context wrapper ensures that the manager doesn't reuse old tint lists.
            Context contextWrapper = new ContextWrapper(context);
            ColorStateList tintList = drawableManager.getTintList(contextWrapper, mState.mId);

            if (tintList != null && isTintableBackground(view, rootDrawable)) {
                ColorStateList viewTintList = ((TintableBackgroundView) view).getSupportBackgroundTintList();
                // TintableBackgroundViews store internal tintLists for known drawables.
                // Those tintLists can become outdated, if they contain attributes that are code-colors.
                // We make sure to store and enforce different tintList every time the code-colors change.
                if (viewTintList == null || viewTintList == mTintList) {
                    ((TintableBackgroundView) view).setSupportBackgroundTintList(tintList);
                }
                mTintList = tintList;
            } else {
                // If tint list is null, tintDrawable will still try to set color filters.
                CcTintManager.tintDrawable(context, tintList, mDrawable, mState.mId);
            }
        }
    }
}
项目:vuze-remote-for-android    文件:AndroidUtilsUI.java   
@Nullable
public static Drawable getDrawableWithBounds(Context context, int resID) {
    Drawable drawableCompat = AppCompatDrawableManager.get().getDrawable(
            context, resID);
    if (drawableCompat != null) {
        if (drawableCompat.getBounds().isEmpty()) {
            drawableCompat.setBounds(0, 0, drawableCompat.getIntrinsicWidth(),
                    drawableCompat.getIntrinsicHeight());
        }
    }
    return drawableCompat;
}
项目:OCiney    文件:AppFragmentActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_activity);
    ButterKnife.bind(this);

    setSupportActionBar(toolbar);
    toolbar.setTitleTextColor(Color.WHITE);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    findViewById(R.id.left_drawer).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

        }
    });

    ajouterFragment(ListMoviesFragment.newInstance(moviesNowShowing, true));

    ajouterListener();

    TypedArray a = getTheme().obtainStyledAttributes(R.style.AppTheme, new int[]{R.attr.homeAsUpIndicator});
    Drawable drawable = AppCompatDrawableManager.get().getDrawable(this, a.getResourceId(0, 0));
    drawable.setColorFilter(getResources().getColor(android.R.color.white), PorterDuff.Mode.SRC_IN);
    drawerToggle.setHomeAsUpIndicator(drawable);

    recherchePlaceholder = "Rechercher un film";

}
项目:iosched    文件:TextInputLayout.java   
private void updateEditTextBackground() {
  if (mEditText == null) {
    return;
  }

  Drawable editTextBackground = mEditText.getBackground();
  if (editTextBackground == null) {
    return;
  }

  ensureBackgroundDrawableStateWorkaround();

  if (android.support.v7.widget.DrawableUtils.canSafelyMutateDrawable(editTextBackground)) {
    editTextBackground = editTextBackground.mutate();
  }

  if (mErrorShown && mErrorView != null) {
    // Set a color filter of the error color
    editTextBackground.setColorFilter(
        AppCompatDrawableManager.getPorterDuffColorFilter(
            mErrorView.getCurrentTextColor(), PorterDuff.Mode.SRC_IN));
  } else if (mCounterOverflowed && mCounterView != null) {
    // Set a color filter of the counter color
    editTextBackground.setColorFilter(
        AppCompatDrawableManager.getPorterDuffColorFilter(
            mCounterView.getCurrentTextColor(), PorterDuff.Mode.SRC_IN));
  } else {
    // Else reset the color filter and refresh the drawable state so that the
    // normal tint is used
    DrawableCompat.clearColorFilter(editTextBackground);
    mEditText.refreshDrawableState();
  }
}
项目:Mire    文件:DrawableHelpers.java   
@Nullable
public static Drawable getDrawable(@NonNull Context context, @DrawableRes int res)
{
    Drawable drawable = AppCompatDrawableManager.get().getDrawable(context, res);
    return drawable.mutate();
}
项目:CompositionAvatar    文件:SampleActivity.java   
private void vector(CompositionAvatarView view) {
    AppCompatDrawableManager drawableManager = AppCompatDrawableManager.get();
    view.addDrawable(drawableManager.getDrawable(this, R.drawable.cloud_circle));
    view.addDrawable(drawableManager.getDrawable(this, R.drawable.album));
    view.addDrawable(drawableManager.getDrawable(this, R.drawable.group_work));
}
项目:boohee_v5.6    文件:AppCompatDelegateImplV7.java   
public void setBackgroundResource(int resid) {
    setBackgroundDrawable(AppCompatDrawableManager.get().getDrawable(getContext(), resid));
}
项目:boohee_v5.6    文件:WindowDecorActionBar.java   
public Tab setIcon(int resId) {
    return setIcon(AppCompatDrawableManager.get().getDrawable(WindowDecorActionBar.this.mContext, resId));
}
项目:AppChooser    文件:DirectoryTabView.java   
public DirectoryTabView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    Drawable arrowIcon = AppCompatDrawableManager.get()
            .getDrawable(context, R.drawable.ic_keyboard_arrow_right_white_24dp);
    arrowIcon.setBounds(0, 0, arrowIcon.getIntrinsicWidth(), arrowIcon.getIntrinsicHeight());

    setCompoundDrawables(null, null, arrowIcon, null);

    setGravity(Gravity.CENTER);

    setTextAppearance(context, R.style.TextAppearance_Design_Tab);

    ColorStateList tabTextColors = getTextColors();
    tabTextColors = createColorStateList(tabTextColors.getDefaultColor(), Color.WHITE);
    setTextColor(tabTextColors);

    setMaxLines(1);

    setEllipsize(TextUtils.TruncateAt.MIDDLE);

    setAllCaps(false);
}