/** * @see RatingBar#setIndeterminateTintMode(PorterDuff.Mode) */ public void setSupportIndeterminateTintMode(@Nullable PorterDuff.Mode tintMode) { mProgressTintInfo.mIndeterminateTintMode = tintMode; mProgressTintInfo.mHasIndeterminateTintMode = true; applyIndeterminateTint(); }
private void applyProgressTints() { if (getProgressDrawable() == null) { return; } applyPrimaryProgressTint(); applyProgressBackgroundTint(); applySecondaryProgressTint(); }
private void applyPrimaryProgressTint() { if (getProgressDrawable() == null) { return; } if (mProgressTintInfo.mHasProgressTintList || mProgressTintInfo.mHasProgressTintMode) { Drawable target = getTintTargetFromProgressDrawable(android.R.id.progress, true); if (target != null) { applyTintForDrawable(target, mProgressTintInfo.mProgressTintList, mProgressTintInfo.mHasProgressTintList, mProgressTintInfo.mProgressTintMode, mProgressTintInfo.mHasProgressTintMode); } } }
private void applyIndeterminateTint() { Drawable indeterminateDrawable = getIndeterminateDrawable(); if (indeterminateDrawable == null) { return; } if (mProgressTintInfo.mHasIndeterminateTintList || mProgressTintInfo.mHasIndeterminateTintMode) { indeterminateDrawable.mutate(); applyTintForDrawable(indeterminateDrawable, mProgressTintInfo.mIndeterminateTintList, mProgressTintInfo.mHasIndeterminateTintList, mProgressTintInfo.mIndeterminateTintMode, mProgressTintInfo.mHasIndeterminateTintMode); } }
@SuppressWarnings("RestrictedApi") private void init(AttributeSet attrs, int defStyleAttr) { Context context = getContext(); TintTypedArray a = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.MaterialRatingBar, defStyleAttr, 0); R.styleable.MaterialRatingBar_mrb_fillBackgroundStars, isIndicator()); a.recycle(); mDrawable = new MaterialRatingDrawable(getContext(), fillBackgroundStars); mDrawable.setStarCount(getNumStars()); setProgressDrawable(mDrawable);
@Override protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); int height = getMeasuredHeight(); int width = Math.round(height * mDrawable.getTileRatio() * getNumStars()); setMeasuredDimension(View.resolveSizeAndState(width, widthMeasureSpec, 0), height); }
logDrawableTintWarning(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { drawable.setTintList(tintList); logDrawableTintWarning(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { drawable.setTintMode(tintMode); drawable.setState(getDrawableState());
/** * @see RatingBar#setProgressTintMode(PorterDuff.Mode) */ public void setSupportProgressTintMode(@Nullable PorterDuff.Mode tintMode) { mProgressTintInfo.mProgressTintMode = tintMode; mProgressTintInfo.mHasProgressTintMode = true; applyPrimaryProgressTint(); }
/** * @see RatingBar#setProgressBackgroundTintList(ColorStateList) */ public void setSupportProgressBackgroundTintList(@Nullable ColorStateList tint) { mProgressTintInfo.mProgressBackgroundTintList = tint; mProgressTintInfo.mHasProgressBackgroundTintList = true; applyProgressBackgroundTint(); }
/** * @see RatingBar#setSecondaryProgressTintMode(PorterDuff.Mode) */ public void setSupportSecondaryProgressTintMode(@Nullable PorterDuff.Mode tintMode) { mProgressTintInfo.mSecondaryProgressTintMode = tintMode; mProgressTintInfo.mHasSecondaryProgressTintMode = true; applySecondaryProgressTint(); }
@Override public void setProgressDrawable(Drawable d) { super.setProgressDrawable(d); // mProgressTintInfo can be null during super class initialization. if (mProgressTintInfo != null) { applyProgressTints(); } }
/** * @see RatingBar#setProgressTintList(ColorStateList) */ public void setSupportProgressTintList(@Nullable ColorStateList tint) { mProgressTintInfo.mProgressTintList = tint; mProgressTintInfo.mHasProgressTintList = true; applyPrimaryProgressTint(); }
/** * @see RatingBar#setProgressBackgroundTintMode(PorterDuff.Mode) */ public void setSupportProgressBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) { mProgressTintInfo.mProgressBackgroundTintMode = tintMode; mProgressTintInfo.mHasProgressBackgroundTintMode = true; applyProgressBackgroundTint(); }
/** * @see RatingBar#setSecondaryProgressTintList(ColorStateList) */ public void setSupportSecondaryProgressTintList(@Nullable ColorStateList tint) { mProgressTintInfo.mSecondaryProgressTintList = tint; mProgressTintInfo.mHasSecondaryProgressTintList = true; applySecondaryProgressTint(); }
private void applySecondaryProgressTint() { if (getProgressDrawable() == null) { return; } if (mProgressTintInfo.mHasSecondaryProgressTintList || mProgressTintInfo.mHasSecondaryProgressTintMode) { Drawable target = getTintTargetFromProgressDrawable(android.R.id.secondaryProgress, false); if (target != null) { applyTintForDrawable(target, mProgressTintInfo.mSecondaryProgressTintList, mProgressTintInfo.mHasSecondaryProgressTintList, mProgressTintInfo.mSecondaryProgressTintMode, mProgressTintInfo.mHasSecondaryProgressTintMode); } } }
/** * @see RatingBar#setIndeterminateTintList(ColorStateList) */ public void setSupportIndeterminateTintList(@Nullable ColorStateList tint) { mProgressTintInfo.mIndeterminateTintList = tint; mProgressTintInfo.mHasIndeterminateTintList = true; applyIndeterminateTint(); }
private void applyProgressBackgroundTint() { if (getProgressDrawable() == null) { return; } if (mProgressTintInfo.mHasProgressBackgroundTintList || mProgressTintInfo.mHasProgressBackgroundTintMode) { Drawable target = getTintTargetFromProgressDrawable(android.R.id.background, false); if (target != null) { applyTintForDrawable(target, mProgressTintInfo.mProgressBackgroundTintList, mProgressTintInfo.mHasProgressBackgroundTintList, mProgressTintInfo.mProgressBackgroundTintMode, mProgressTintInfo.mHasProgressBackgroundTintMode); } } }
@Override public void setIndeterminateDrawable(Drawable d) { super.setIndeterminateDrawable(d); // mProgressTintInfo can be null during super class initialization. if (mProgressTintInfo != null) { applyIndeterminateTint(); } }