/***
* Enables or disables the whole seekBar!
*
* @param enabled
*/
@Override
public void setEnabled(final boolean enabled) {
mIsEnabled = enabled;
triggerMethodOnceViewIsDisplayed(this, new Callable<Void>() {
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public Void call() throws Exception {
if (!lollipopAndAbove()) {
gradientDrawable = new GradientDrawable();
gradientDrawable.setShape(GradientDrawable.OVAL);
gradientDrawable.setSize(mOriginalThumbHeight / 3, mOriginalThumbHeight / 3);
gradientDrawable.setColor(mIsEnabled ? mThumbColor : Color.LTGRAY);
gradientDrawable.setDither(true);
gradientDrawable.setAlpha(mThumbAlpha);
setThumb(gradientDrawable);
//load up the drawable and apply color
LayerDrawable ld = (LayerDrawable) getProgressDrawable();
ScaleDrawable shape = (ScaleDrawable) (ld.findDrawableByLayerId(android.R.id.progress));
shape.setColorFilter(mIsEnabled ? mProgressColor : Color.LTGRAY, PorterDuff.Mode.SRC_IN);
//set the background to transparent
NinePatchDrawable ninePatchDrawable = (NinePatchDrawable) (ld.findDrawableByLayerId(android.R.id.background));
ninePatchDrawable.setColorFilter(Color.TRANSPARENT, PorterDuff.Mode.SRC_IN);
//background
//load up the drawable and apply color
SeekBarBackgroundDrawable seekBarBackgroundDrawable = new SeekBarBackgroundDrawable(getContext(),
mIsEnabled ? mProgressBackgroundColor : Color.LTGRAY, mActualBackgroundColor, getPaddingLeft(), getPaddingRight());
if (belowJellybean())
setBackgroundDrawable(seekBarBackgroundDrawable);
else
setBackground(seekBarBackgroundDrawable);
}
SeekBarCompat.super.setEnabled(enabled);
return null;
}
});
}
SeekBarCompat.java 文件源码
java
阅读 17
收藏 0
点赞 0
评论 0
项目:crofis-android-uikit
作者:
评论列表
文章目录