Java 类android.content.res.ColorStateList 实例源码

项目:BilibiliClient    文件:BangumiScheduleSection.java   
private void setWeekDayIconAndTitle(HeaderViewHolder viewHolder, int iconRes, String title) {
    if (mDate.equals(WeekDayUtil.formatDate(DateUtil.getCurrentTime("yyyy-MM-dd")))){
        viewHolder.mUpdateTime.setText("今天");
        viewHolder.mUpdateTime.setTextColor(mContext.getResources().getColor(R.color.colorPrimary));
        viewHolder.mWeekDayText.setTextColor(mContext.getResources().getColor(R.color.colorPrimary));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            viewHolder.mWeekDayIcon.setImageTintList(ColorStateList.valueOf(mContext.getResources().getColor(R.color.colorPrimary)));
        }
    } else {
        viewHolder.mUpdateTime.setText(mDate);
        viewHolder.mUpdateTime.setTextColor(mContext.getResources().getColor(R.color.black_alpha_30));
        viewHolder.mWeekDayText.setTextColor(mContext.getResources().getColor(R.color.gray_80));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            viewHolder.mWeekDayIcon.setImageTintList(ColorStateList.valueOf(mContext.getResources().getColor(R.color.gray_80)));
        }
    }
    viewHolder.mWeekDayIcon.setImageResource(iconRes);
    viewHolder.mWeekDayText.setText(title);
}
项目:MusicX-music-player    文件:Playing4Fragment.java   
private void colorMode(int color) {
    if (getActivity() == null || getActivity().getWindow() == null) {
        return;
    }
    if (Extras.getInstance().getDarkTheme() || Extras.getInstance().getBlackTheme()) {
        getActivity().getWindow().setNavigationBarColor(color);
        getActivity().getWindow().setStatusBarColor(color);
        seekbar.setBackgroundTintList(ColorStateList.valueOf(color));
        if (vizualview != null) {
            vizualview.setmCakeColor(color);
        }
        playpausebutton.setBackgroundTintList(ColorStateList.valueOf(color));
        queueClick.setBackgroundTintList(ColorStateList.valueOf(color));
    } else {
        getActivity().getWindow().setNavigationBarColor(color);
        seekbar.setBackgroundTintList(ColorStateList.valueOf(color));
        getActivity().getWindow().setStatusBarColor(color);
        if (vizualview != null) {
            vizualview.setmCakeColor(color);
        }
        playpausebutton.setBackgroundTintList(ColorStateList.valueOf(color));
        queueClick.setBackgroundTintList(ColorStateList.valueOf(color));
    }

}
项目:atlas    文件:DelegateResources.java   
public static void walkroundActionMenuTextColor(Resources res){
    try {
        if (Build.VERSION.SDK_INT>=16 && Build.VERSION.SDK_INT <= 19) {
            final long key = (((long) -1) << 32) | 0x7f010082;
            if(walkroundStateList==null) {
                walkroundStateList = ColorStateList.valueOf(Color.rgb(0, 0, 0));
            }
            Field mColorStateListCacheField = AndroidHack.findField(res, "mColorStateListCache");
            mColorStateListCacheField.setAccessible(true);
            LongSparseArray mColorStateListCache = (LongSparseArray) mColorStateListCacheField.get(res);
            mColorStateListCache.put(key,new WeakReference<>(walkroundStateList));
        }
    }catch(Throwable e){
        e.printStackTrace();
    }
}
项目:Depth    文件:RippleHelper.java   
public static ColorStateList getPressedColorSelector(int normalColor, int pressedColor)
{
    return new ColorStateList(
            new int[][]
                    {
                            new int[]{android.R.attr.state_pressed},
                            new int[]{android.R.attr.state_focused},
                            new int[]{android.R.attr.state_activated},
                            new int[]{}
                    },
            new int[]
                    {
                            pressedColor,
                            pressedColor,
                            pressedColor,
                            normalColor
                    }
    );
}
项目:BilibiliClient    文件:VideoDetailsActivity.java   
@Override
public void finishTask() {
    mFAB.setClickable(true);
    mFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.colorPrimary)));
    mCollapsingToolbarLayout.setTitle("");
    if (TextUtils.isEmpty(mImgUrl)){
        Glide.with(this)
                .load(mVideoDetailsInfo)
                .centerCrop()
                .diskCacheStrategy(DiskCacheStrategy.ALL)
                .placeholder(R.drawable.bili_default_image_tv)
                .dontAnimate()
                .into(mVideoPreview);
    }
    VideoIntroductionFragment introductionFragment = VideoIntroductionFragment.newInstance(mAv);
    VideoCommentFragment commentFragment = VideoCommentFragment.newInstance(mAv);
    fragments.add(introductionFragment);
    fragments.add(commentFragment);
    setPagerTitle(String.valueOf(mVideoDetailsInfo.getStat().getReply()));
}
项目:letv    文件:LoadingLayout.java   
private void setTextColor(ColorStateList color) {
    if (this.mHeaderText != null) {
        this.mHeaderText.setTextColor(color);
    }
    if (this.mSubHeaderText != null) {
        this.mSubHeaderText.setTextColor(color);
    }
}
项目:android_ui    文件:TintManager.java   
/**
 * Creates a new instance of ColorStateList as tint list for background of Button widget.
 *
 * @param context   Context used to resolve theme attributes that can be used to create the
 *                  requested tint list.
 * @param tintColor Color to be used as primary tint (accent) color.
 * @return New instance of ColorStateList specific for background of Button widget.
 */
@Nullable
static ColorStateList createButtonBackgroundTintColors(@NonNull Context context, int tintColor) {
    final int colorPressed = Colors.darker(tintColor, 0.1f);
    return tintColor != Color.TRANSPARENT ? new ColorStateList(
            new int[][]{
                    // Enabled states ----------------------------------------------------------
                    WidgetStateSet.ENABLED_PRESSED,
                    WidgetStateSet.ENABLED_FOCUSED,
                    WidgetStateSet.ENABLED,
                    // Disabled states ---------------------------------------------------------
                    WidgetStateSet.DISABLED
            },
            new int[]{
                    // Enabled state colors ----------------------------------------------------
                    colorPressed,
                    colorPressed,
                    tintColor,
                    // Disabled state colors ---------------------------------------------------
                    COLOR_DISABLED_BUTTON
            }
    ) : null;
}
项目:MusicX-music-player    文件:TintHelper.java   
public static void setTint(@NonNull SeekBar seekBar, @ColorInt int color, boolean useDarker) {
    final ColorStateList s1 = getDisabledColorStateList(color,
            ContextCompat.getColor(seekBar.getContext(), useDarker ? R.color.ate_control_disabled_dark : R.color.ate_control_disabled_light));
    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 = createTintedDrawable(seekBar.getProgressDrawable(), s1);
        seekBar.setProgressDrawable(progressDrawable);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            Drawable thumbDrawable = createTintedDrawable(seekBar.getThumb(), 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);
    }
}
项目:AndelaTrackChallenge    文件:Easel.java   
/**
 * Tint the {@link SeekBar}
 *
 * @param seekBar the seekbar
 * @param color   the color
 */
public static void tint(@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);
    }
}
项目:Edu    文件:TimerView.java   
public void startTimer(){
    if(!isBegin){
        isBegin = true;
        timerview.setBackground(getResources().getDrawable(R.drawable.shape_bo_grey_cccccc_r4dp));
        timerview.setTextColor(ColorStateList.valueOf(ContextCompat.getColor(getContext(),R.color.grey_cccccc)));
        new CountDownTimer(60000, 1000) {
            @Override
            public void onTick(long millisUntilFinished) {
                timerview.setText(millisUntilFinished/1000 + "s");
            }

            @Override
            public void onFinish() {
                timerview.setBackground(getResources().getDrawable(R.drawable.shape_bo_white_r4dp));
                timerview.setTextColor(ColorStateList.valueOf(ContextCompat.getColor(getContext(),R.color.white)));
                timerview.setText("获取验证码");
                isBegin = false;
            }
        }.start();
    }
}
项目:NumberPadTimePicker    文件:NumberPadTimePickerBottomSheetComponent.java   
@NonNull
private static int[] extractColors(ColorStateList colorStateList, int[][] states) {
    int[] colors = new int[states.length];
    int idx = 0;
    for (int[] stateSet : states) {
        // The empty state is peculiar in that getColorForState() will not return
        // the default color, but rather any color defined in the ColorStateList
        // for any state.
        // https://developer.android.com/reference/android/content/res/ColorStateList.html
        // "Each item defines a set of state spec and color pairs, where the state
        // spec is a series of attributes set to either true or false to represent
        // inclusion or exclusion. If an attribute is not specified for an item,
        // it may be any value."
        // "An item with no state spec is considered to match any set of states
        // and is generally useful as a final item to be used as a default."
        colors[idx++] = stateSet.length == 0 ? colorStateList.getDefaultColor()
                : colorStateList.getColorForState(stateSet, 0);
    }
    return colors;
}
项目:Recognize-it    文件:GalleryAlbumActivity.java   
/**
 * Initialize widget.
 */
private void initializeWidget() {
    int navigationColor = mWidget.getNavigationBarColor();
    navigationColor = AlbumUtils.getAlphaColor(navigationColor, mNavigationAlpha);
    StatusUtils.setFullToNavigationBar(this);
    StatusUtils.setNavigationBarColor(this, navigationColor);

    setTitle(mWidget.getTitle());

    if (!mCheckable) {
        findViewById(R.id.bottom_root).setVisibility(View.GONE);
    } else {
        ColorStateList itemSelector = mWidget.getMediaItemCheckSelector();
        mCheckBox.setSupportButtonTintList(itemSelector);

        mCheckBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean isChecked = mCheckBox.isChecked();
                mCheckedMap.put(mAlbumFiles.get(mCurrentItemPosition), isChecked);
                setCheckedCountUI(getCheckCount());
            }
        });
    }
}
项目:MusicX-music-player    文件:TintHelper.java   
@CheckResult
@Nullable
public static Drawable createTintedDrawable(@Nullable Drawable drawable, @NonNull ColorStateList sl) {
    if (drawable == null) return null;
    drawable = DrawableCompat.wrap(drawable.mutate());
    DrawableCompat.setTintList(drawable, sl);
    return drawable;
}
项目:android_ui    文件:ProgressBarWidget.java   
/**
 * Applies current first valid tint from {@link Decorator#mTintInfo} to the progress drawable as
 * whole.
 *
 * @see #applyProgressTints()
 */
private void applySimpleProgressTint() {
    if (mProgressDrawable instanceof TintDrawable) {
        final ProgressTintInfo tintInfo = mDecorator.getTintInfo();
        final TintDrawable tintDrawable = (TintDrawable) mProgressDrawable;
        boolean hasTintList, hasTintMode;
        hasTintList = hasTintMode = false;
        ColorStateList tintList = null;
        PorterDuff.Mode tintMode = null;
        if (tintInfo.hasTintList || tintInfo.hasTintMode) {
            hasTintList = tintInfo.hasTintList;
            tintList = tintInfo.tintList;
            hasTintMode = tintInfo.hasTintMode;
            tintMode = tintInfo.tintMode;
        } else if (tintInfo.hasSecondaryProgressTintList || tintInfo.hasSecondaryProgressTintMode) {
            hasTintList = tintInfo.hasSecondaryProgressTintList;
            tintList = tintInfo.secondaryProgressTintList;
            hasTintMode = tintInfo.hasSecondaryProgressTintMode;
            tintMode = tintInfo.secondaryProgressTintMode;
        } else if (tintInfo.hasProgressBackgroundTintList || tintInfo.hasProgressBackgroundTintMode) {
            hasTintList = tintInfo.hasProgressBackgroundTintList;
            tintList = tintInfo.progressBackgroundTintList;
            hasTintMode = tintInfo.hasProgressBackgroundTintMode;
            tintMode = tintInfo.progressBackgroundTintMode;
        }
        if (hasTintList) tintDrawable.setTintList(tintList);
        if (hasTintMode) tintDrawable.setTintMode(tintMode);
        if (mProgressDrawable.isStateful()) {
            mProgressDrawable.setState(getDrawableState());
        }
    }
}
项目:android_ui    文件:GridViewWidget.java   
/**
 */
@Nullable
@Override
public ColorStateList getBackgroundTintList() {
    this.ensureDecorator();
    return mDecorator.getBackgroundTintList();
}
项目:qmui    文件:QMUILinkify.java   
/**
 * Scans the text of the provided TextView and turns all occurrences of
 * the link types indicated in the mask into clickable links.  If matches
 * are found the movement method for the TextView is set to
 * LinkMovementMethod.
 */
public static final boolean addLinks(TextView text, int mask, ColorStateList linkColor, ColorStateList bgColor, QMUIOnSpanClickListener l) {
    if (mask == 0) {
        return false;
    }

    CharSequence t = text.getText();

    if (t instanceof Spannable) {
        if (addLinks((Spannable) t, mask, linkColor, bgColor, l)) {
            addLinkMovementMethod(text);
            return true;
        }

        return false;
    } else {
        SpannableString s = SpannableString.valueOf(t);

        if (addLinks(s, mask, linkColor, bgColor, l)) {
            addLinkMovementMethod(text);
            text.setText(s);

            return true;
        }

        return false;
    }
}
项目:AvatarView    文件:RoundedImageView.java   
public RoundedImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RoundedImageView, defStyle, 0);

    int index = a.getInt(R.styleable.RoundedImageView_android_scaleType, -1);
    if (index >= 0) {
        setScaleType(SCALE_TYPES[index]);
    } else {
        // default scaletype to FIT_CENTER
        setScaleType(ScaleType.FIT_CENTER);
    }

    cornerRadius = a.getDimensionPixelSize(R.styleable.RoundedImageView_rcorner_radius, -1);
    borderWidth = a.getDimensionPixelSize(R.styleable.RoundedImageView_rborder_width, -1);

    // don't allow negative values for radius and border
    if (cornerRadius < 0) {
        cornerRadius = DEFAULT_RADIUS;
    }
    if (borderWidth < 0) {
        borderWidth = DEFAULT_BORDER_WIDTH;
    }

    borderColor = a.getColorStateList(R.styleable.RoundedImageView_rborder_color);
    if (borderColor == null) {
        borderColor = ColorStateList.valueOf(RoundedDrawable.DEFAULT_BORDER_COLOR);
    }

    mutateBackground = a.getBoolean(R.styleable.RoundedImageView_rmutate_background, false);
    isOval = a.getBoolean(R.styleable.RoundedImageView_roval, false);

    updateDrawableAttrs();
    updateBackgroundDrawableAttrs(true);

    a.recycle();
}
项目:ReadMark    文件:SkinResource.java   
/**
 * 获取颜色
 * @param resName
 * @return
 */
public ColorStateList getColorByName(String resName){
    try{
        int resId = mSkinResources.getIdentifier(resName, "color", mPackageName);
        ColorStateList color = mSkinResources.getColorStateList(resId);
        return color;

    }catch (Exception e){
        e.printStackTrace();
        return null;
    }
}
项目:android_ui    文件:TextViewDecorator.java   
/**
 * Applies a tint to the compound drawables. Does not modify the current tint mode, which is
 * {@link PorterDuff.Mode#SRC_IN} by default.
 *
 * @param tint The desired tint to be applied. May be {@code null} to clear the current tint.
 */
public void setCompoundDrawableTintList(ColorStateList tint) {
    if (UiConfig.MATERIALIZED_MARSHMALLOW) {
        superSetCompoundDrawableTintList(tint);
        return;
    }
    final CompoundTintInfo tintInfo = getTintInfo();
    if (!tintInfo.hasCompoundTintMode) {
        tintInfo.compoundTintMode = PorterDuff.Mode.SRC_IN;
    }
    tintInfo.compoundTintList = tint;
    tintInfo.hasCompoundTintList = true;
    this.applyCompoundDrawablesTint();
}
项目:BilibiliClient    文件:VideoDetailsActivity.java   
@Override
public void loadData() {
    RetrofitHelper.getBiliAppAPI()
            .getVideoDetails(mAv)
            .compose(bindToLifecycle())
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe(videoDetailsInfo -> {
                mVideoDetailsInfo = videoDetailsInfo.getData();
                finishTask();
            }, throwable -> {
                mFAB.setClickable(false);
                mFAB.setBackgroundTintList(ColorStateList.valueOf(getResources().getColor(R.color.gray_20)));
            });
}
项目:NeoTerm    文件:PhoneRecyclerAdapter.java   
@Override
public final void onTabBackgroundColorChanged(@Nullable final ColorStateList colorStateList) {
    TabItemIterator iterator = new TabItemIterator.Builder(model, viewRecycler).create();
    TabItem tabItem;

    while ((tabItem = iterator.next()) != null) {
        if (tabItem.isInflated()) {
            adaptBackgroundColor(tabItem.getView(), tabItem.getViewHolder(), tabItem.getTab());
        }
    }
}
项目:Recognize-it    文件:Widget.java   
protected Widget(Parcel in) {
    //noinspection WrongConstant
    mStyle = in.readInt();
    mStatusBarColor = in.readInt();
    mToolBarColor = in.readInt();
    mNavigationBarColor = in.readInt();
    mTitle = in.readString();
    mMediaItemCheckSelector = in.readParcelable(ColorStateList.class.getClassLoader());
    mBucketItemCheckSelector = in.readParcelable(ColorStateList.class.getClassLoader());
    mButtonStyle = in.readParcelable(ButtonStyle.class.getClassLoader());
}
项目:sao    文件:CoolView.java   
private int[] getColorsFromColorStateList(ColorStateList colorStateList) {
    if (colorStateList == null) {
        return colors;
    }
    try {
        return (int[]) ColorStateList.class.getMethod("getColors").invoke(colorStateList);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return colors;
}
项目:SingleSelectBar    文件:ResHelper.java   
private void updateTextColor() {
    int[] colors = new int[] {colorUnselected, colorSelected};
    int[][] states = new int[2][];
    states[0] = new int[] {android.R.attr.state_selected};
    states[1] = new int[] {};
    textColor = new ColorStateList(states, colors);
}
项目:LiteReader    文件:DoubanMovieMoreReviewViewModel.java   
@Override
public void initTab(TabLayout tabLayout) {
    tabLayout.setTabMode(TabLayout.MODE_FIXED);
    tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
    tabLayout.setBackgroundColor(getContext().getResources().getColor(R.color.colorPrimary));
    tabLayout.setSelectedTabIndicatorColor(Color.WHITE);
    tabLayout.setTabTextColors(ColorStateList.valueOf(Color.WHITE));
}
项目:Android-skin-support    文件:SkinCompatDrawableManager.java   
private static PorterDuffColorFilter createTintFilter(ColorStateList tint,
                                                      PorterDuff.Mode tintMode, final int[] state) {
    if (tint == null || tintMode == null) {
        return null;
    }
    final int color = tint.getColorForState(state, Color.TRANSPARENT);
    return getPorterDuffColorFilter(color, tintMode);
}
项目:android_ui    文件:TextAppearance.java   
/**
 * Sets a stateful set of colors for text.
 *
 * @param colors The desired colors. May be {@code null} to clear the current ones.
 * @return {@code True} if colors of this text appearance have changed, {@code false} otherwise.
 * @see #getTextColor()
 */
public boolean setTextColor(@Nullable ColorStateList colors) {
    if (mTextColors != colors) {
        this.mTextColors = colors;
        return true;
    }
    return false;
}
项目:revolution-irc    文件:ThemedSeekBar.java   
private static ColorStateList createSeekBarThumbColorList(Context ctx) {
    int accentColor = ThemeHelper.getAccentColor(ctx);
    int normalColor = StyledAttributesHelper.getColor(ctx, R.attr.colorControlNormal, 0);
    int disabledColor = ColorUtils.setAlphaComponent(normalColor, (int) (255.f *
            StyledAttributesHelper.getFloat(ctx, android.R.attr.disabledAlpha, 1.f)));
    return new ColorStateList(new int[][] {
            new int[] { -android.R.attr.state_enabled },
            new int[] { }
    }, new int[] {
            disabledColor,
            accentColor
    });
}
项目:Aequorea    文件:SettingsActivity.java   
private void colorCheckBox() {
    int titleColor = ThemeHelper.getResourceColor(this, R.attr.title_color);
    int accentColor = ThemeHelper.getResourceId(this, R.attr.colorAccent);
    int subTitleColor = ThemeHelper.getResourceColor(this, R.attr.subtitle_color);

    ColorStateList stateList = new ColorStateList(new int[][]{{ -android.R.attr.state_checked }, { android.R.attr.state_checked }},
        new int[]{0x8A000000, ContextCompat.getColor(this, accentColor)});

    for (ACheckBox cb : mList) {
        cb.setColorStateList(stateList);
        cb.setTextColor(titleColor, subTitleColor);
    }
}
项目:boohee_v5.6    文件:AppCompatDrawableManager.java   
private ColorStateList getTintListFromCache(@NonNull Context context, @DrawableRes int resId) {
    if (this.mTintLists == null) {
        return null;
    }
    SparseArray<ColorStateList> tints = (SparseArray) this.mTintLists.get(context);
    if (tints != null) {
        return (ColorStateList) tints.get(resId);
    }
    return null;
}
项目:MakiLite    文件:SnackBar.java   
/**
 * Sets the text color of the action specified in
 * {@link #setAction(CharSequence, View.OnClickListener)}.
 */
@NonNull
public SnackBar setActionTextColor(ColorStateList colors) {
    this.snackbar.setActionTextColor(colors);

    return this;
}
项目:SetupWizardLibCompat    文件:GlifLayout.java   
private void setProgressBarColor(ColorStateList color) {
    if (Build.VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
        final ProgressBar bar = peekProgressBar();
        if (bar != null) {
            bar.setIndeterminateTintList(color);
        }
    }
}
项目:Android-skin-support    文件:SkinMaterialTextInputLayout.java   
private void setDefaultTextColor(ColorStateList colors) {
    try {
        Field defaultTextColor = TextInputLayout.class.getDeclaredField("mDefaultTextColor");
        defaultTextColor.setAccessible(true);
        defaultTextColor.set(this, colors);
        updateLabelState();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:SkinFramework    文件:ComposedResources.java   
@RequiresApi(api = Build.VERSION_CODES.M)
@Nullable
@Override
public ColorStateList getColorStateList(@ColorRes int id, @Nullable Theme theme) throws NotFoundException {
    int realId = getCorrespondResId(id);
    if (realId > 0) {
        return mSkinResources.getColorStateList(realId, theme);
    }
    return super.getColorStateList(id, theme);
}
项目:LaunchEnr    文件:NotificationMainView.java   
@Override
protected void onFinishInflate() {
    super.onFinishInflate();

    mTextAndBackground = (ViewGroup) findViewById(R.id.text_and_background);
    ColorDrawable colorBackground = (ColorDrawable) mTextAndBackground.getBackground();
    mBackgroundColor = colorBackground.getColor();
    RippleDrawable rippleBackground = new RippleDrawable(ColorStateList.valueOf(
            ThemeUtils.getAttrColor(getContext(), android.R.attr.colorControlHighlight)),
            colorBackground, null);
    mTextAndBackground.setBackground(rippleBackground);
    mTitleView = (TextView) mTextAndBackground.findViewById(R.id.title);
    mTextView = (TextView) mTextAndBackground.findViewById(R.id.text);
}
项目:FastLib    文件:FastLoadMoreView.java   
private void initView(BaseViewHolder holder) {
    if (holder == null) {
        return;
    }

    holder.setText(R.id.tv_loadingFastLoadMore, mLoadingText)
            .setTextColor(R.id.tv_loadingFastLoadMore, mLoadingTextColor)
            .setText(R.id.tv_loadFailFastLoadMore, mLoadFailText)
            .setTextColor(R.id.tv_loadFailFastLoadMore, mLoadFailTextColor)
            .setText(R.id.tv_loadEndFastLoadMore, mLoadEndText)
            .setTextColor(R.id.tv_loadEndFastLoadMore, mLoadEndTextColor);
    TextView tvLoading = holder.getView(R.id.tv_loadingFastLoadMore);
    TextView tvLoadFail = holder.getView(R.id.tv_loadFailFastLoadMore);
    TextView tvLoadEnd = holder.getView(R.id.tv_loadEndFastLoadMore);
    ProgressBar pbLoading = holder.getView(R.id.pb_loadingFastLoadMore);
    tvLoading.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLoadingTextSize);
    tvLoading.getPaint().setFakeBoldText(mLoadingTextFakeBold);
    tvLoadFail.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLoadFailTextSize);
    tvLoadFail.getPaint().setFakeBoldText(mLoadFailTextFakeBold);
    tvLoadEnd.setTextSize(TypedValue.COMPLEX_UNIT_PX, mLoadEndTextSize);
    tvLoadEnd.getPaint().setFakeBoldText(mLoadEndTextFakeBold);
    if (mLoadingSize >= 0) {
        pbLoading.getIndeterminateDrawable().setBounds(0, 0, mLoadingSize, mLoadingSize);
        ViewGroup.LayoutParams params = pbLoading.getLayoutParams();
        params.width = mLoadingSize;
        params.height = mLoadingSize;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        pbLoading.setIndeterminateTintList(ColorStateList.valueOf(mLoadingProgressColor));
    }
    if (mLoadingProgressDrawable != null) {
        mLoadingProgressDrawable.setBounds(pbLoading.getIndeterminateDrawable().getBounds());
        pbLoading.setIndeterminateDrawable(mLoadingProgressDrawable);
    }
}
项目:android_ui    文件:SeekBarWidget.java   
/**
 * Applies current first valid tint from {@link Decorator#mTintInfo} to the progress drawable as
 * whole.
 *
 * @see #applyProgressTints()
 */
private void applySimpleProgressTint() {
    if (mProgressDrawable instanceof TintDrawable) {
        final SeekBarTintInfo tintInfo = mDecorator.getTintInfo();
        final TintDrawable tintDrawable = (TintDrawable) mProgressDrawable;
        boolean hasTintList, hasTintMode;
        hasTintList = hasTintMode = false;
        ColorStateList tintList = null;
        PorterDuff.Mode tintMode = null;
        if (tintInfo.hasPrimaryProgressTintList || tintInfo.hasPrimaryProgressTintMode) {
            hasTintList = tintInfo.hasPrimaryProgressTintList;
            tintList = tintInfo.primaryProgressTintList;
            hasTintMode = tintInfo.hasPrimaryProgressTintMode;
            tintMode = tintInfo.primaryProgressTintMode;
        } else if (tintInfo.hasSecondaryProgressTintList || tintInfo.hasSecondaryProgressTintMode) {
            hasTintList = tintInfo.hasSecondaryProgressTintList;
            tintList = tintInfo.secondaryProgressTintList;
            hasTintMode = tintInfo.hasSecondaryProgressTintMode;
            tintMode = tintInfo.secondaryProgressTintMode;
        } else if (tintInfo.hasProgressBackgroundTintList || tintInfo.hasProgressBackgroundTintMode) {
            hasTintList = tintInfo.hasProgressBackgroundTintList;
            tintList = tintInfo.progressBackgroundTintList;
            hasTintMode = tintInfo.hasProgressBackgroundTintMode;
            tintMode = tintInfo.progressBackgroundTintMode;
        }
        if (hasTintList) tintDrawable.setTintList(tintList);
        if (hasTintMode) tintDrawable.setTintMode(tintMode);
        if (mProgressDrawable.isStateful()) {
            mProgressDrawable.setState(getDrawableState());
        }
    }
}
项目:android-project-gallery    文件:RoundedImageView.java   
public void setBorderColor(ColorStateList colors)
{
    if (borderColor.equals(colors))
    {
        return;
    }

    borderColor = (colors != null) ? colors : ColorStateList.valueOf(RoundedDrawable.DEFAULT_BORDER_COLOR);
    updateDrawableAttrs();
    updateBackgroundDrawableAttrs(false);
    if (borderWidth > 0)
    {
        invalidate();
    }
}
项目:android_ui    文件:ImageDecorator.java   
/**
 * Returns the tint applied to the image drawable.
 *
 * @return Image drawable's tint or {@code null} if no tint is applied.
 */
ColorStateList getImageTintList() {
    if (UiConfig.MATERIALIZED) {
        return superGetImageTintList();
    }
    return mTintInfo != null ? mTintInfo.tintList : null;
}
项目:UIWidget    文件:TitleBarView.java   
/**
 * 设置文字状态颜色-如按下颜色变化
 *
 * @param color
 * @return
 */
public TitleBarView setLeftTextColor(ColorStateList color) {
    try {
        mLeftTv.setTextColor(color);
    } catch (Exception e) {
    }
    return this;
}