Source code
package android.support.v7.widget;
import android.content.Context;
import android.support.annotation.DrawableRes;
import android.support.v7.internal.widget.TintManager;
import android.support.v7.internal.widget.TintTypedArray;
import android.util.AttributeSet;
import android.widget.CheckedTextView;
public class AppCompatCheckedTextView extends CheckedTextView {
private static final int[] TINT_ATTRS = new int[]{16843016};
private AppCompatTextHelper mTextHelper;
private TintManager mTintManager;
public AppCompatCheckedTextView(Context context) {
this(context, null);
}
public AppCompatCheckedTextView(Context context, AttributeSet attrs) {
this(context, attrs, 16843720);
}
public AppCompatCheckedTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
this.mTextHelper = AppCompatTextHelper.create(this);
this.mTextHelper.loadFromAttributes(attrs, defStyleAttr);
this.mTextHelper.applyCompoundDrawablesTints();
if (TintManager.SHOULD_BE_USED) {
TintTypedArray a = TintTypedArray.obtainStyledAttributes(getContext(), attrs, TINT_ATTRS, defStyleAttr, 0);
setCheckMarkDrawable(a.getDrawable(0));
a.recycle();
this.mTintManager = a.getTintManager();
}
}
public void setCheckMarkDrawable(@DrawableRes int resId) {
if (this.mTintManager != null) {
setCheckMarkDrawable(this.mTintManager.getDrawable(resId));
} else {
super.setCheckMarkDrawable(resId);
}
}
public void setTextAppearance(Context context, int resId) {
super.setTextAppearance(context, resId);
if (this.mTextHelper != null) {
this.mTextHelper.onSetTextAppearance(context, resId);
}
}
protected void drawableStateChanged() {
super.drawableStateChanged();
if (this.mTextHelper != null) {
this.mTextHelper.applyCompoundDrawablesTints();
}
}
}