@Nullable private Drawable getTintTargetFromProgressDrawable(int layerId, boolean shouldFallback) { Drawable progressDrawable = getProgressDrawable(); if (progressDrawable == null) { return null; } progressDrawable.mutate(); Drawable layerDrawable = null; if (progressDrawable instanceof LayerDrawable) { layerDrawable = ((LayerDrawable) progressDrawable).findDrawableByLayerId(layerId); } if (layerDrawable == null && shouldFallback) { layerDrawable = progressDrawable; } return layerDrawable; }
/** * Get the current drawable of this ProgressBar. * * @return The current drawable. */ @Nullable public Drawable getCurrentDrawable() { return isIndeterminate() ? getIndeterminateDrawable() : getProgressDrawable(); }
private void applyProgressBackgroundTint() { if (getProgressDrawable() == null) { return; } if (mProgressTintInfo.mHasProgressBackgroundTint || mProgressTintInfo.mHasProgressBackgroundTintMode) { Drawable target = getTintTargetFromProgressDrawable(android.R.id.background, false); if (target != null) { applyTintForDrawable(target, mProgressTintInfo.mProgressBackgroundTint, mProgressTintInfo.mHasProgressBackgroundTint, mProgressTintInfo.mProgressBackgroundTintMode, mProgressTintInfo.mHasProgressBackgroundTintMode); } } }
private void applyPrimaryProgressTint() { if (getProgressDrawable() == null) { return; } if (mProgressTintInfo.mHasProgressTint || mProgressTintInfo.mHasProgressTintMode) { Drawable target = getTintTargetFromProgressDrawable(android.R.id.progress, true); if (target != null) { applyTintForDrawable(target, mProgressTintInfo.mProgressTint, mProgressTintInfo.mHasProgressTint, mProgressTintInfo.mProgressTintMode, mProgressTintInfo.mHasProgressTintMode); } } }
private void applySecondaryProgressTint() { if (getProgressDrawable() == null) { return; } if (mProgressTintInfo.mHasSecondaryProgressTint || mProgressTintInfo.mHasSecondaryProgressTintMode) { Drawable target = getTintTargetFromProgressDrawable(android.R.id.secondaryProgress, false); if (target != null) { applyTintForDrawable(target, mProgressTintInfo.mSecondaryProgressTint, mProgressTintInfo.mHasSecondaryProgressTint, mProgressTintInfo.mSecondaryProgressTintMode, mProgressTintInfo.mHasSecondaryProgressTintMode); } } }
private void applyProgressTints() { if (getProgressDrawable() == null) { return; } applyPrimaryProgressTint(); applyProgressBackgroundTint(); applySecondaryProgressTint(); }