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

CoordinatorLayout.java 文件源码 项目:boohee_v5.6 阅读 30 收藏 0 点赞 0 评论 0
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);
    }
}
MainActivity.java 文件源码 项目:GitHub 阅读 16 收藏 0 点赞 0 评论 0
@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();
}
Utils.java 文件源码 项目:GitHub 阅读 19 收藏 0 点赞 0 评论 0
@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;
}
MDTintHelper.java 文件源码 项目:GitHub 阅读 26 收藏 0 点赞 0 评论 0
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);
    }
}
CameraSwitchView.java 文件源码 项目:CameraFragment 阅读 14 收藏 0 点赞 0 评论 0
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();
}
FloatingActionButtonEclairMr1.java 文件源码 项目:boohee_v5.6 阅读 36 收藏 0 点赞 0 评论 0
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);
}
Easel.java 文件源码 项目:AndelaTrackChallenge 阅读 24 收藏 0 点赞 0 评论 0
/**
 * 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.java 文件源码 项目:ListItemView 阅读 17 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
ContextUtils.java 文件源码 项目:memetastic 阅读 36 收藏 0 点赞 0 评论 0
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.java 文件源码 项目:ColorRatingBar 阅读 18 收藏 0 点赞 0 评论 0
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);
    }
MediaActionSwitchView.java 文件源码 项目:android_camera_experiment 阅读 18 收藏 0 点赞 0 评论 0
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);
    }
AppCompatCompoundButtonHelper.java 文件源码 项目:boohee_v5.6 阅读 22 收藏 0 点赞 0 评论 0
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);
    }
}
ServerListAdapter.java 文件源码 项目:revolution-irc 阅读 20 收藏 0 点赞 0 评论 0
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());
}
AlignPopupWindow.java 文件源码 项目:OSchina_resources_android 阅读 17 收藏 0 点赞 0 评论 0
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;
    }
}
ListViewCompat.java 文件源码 项目:boohee_v5.6 阅读 17 收藏 0 点赞 0 评论 0
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);
    }
}
QMUICollapsingTopBarLayout.java 文件源码 项目:qmui 阅读 22 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
MessageInputStyle.java 文件源码 项目:FinalProject 阅读 19 收藏 0 点赞 0 评论 0
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;
}
AdapterMusic.java 文件源码 项目:DMAudioStreamer 阅读 28 收藏 0 点赞 0 评论 0
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;
    }
}
BorderCircleView.java 文件源码 项目:MTweaks-KernelAdiutorMOD 阅读 26 收藏 0 点赞 0 评论 0
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);
}
IconUtils.java 文件源码 项目:FireFiles 阅读 32 收藏 0 点赞 0 评论 0
@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;
}
ClearEditText.java 文件源码 项目:GitHub 阅读 30 收藏 0 点赞 0 评论 0
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);
    }
NumberPadTimePickerBottomSheetComponent.java 文件源码 项目:NumberPadTimePicker 阅读 31 收藏 0 点赞 0 评论 0
@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.java 文件源码 项目:PreviewSeekBar 阅读 18 收藏 0 点赞 0 评论 0
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);
}
LoginActivity.java 文件源码 项目:LoginConcept 阅读 24 收藏 0 点赞 0 评论 0
@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);
                    });
                }
            });
}
VideoPlayerActivity.java 文件源码 项目:MyAnimeViewer 阅读 25 收藏 0 点赞 0 评论 0
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);
    }
}
EditorActivity.java 文件源码 项目:KernelAdiutor-Mod 阅读 37 收藏 0 点赞 0 评论 0
@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);
}
FeedbackBottomSheet.java 文件源码 项目:mapbox-navigation-android 阅读 20 收藏 0 点赞 0 评论 0
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);
  }
}
ThemedSeekBar.java 文件源码 项目:revolution-irc 阅读 27 收藏 0 点赞 0 评论 0
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()));
    }
}
ViewUtils.java 文件源码 项目:ListItemView 阅读 26 收藏 0 点赞 0 评论 0
public static void setIconColor(ImageView iconHolder, int color) {
    Drawable wrappedDrawable = DrawableCompat.wrap(iconHolder.getDrawable());
    DrawableCompat.setTint(wrappedDrawable, color);
    iconHolder.setImageDrawable(wrappedDrawable);
    iconHolder.invalidate();
}
AppSecurityPermissions.java 文件源码 项目:mobile-store 阅读 25 收藏 0 点赞 0 评论 0
@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;
}


问题


面经


文章

微信
公众号

扫码关注公众号