package skin.support.widget;
import android.content.Context;
import android.util.AttributeSet;
import com.zhy.autolayout.AutoLinearLayout;
import skin.support.widget.SkinCompatBackgroundHelper;
import skin.support.widget.SkinCompatSupportable;
/**
* Created by pengfengwang on 2017/3/15.
*/
public class SkinAutoLinearLayout extends AutoLinearLayout implements SkinCompatSupportable {
private SkinCompatBackgroundHelper mBackgroundTintHelper;
public SkinAutoLinearLayout(Context context) {
this(context, null);
}
public SkinAutoLinearLayout(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public SkinAutoLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
}
public SkinAutoLinearLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
mBackgroundTintHelper = new SkinCompatBackgroundHelper(this);
mBackgroundTintHelper.loadFromAttributes(attrs, defStyleAttr);
}
@Override
public void setBackgroundResource(int resid) {
super.setBackgroundResource(resid);
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.applySkin();
}
}
@Override
public void applySkin() {
if (mBackgroundTintHelper != null) {
mBackgroundTintHelper.applySkin();
}
}
}