Java 类android.support.v4.graphics.drawable.DrawableCompat 实例源码

项目:boohee_v5.6    文件:CoordinatorLayout.java   
public void setStatusBarBackground(@Nullable Drawable bg) {
    Drawable drawable = null;
    if (this.mStatusBarBackground != bg) {
        if (this.mStatusBarBackground != null) {
            this.mStatusBarBackground.setCallback(null);
        }
        if (bg != null) {
            drawable = bg.mutate();
        }
        this.mStatusBarBackground = drawable;
        if (this.mStatusBarBackground != null) {
            if (this.mStatusBarBackground.isStateful()) {
                this.mStatusBarBackground.setState(getDrawableState());
            }
            DrawableCompat.setLayoutDirection(this.mStatusBarBackground, ViewCompat.getLayoutDirection(this));
            this.mStatusBarBackground.setVisible(getVisibility() == 0, false);
            this.mStatusBarBackground.setCallback(this);
        }
        ViewCompat.postInvalidateOnAnimation(this);
    }
}
项目:GitHub    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    marqueeView1 = (SimpleMarqueeView) findViewById(R.id.marqueeView1);
    marqueeView2 = (SimpleMarqueeView) findViewById(R.id.marqueeView2);
    marqueeView3 = (SimpleMarqueeView) findViewById(R.id.marqueeView3);
    yellowSpeaker = (ImageView) findViewById(R.id.yellowSpeaker);
    marqueeView4 = (MarqueeView) findViewById(R.id.marqueeView4);
    marqueeView5 = (SimpleMarqueeView) findViewById(R.id.marqueeView5);
    marqueeView6 = (SimpleMarqueeView) findViewById(R.id.marqueeView6);
    DrawableCompat.setTint(DrawableCompat.wrap(yellowSpeaker.getDrawable().mutate()), getResources().getColor(R.color.yellow));

    initMarqueeView1();
    initMarqueeView2();
    initMarqueeView3();
    initMarqueeView4();
    initMarqueeView5();
    initMarqueeView6();
}
项目:GitHub    文件:Utils.java   
@UiThread // Implicit synchronization for use of shared resource VALUE.
public static Drawable getTintedDrawable(Context context,
    @DrawableRes int id, @AttrRes int tintAttrId) {
  boolean attributeFound = context.getTheme().resolveAttribute(tintAttrId, VALUE, true);
  if (!attributeFound) {
    throw new Resources.NotFoundException("Required tint color attribute with name "
        + context.getResources().getResourceEntryName(tintAttrId)
        + " and attribute ID "
        + tintAttrId
        + " was not found.");
  }

  Drawable drawable = ContextCompat.getDrawable(context, id);
  drawable = DrawableCompat.wrap(drawable.mutate());
  int color = ContextCompat.getColor(context, VALUE.resourceId);
  DrawableCompat.setTint(drawable, color);
  return drawable;
}
项目:GitHub    文件:MDTintHelper.java   
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color) {
    ColorStateList s1 = ColorStateList.valueOf(color);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        seekBar.setThumbTintList(s1);
        seekBar.setProgressTintList(s1);
    } else if (Build.VERSION.SDK_INT > Build.VERSION_CODES.GINGERBREAD_MR1) {
        Drawable progressDrawable = DrawableCompat.wrap(seekBar.getProgressDrawable());
        seekBar.setProgressDrawable(progressDrawable);
        DrawableCompat.setTintList(progressDrawable, s1);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = DrawableCompat.wrap(seekBar.getThumb());
            DrawableCompat.setTintList(thumbDrawable, s1);
            seekBar.setThumb(thumbDrawable);
        }
    } else {
        PorterDuff.Mode mode = PorterDuff.Mode.SRC_IN;
        if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.GINGERBREAD_MR1) {
            mode = PorterDuff.Mode.MULTIPLY;
        }
        if (seekBar.getIndeterminateDrawable() != null)
            seekBar.getIndeterminateDrawable().setColorFilter(color, mode);
        if (seekBar.getProgressDrawable() != null)
            seekBar.getProgressDrawable().setColorFilter(color, mode);
    }
}
项目:CameraFragment    文件:CameraSwitchView.java   
private void initializeView() {
    Context context = getContext();
    frontCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_front_white_24dp);
    frontCameraDrawable = DrawableCompat.wrap(frontCameraDrawable);
    DrawableCompat.setTintList(frontCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector));

    rearCameraDrawable = ContextCompat.getDrawable(context, R.drawable.ic_camera_rear_white_24dp);
    rearCameraDrawable = DrawableCompat.wrap(rearCameraDrawable);
    DrawableCompat.setTintList(rearCameraDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector));

    setBackgroundResource(R.drawable.circle_frame_background_dark);
    displayBackCamera();

    padding = Utils.convertDipToPixels(context, padding);
    setPadding(padding, padding, padding, padding);

    displayBackCamera();
}
项目:boohee_v5.6    文件:FloatingActionButtonEclairMr1.java   
void setBackgroundDrawable(ColorStateList backgroundTint, Mode backgroundTintMode, int rippleColor, int borderWidth) {
    Drawable[] layers;
    this.mShapeDrawable = DrawableCompat.wrap(createShapeDrawable());
    DrawableCompat.setTintList(this.mShapeDrawable, backgroundTint);
    if (backgroundTintMode != null) {
        DrawableCompat.setTintMode(this.mShapeDrawable, backgroundTintMode);
    }
    this.mRippleDrawable = DrawableCompat.wrap(createShapeDrawable());
    DrawableCompat.setTintList(this.mRippleDrawable, createColorStateList(rippleColor));
    if (borderWidth > 0) {
        this.mBorderDrawable = createBorderDrawable(borderWidth, backgroundTint);
        layers = new Drawable[]{this.mBorderDrawable, this.mShapeDrawable, this.mRippleDrawable};
    } else {
        this.mBorderDrawable = null;
        layers = new Drawable[]{this.mShapeDrawable, this.mRippleDrawable};
    }
    this.mContentBackground = new LayerDrawable(layers);
    this.mShadowDrawable = new ShadowDrawableWrapper(this.mView.getResources(), this.mContentBackground, this.mShadowViewDelegate.getRadius(), this.mElevation, this.mElevation + this.mPressedTranslationZ);
    this.mShadowDrawable.setAddPaddingForCorners(false);
    this.mShadowViewDelegate.setBackgroundDrawable(this.mShadowDrawable);
}
项目:AndelaTrackChallenge    文件:Easel.java   
/**
 * Tint the radio button
 *
 * @param radioButton the radio button
 * @param color       the color
 */
public static void tint(@NonNull RadioButton radioButton, @ColorInt int color) {
    final int disabledColor = getDisabledColor(radioButton.getContext());
    ColorStateList sl = new ColorStateList(new int[][]{
            new int[]{android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{android.R.attr.state_enabled, android.R.attr.state_checked},
            new int[]{-android.R.attr.state_enabled, -android.R.attr.state_checked},
            new int[]{-android.R.attr.state_enabled, android.R.attr.state_checked}
    }, new int[]{
            getThemeAttrColor(radioButton.getContext(), R.attr.colorControlNormal),
            color,
            disabledColor,
            disabledColor
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        radioButton.setButtonTintList(sl);
    } else {
        Drawable radioDrawable = ContextCompat.getDrawable(radioButton.getContext(), R.drawable.abc_btn_radio_material);
        Drawable d = DrawableCompat.wrap(radioDrawable);
        DrawableCompat.setTintList(d, sl);
        radioButton.setButtonDrawable(d);
    }
}
项目:ListItemView    文件:ListItemView.java   
/**
 * Set a color of icon on left side.
 *
 * @param iconColor a icon color
 */
public void setIconColor(@ColorInt final int iconColor) {
    mIconColor = iconColor;
    if (mDisplayMode == MODE_ICON && mIconView.getDrawable() != null) {
        ViewUtils.setIconColor(mIconView,
                Color.alpha(mIconColor) == 0 ? mDefaultColor : mIconColor);

    } else if (mDisplayMode == MODE_CIRCULAR_ICON
            && mCircularIconView.getIconDrawable() != null) {
        mCircularIconView.setMask(Color.alpha(mIconColor) == 0);
        Drawable wrappedDrawable = DrawableCompat.wrap(mCircularIconView.getIconDrawable());
        DrawableCompat.setTint(wrappedDrawable,
                Color.alpha(mIconColor) == 0 ? Color.WHITE : mIconColor);
        mCircularIconView.setIconDrawable(wrappedDrawable);
    }
}
项目:memetastic    文件:ContextUtils.java   
public Bitmap drawableToBitmap(Drawable drawable) {
    Bitmap bitmap = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && (drawable instanceof VectorDrawable || drawable instanceof VectorDrawableCompat)) {
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            drawable = (DrawableCompat.wrap(drawable)).mutate();
        }

        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);
    } else if (drawable instanceof BitmapDrawable) {
        bitmap = ((BitmapDrawable) drawable).getBitmap();
    }
    return bitmap;
}
项目:ColorRatingBar    文件:ColorRatingBar.java   
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
        TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.ColorRatingBar, defStyleAttr, 0);
        int progressColor = a.getColor(R.styleable.ColorRatingBar_progress_color, ContextCompat.getColor(context, R.color.colorPrimary));
//        int halfColor = a.getColor(R.styleable.ColorRatingBar_half_color, ContextCompat.getColor(context, R.color.colorAccent));
        int emptyColor = a.getColor(R.styleable.ColorRatingBar_empty_color, ContextCompat.getColor(context, R.color.colorAccent));
        boolean changeable = a.getBoolean(R.styleable.ColorRatingBar_changeable, true);

        LayerDrawable stars = (LayerDrawable) getProgressDrawable();
        // Filled stars
        setRatingStarColor(DrawableCompat.wrap(stars.getDrawable(2)), progressColor);
        // Half filled stars
        setRatingStarColor(DrawableCompat.wrap(stars.getDrawable(1)), progressColor);
        // Empty stars
        setRatingStarColor(DrawableCompat.wrap(stars.getDrawable(0)), emptyColor);

        setIsIndicator(!changeable);
    }
项目:android_camera_experiment    文件:MediaActionSwitchView.java   
private void initializeView() {
        photoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_photo_camera_white_24dp);
        photoDrawable = DrawableCompat.wrap(photoDrawable);
        DrawableCompat.setTintList(photoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector));

        videoDrawable = ContextCompat.getDrawable(context, R.drawable.ic_videocam_white_24dp);
        videoDrawable = DrawableCompat.wrap(videoDrawable);
        DrawableCompat.setTintList(videoDrawable.mutate(), ContextCompat.getColorStateList(context, R.drawable.switch_camera_mode_selector));

        setBackgroundResource(R.drawable.circle_frame_background_dark);
//        setBackgroundResource(R.drawable.circle_frame_background);

        setOnClickListener(new MediaActionClickListener());
        setIcons();
        padding = Utils.convertDipToPixels(context, padding);
        setPadding(padding, padding, padding, padding);
    }
项目:boohee_v5.6    文件:AppCompatCompoundButtonHelper.java   
void applyButtonTint() {
    Drawable buttonDrawable = CompoundButtonCompat.getButtonDrawable(this.mView);
    if (buttonDrawable == null) {
        return;
    }
    if (this.mHasButtonTint || this.mHasButtonTintMode) {
        buttonDrawable = DrawableCompat.wrap(buttonDrawable).mutate();
        if (this.mHasButtonTint) {
            DrawableCompat.setTintList(buttonDrawable, this.mButtonTintList);
        }
        if (this.mHasButtonTintMode) {
            DrawableCompat.setTintMode(buttonDrawable, this.mButtonTintMode);
        }
        if (buttonDrawable.isStateful()) {
            buttonDrawable.setState(this.mView.getDrawableState());
        }
        this.mView.setButtonDrawable(buttonDrawable);
    }
}
项目:revolution-irc    文件:ServerListAdapter.java   
public void bind(ServerListAdapter adapter, ServerConnectionInfo connectionInfo) {
    mConnectionInfo = connectionInfo;

    Drawable d = DrawableCompat.wrap(mIconBg.getBackground());
    if (connectionInfo.isConnected()) {
        DrawableCompat.setTint(d, adapter.mColorConnected);
        mIcon.setImageResource(R.drawable.ic_server_connected);
        int channels = connectionInfo.getChannels().size();
        mDesc.setText(mDesc.getResources().getQuantityString(R.plurals.server_list_connected, channels, channels));
    } else if (connectionInfo.isConnecting()) {
        DrawableCompat.setTint(d, adapter.mColorConnecting);
        mIcon.setImageResource(R.drawable.ic_refresh);
        mDesc.setText(R.string.server_list_connecting);
    } else {
        DrawableCompat.setTint(d, adapter.mColorDisconnected);
        mIcon.setImageResource(R.drawable.ic_close);
        mDesc.setText(R.string.server_list_disconnected);
    }
    mIconBg.setBackgroundDrawable(d);
    mName.setText(connectionInfo.getName());
}
项目:OSchina_resources_android    文件:AlignPopupWindow.java   
void setStyle(TextSection section) {
    switch (section.getAlignment()) {
        case TextSection.LEFT:
            DrawableCompat.setTint(mImageAlignLeft.getDrawable(), 0xff24cf5f);
            DrawableCompat.setTint(mImageAlignCenter.getDrawable(), 0xFFFFFFFF);
            DrawableCompat.setTint(mImageAlignRight.getDrawable(), 0xFFFFFFFF);
            break;
        case TextSection.CENTER:
            DrawableCompat.setTint(mImageAlignLeft.getDrawable(), 0xFFFFFFFF);
            DrawableCompat.setTint(mImageAlignCenter.getDrawable(), 0xff24cf5f);
            DrawableCompat.setTint(mImageAlignRight.getDrawable(), 0xFFFFFFFF);
            break;
        case TextSection.RIGHT:
            DrawableCompat.setTint(mImageAlignLeft.getDrawable(), 0xFFFFFFFF);
            DrawableCompat.setTint(mImageAlignCenter.getDrawable(), 0xFFFFFFFF);
            DrawableCompat.setTint(mImageAlignRight.getDrawable(), 0xff24cf5f);
            break;
    }
}
项目:boohee_v5.6    文件:ListViewCompat.java   
protected void positionSelectorLikeFocusCompat(int position, View sel) {
    boolean manageState;
    boolean z = true;
    Drawable selector = getSelector();
    if (selector == null || position == -1) {
        manageState = false;
    } else {
        manageState = true;
    }
    if (manageState) {
        selector.setVisible(false, false);
    }
    positionSelectorCompat(position, sel);
    if (manageState) {
        Rect bounds = this.mSelectorRect;
        float x = bounds.exactCenterX();
        float y = bounds.exactCenterY();
        if (getVisibility() != 0) {
            z = false;
        }
        selector.setVisible(z, false);
        DrawableCompat.setHotspot(selector, x, y);
    }
}
项目:qmui    文件:QMUICollapsingTopBarLayout.java   
/**
 * Set the drawable to use for the status bar scrim from resources.
 * Providing null will disable the scrim functionality.
 * <p>
 * <p>This scrim is only shown when we have been given a top system inset.</p>
 *
 * @param drawable the drawable to display
 * @see #getStatusBarScrim()
 */
public void setStatusBarScrim(@Nullable Drawable drawable) {
    if (mStatusBarScrim != drawable) {
        if (mStatusBarScrim != null) {
            mStatusBarScrim.setCallback(null);
        }
        mStatusBarScrim = drawable != null ? drawable.mutate() : null;
        if (mStatusBarScrim != null) {
            if (mStatusBarScrim.isStateful()) {
                mStatusBarScrim.setState(getDrawableState());
            }
            DrawableCompat.setLayoutDirection(mStatusBarScrim,
                    ViewCompat.getLayoutDirection(this));
            mStatusBarScrim.setVisible(getVisibility() == VISIBLE, false);
            mStatusBarScrim.setCallback(this);
            mStatusBarScrim.setAlpha(mScrimAlpha);
        }
        ViewCompat.postInvalidateOnAnimation(this);
    }
}
项目:FinalProject    文件:MessageInputStyle.java   
private Drawable getSelector(@ColorInt int normalColor, @ColorInt int pressedColor,
                             @ColorInt int disabledColor, @DrawableRes int shape) {

    Drawable drawable = DrawableCompat.wrap(getVectorDrawable(shape)).mutate();
    DrawableCompat.setTintList(
            drawable,
            new ColorStateList(
                    new int[][]{
                            new int[]{android.R.attr.state_enabled, -android.R.attr.state_pressed},
                            new int[]{android.R.attr.state_enabled, android.R.attr.state_pressed},
                            new int[]{-android.R.attr.state_enabled}
                    },
                    new int[]{normalColor, pressedColor, disabledColor}
            ));
    return drawable;
}
项目:DMAudioStreamer    文件:AdapterMusic.java   
private Drawable getDrawableByState(Context context, int state) {
    switch (state) {
        case PlaybackStateCompat.STATE_NONE:
            Drawable pauseDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play);
            DrawableCompat.setTintList(pauseDrawable, colorPlay);
            return pauseDrawable;
        case PlaybackStateCompat.STATE_PLAYING:
            AnimationDrawable animation = (AnimationDrawable) ContextCompat.getDrawable(context, R.drawable.equalizer);
            DrawableCompat.setTintList(animation, colorPlay);
            animation.start();
            return animation;
        case PlaybackStateCompat.STATE_PAUSED:
            Drawable playDrawable = ContextCompat.getDrawable(context, R.drawable.equalizer);
            DrawableCompat.setTintList(playDrawable, colorPause);
            return playDrawable;
        default:
            Drawable noneDrawable = ContextCompat.getDrawable(context, R.drawable.ic_play);
            DrawableCompat.setTintList(noneDrawable, colorPlay);
            return noneDrawable;
    }
}
项目:MTweaks-KernelAdiutorMOD    文件:BorderCircleView.java   
public BorderCircleView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    if (isClickable()) {
        setForeground(ViewUtils.getSelectableBackground(context));
    }
    mCheck = ContextCompat.getDrawable(context, R.drawable.ic_done);
    DrawableCompat.setTint(mCheck, Color.WHITE);

    mPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaint.setColor(ViewUtils.getThemeAccentColor(context));

    mPaintBorder = new Paint(Paint.ANTI_ALIAS_FLAG);
    mPaintBorder.setColor(ViewUtils.getColorPrimaryColor(context));
    mPaintBorder.setStrokeWidth((int) getResources().getDimension(R.dimen.circleview_border));
    mPaintBorder.setStyle(Paint.Style.STROKE);

    setWillNotDraw(false);
}
项目:FireFiles    文件:IconUtils.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public static Drawable applyTintList(Context context, int drawableId, int tintColorId) {
    final Drawable icon = getDrawable(context, drawableId);
    icon.mutate();
    DrawableCompat.setTintList(DrawableCompat.wrap(icon), ContextCompat.getColorStateList(context, tintColorId));
    return icon;
}
项目:GitHub    文件:ClearEditText.java   
private void init(final Context context) {

        final Drawable drawable = ContextCompat.getDrawable(context, R.drawable.svg_delete);
        final Drawable wrappedDrawable = DrawableCompat.wrap(drawable); //Wrap the drawable so that it can be tinted pre Lollipop
        DrawableCompat.setTint(wrappedDrawable, getCurrentHintTextColor());
        mClearTextIcon = wrappedDrawable;

//        mClearTextIcon= context.getResources().getDrawable(R.drawable.icon_delete_32);
        mClearTextIcon.setBounds(0, 0, mClearTextIcon.getIntrinsicHeight(), mClearTextIcon.getIntrinsicHeight());
        setClearIconVisible(false);
        super.setOnTouchListener(this);
        super.setOnFocusChangeListener(this);
        addTextChangedListener(this);
    }
项目:NumberPadTimePicker    文件:NumberPadTimePickerBottomSheetComponent.java   
@NonNull
private ValueAnimator createFabIconTintAnimator(int[] colors) {
    ValueAnimator anim = newArgbValueAnimator(colors);
    anim.setDuration(FAB_ANIM_DURATION);
    anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            DrawableCompat.setTintList(mOkButton.getDrawable(), ColorStateList.valueOf(
                    (int) animation.getAnimatedValue()));
        }
    });
    return anim;
}
项目:PreviewSeekBar    文件:PreviewSeekBar.java   
public void setTintColor(@ColorInt int color) {
    Drawable drawable = DrawableCompat.wrap(getThumb());
    DrawableCompat.setTint(drawable, color);
    setThumb(drawable);

    drawable = DrawableCompat.wrap(getProgressDrawable());
    DrawableCompat.setTint(drawable, color);
    setProgressDrawable(drawable);
}
项目:LoginConcept    文件:LoginActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    ButterKnife.bind(this);
    final AnimatedViewPager pager= ButterKnife.findById(this,R.id.pager);
    final ImageView background=ButterKnife.findById(this,R.id.scrolling_background);
    int[] screenSize=screenSize();

    for(ImageView element:sharedElements){
        @ColorRes int color=element.getId()!=R.id.logo?R.color.white_transparent:R.color.color_logo_log_in;
        DrawableCompat.setTint(element.getDrawable(), ContextCompat.getColor(this,color));
    }
    //load a very big image and resize it, so it fits our needs
    Glide.with(this)
            .load(R.drawable.busy)
            .asBitmap()
            .override(screenSize[0]*2,screenSize[1])
            .diskCacheStrategy(DiskCacheStrategy.RESULT)
            .into(new ImageViewTarget<Bitmap>(background) {
                @Override
                protected void setResource(Bitmap resource) {
                    background.setImageBitmap(resource);
                    background.post(()->{
                        //we need to scroll to the very left edge of the image
                        //fire the scale animation
                        background.scrollTo(-background.getWidth()/2,0);
                        ObjectAnimator xAnimator=ObjectAnimator.ofFloat(background,View.SCALE_X,4f,background.getScaleX());
                        ObjectAnimator yAnimator=ObjectAnimator.ofFloat(background,View.SCALE_Y,4f,background.getScaleY());
                        AnimatorSet set=new AnimatorSet();
                        set.playTogether(xAnimator,yAnimator);
                        set.setDuration(getResources().getInteger(R.integer.duration));
                        set.start();
                    });
                    pager.post(()->{
                        AuthAdapter adapter = new AuthAdapter(getSupportFragmentManager(), pager, background, sharedElements);
                        pager.setAdapter(adapter);
                    });
                }
            });
}
项目:MyAnimeViewer    文件:VideoPlayerActivity.java   
private void setUpCastButton() {
    if (TextUtils.isEmpty(getString(R.string.cast_app_id)))
        return;
    if (castContext != null && castSession != null) {
        Drawable remoteIndicatorDrawable = getRemoteIndicatorDrawable();
        DrawableCompat.setTint(remoteIndicatorDrawable, ContextCompat.getColor(this, android.R.color.white));
        mediaRouteButton.setRemoteIndicatorDrawable(remoteIndicatorDrawable);
        CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), mediaRouteButton);
    }
}
项目:KernelAdiutor-Mod    文件:EditorActivity.java   
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    Drawable drawable = ContextCompat.getDrawable(this, R.drawable.ic_save);
    DrawableCompat.setTint(drawable, Color.WHITE);
    menu.add(0, Menu.FIRST, Menu.FIRST, getString(R.string.save)).setIcon(drawable)
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    return super.onCreateOptionsMenu(menu);
}
项目:mapbox-navigation-android    文件:FeedbackBottomSheet.java   
private void initBackground(View view) {
  if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.LOLLIPOP) {
    int navigationViewPrimaryColor = ThemeSwitcher.retrieveNavigationViewThemeColor(getContext(),
      R.attr.navigationViewPrimary);
    int navigationViewSecondaryColor = ThemeSwitcher.retrieveNavigationViewThemeColor(getContext(),
      R.attr.navigationViewSecondary);
    // BottomSheet background
    Drawable bottomSheetBackground = DrawableCompat.wrap(view.getBackground()).mutate();
    DrawableCompat.setTint(bottomSheetBackground, navigationViewPrimaryColor);
    // ProgressBar progress color
    LayerDrawable progressBarBackground = (LayerDrawable) feedbackProgressBar.getProgressDrawable();
    Drawable progressDrawable = progressBarBackground.getDrawable(1);
    progressDrawable.setColorFilter(navigationViewSecondaryColor, PorterDuff.Mode.SRC_IN);
  }
}
项目:revolution-irc    文件:ThemedSeekBar.java   
public static void install(SeekBar seekBar, AttributeSet attrs) {
    ThemedView.setupBackground(seekBar, attrs);
    if (ThemeHelper.hasCustomAccentColor(seekBar.getContext())) {
        int accentColor = ThemeHelper.getAccentColor(seekBar.getContext());
        LayerDrawable ld = (LayerDrawable) seekBar.getProgressDrawable();
        ld.findDrawableByLayerId(android.R.id.progress).setColorFilter(accentColor,
                PorterDuff.Mode.SRC_IN);

        DrawableCompat.setTintList(seekBar.getThumb().mutate(),
                createSeekBarThumbColorList(seekBar.getContext()));
    }
}
项目:ListItemView    文件:ViewUtils.java   
public static void setIconColor(ImageView iconHolder, int color) {
    Drawable wrappedDrawable = DrawableCompat.wrap(iconHolder.getDrawable());
    DrawableCompat.setTint(wrappedDrawable, color);
    iconHolder.setImageDrawable(wrappedDrawable);
    iconHolder.invalidate();
}
项目:mobile-store    文件:AppSecurityPermissions.java   
@TargetApi(22)
public Drawable loadGroupIcon(Context context, PackageManager pm) {
    Drawable iconDrawable;
    if (icon != 0) {
        iconDrawable = (Build.VERSION.SDK_INT < 22) ? loadIcon(pm) : loadUnbadgedIcon(pm);
    } else {
        iconDrawable = ContextCompat.getDrawable(context, R.drawable.ic_perm_device_info);
    }

    Preferences.Theme theme = Preferences.get().getTheme();
    Drawable wrappedIconDrawable = DrawableCompat.wrap(iconDrawable).mutate();
    DrawableCompat.setTint(wrappedIconDrawable, theme == Preferences.Theme.light ? Color.BLACK : Color.WHITE);
    return wrappedIconDrawable;
}
项目:Mix    文件:ThemeUtils.java   
public static Drawable tintDrawable(Drawable drawable, ColorStateList cls, PorterDuff.Mode mode) {
    if (drawable == null) return null;
    Drawable wrapper = DrawableCompat.wrap(drawable.mutate());
    DrawableCompat.setTintList(wrapper, cls);
    DrawableCompat.setTintMode(drawable, mode);
    return wrapper;
}
项目:memetastic    文件:ContextUtils.java   
public Drawable tintDrawable(@Nullable Drawable drawable, @ColorInt int color) {
    if (drawable != null) {
        drawable = DrawableCompat.wrap(drawable);
        DrawableCompat.setTint(drawable.mutate(), color);
    }
    return drawable;
}
项目:NumberPadTimePicker    文件:NumberPadTimePickerBottomSheetComponent.java   
@Override
public BottomSheetNumberPadTimePickerThemer setFabIconTint(ColorStateList tint) {
    if (tint != null) {
        int[] colors = extractColors(tint, STATES_FAB_COLORS);
        if (mFabIconTintAnimator != null) {
            mFabIconTintAnimator.setIntValues(colors);
        } else {
            mFabIconTintAnimator = createFabIconTintAnimator(colors);
        }
    }
    DrawableCompat.setTintList(mOkButton.getDrawable(), tint);
    return this;
}
项目:tenor-android-demo-search    文件:AbstractDrawableUtils.java   
/**
 * Sets a tint on top of the desired drawable
 *
 * @param drawable     source drawable to apply the tint
 * @param tintColorInt color int of the desired tint
 */
public static void setDrawableTint(@NonNull final Drawable drawable,
                                   @ColorInt final int tintColorInt) {
    /*
     * === FIXED ===
     * In the latest support library, DrawableCompat.wrap() is no longer needed
     *
     * There is an invalidation issue when setting drawable state on pre-lollipop devices,
     * even if using the DrawableCompat.setTint() method.  It appears to be google support
     * library issue.  The get around is to use DrawableCompat.wrap() to wrap the drawable
     * before setting tint color
     *
     * http://stackoverflow.com/questions/30872101
     * https://code.google.com/p/android/issues/detail?id=172067#c13
     * =============
     */
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        /*
         * Tint ONLY the targeted drawable without affecting other drawables in the app.
         *
         * http://stackoverflow.com/questions/26788251
         */
        Drawable mutateDrawable = drawable.mutate();

        // Work for API 17 and below as well
        mutateDrawable.setColorFilter(tintColorInt, PorterDuff.Mode.SRC_IN);
    } else {
        DrawableCompat.setTint(drawable, tintColorInt);
    }
}
项目:Xndroid    文件:ThemeUtils.java   
@NonNull
private static Drawable getVectorDrawable(@NonNull Context context, int drawableId) {
    Drawable drawable = ContextCompat.getDrawable(context, drawableId);

    Preconditions.checkNonNull(drawable);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        drawable = (DrawableCompat.wrap(drawable)).mutate();
    }
    return drawable;
}
项目:YCDialog    文件:DialogAdapter.java   
private Drawable icon(Drawable drawable) {
    if (drawable != null) {
        Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
        @SuppressWarnings("SuspiciousNameCombination")
        Drawable resizeIcon = new BitmapDrawable(context.getResources(), Bitmap.createScaledBitmap(bitmap, leftIcon, leftIcon, true));
        Drawable.ConstantState state = resizeIcon.getConstantState();
        resizeIcon = DrawableCompat.wrap(state == null ? resizeIcon : state.newDrawable().mutate());
        return resizeIcon;
    }
    return null;
}
项目:Melophile    文件:PresentationUtils.java   
public static void setDrawableColor(TextView view, int color){
    Drawable[] drawables=view.getCompoundDrawables();
    for(Drawable drawable:drawables){
        if(drawable!=null){
            drawable.mutate();
            DrawableCompat.setTint(drawable,color);
        }
    }
}
项目:cwac-crossport    文件:FloatingActionButtonImpl.java   
void setBackgroundDrawable(ColorStateList backgroundTint,
        PorterDuff.Mode backgroundTintMode, int rippleColor, int borderWidth) {
    // Now we need to tint the original background with the tint, using
    // an InsetDrawable if we have a border width
    mShapeDrawable = DrawableCompat.wrap(createShapeDrawable());
    DrawableCompat.setTintList(mShapeDrawable, backgroundTint);
    if (backgroundTintMode != null) {
        DrawableCompat.setTintMode(mShapeDrawable, backgroundTintMode);
    }

    // Now we created a mask Drawable which will be used for touch feedback.
    GradientDrawable touchFeedbackShape = createShapeDrawable();

    // We'll now wrap that touch feedback mask drawable with a ColorStateList. We do not need
    // to inset for any border here as LayerDrawable will nest the padding for us
    mRippleDrawable = DrawableCompat.wrap(touchFeedbackShape);
    DrawableCompat.setTintList(mRippleDrawable, createColorStateList(rippleColor));

    final Drawable[] layers;
    if (borderWidth > 0) {
        mBorderDrawable = createBorderDrawable(borderWidth, backgroundTint);
        layers = new Drawable[] {mBorderDrawable, mShapeDrawable, mRippleDrawable};
    } else {
        mBorderDrawable = null;
        layers = new Drawable[] {mShapeDrawable, mRippleDrawable};
    }

    mContentBackground = new LayerDrawable(layers);

    mShadowDrawable = new ShadowDrawableWrapper(
            mView.getContext(),
            mContentBackground,
            mShadowViewDelegate.getRadius(),
            mElevation,
            mElevation + mPressedTranslationZ);
    mShadowDrawable.setAddPaddingForCorners(false);
    mShadowViewDelegate.setBackgroundDrawable(mShadowDrawable);
}
项目:Selector    文件:OneKeyClearEditText.java   
private void initClearDrawable(Context context) {
  mClearDrawable = getCompoundDrawables()[2];// 获取EditText的DrawableRight,假如没有设置我们就使用默认的图片
  if (mClearDrawable == null) {
    //          mClearDrawable = getResources().getDrawable(R.drawable.search_cancel, context.getTheme());
    mClearDrawable = getResources().getDrawable(R.drawable.search_cancel);
  }
  DrawableCompat.setTint(mClearDrawable, DrawableColor);// 设置删除按钮的颜色和TextColor的颜色一致
  mClearDrawable.setBounds(0, 0, (int) getTextSize(),
      (int) getTextSize());// 设置Drawable的宽高和TextSize的大小一致
  setClearIconVisible(false);
  // 设置焦点改变的监听
  setOnFocusChangeListener(this);
  // 设置输入框里面内容发生改变的监听
  addTextChangedListener(this);
}
项目:Cable-Android    文件:DocumentView.java   
public void setTint(int foregroundTint, int backgroundTint) {
  DrawableCompat.setTint(this.document.getBackground(), backgroundTint);
  DrawableCompat.setTint(this.documentBackground.getBackground(), foregroundTint);
  this.document.setTextColor(foregroundTint);

  this.fileName.setTextColor(foregroundTint);
  this.fileSize.setTextColor(foregroundTint);

  this.downloadButton.setColorFilter(foregroundTint);
  this.downloadProgress.setBarColor(foregroundTint);
}