/** * {@inheritDoc} */ @Override public void setAlpha(int alpha) { if (mAlpha != alpha) { mAlpha = alpha; invalidateSelf(); } }
public void setStarCount(int count) { getTileDrawableByLayerId(android.R.id.background).setTileCount(count); getTileDrawableByLayerId(android.R.id.secondaryProgress).setTileCount(count); getTileDrawableByLayerId(android.R.id.progress).setTileCount(count); }
public void setTileCount(int tileCount) { mTileCount = tileCount; invalidateSelf(); }
private void applyProgressTints() { if (getProgressDrawable() == null) { return; } applyPrimaryProgressTint(); applyProgressBackgroundTint(); 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); } } }
private static Drawable createLayerDrawableWithTintColor(int tileRes, int tintColor, Context context) { TileDrawable drawable = new TileDrawable(AppCompatResources.getDrawable(context, tileRes)); drawable.mutate(); //noinspection RedundantCast ((TintableDrawable) drawable).setTint(tintColor); return drawable; }
@SuppressLint("RtlHardcoded") private static Drawable createClippedLayerDrawableWithTintColor(int tileResId, int tintColor, Context context) { return new ClipDrawableCompat(createLayerDrawableWithTintColor(tileResId, tintColor, context), Gravity.LEFT, ClipDrawableCompat.HORIZONTAL); }
@SuppressLint("RtlHardcoded") private static Drawable createClippedLayerDrawableWithTintAttrRes(int tileResId, int tintAttrRes, Context context) { return new ClipDrawableCompat(createLayerDrawableWithTintAttrRes(tileResId, tintAttrRes, context), Gravity.LEFT, ClipDrawableCompat.HORIZONTAL); }
/** * @deprecated Use {@link #setSupportProgressTintMode(PorterDuff.Mode)} instead. */ @Override public void setProgressTintMode(@Nullable PorterDuff.Mode tintMode) { logRatingBarTintWarning(); setSupportProgressTintMode(tintMode); }
/** * @deprecated Use {@link #getSupportIndeterminateTintMode()} instead. */ @Nullable @Override public PorterDuff.Mode getIndeterminateTintMode() { logRatingBarTintWarning(); return getSupportIndeterminateTintMode(); }
public float getTileRatio() { Drawable drawable = getTileDrawableByLayerId(android.R.id.progress).getDrawable(); return (float) drawable.getIntrinsicWidth() / drawable.getIntrinsicHeight(); }
/** * {@inheritDoc} */ @Override public void setTintList(@Nullable ColorStateList tint) { mTintList = tint; if (updateTintFilter()) { invalidateSelf(); } }
@Override public synchronized void setSecondaryProgress(int secondaryProgress) { super.setSecondaryProgress(secondaryProgress); // HACK: Check and call our listener here because this method is always called by // updateSecondaryProgress() from onProgressRefresh(). float rating = getRating(); if (mOnRatingChangeListener != null && rating != mLastKnownRating) { mOnRatingChangeListener.onRatingChanged(this, rating); } mLastKnownRating = rating; }
@SuppressLint("RtlHardcoded") private static Drawable createClippedTransparentLayerDrawable() { return new ClipDrawableCompat(new TileDrawable(new ColorDrawable(Color.TRANSPARENT)), Gravity.LEFT, ClipDrawableCompat.HORIZONTAL); }
public MaterialRatingBar(Context context) { super(context); init(null, 0); }
@Override protected boolean onStateChange(int[] state) { return updateTintFilter(); }
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); } } }
public MaterialRatingBar(Context context, AttributeSet attrs) { super(context, attrs); init(attrs, 0); }
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); } } }
public MaterialRatingBar(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(attrs, defStyleAttr); }