// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java
// public class SkinCompatResources {
//     private static volatile SkinCompatResources sInstance;
//     private final Context mAppContext;
//     private Resources mResources;
//     private String mSkinPkgName;
//     private boolean isDefaultSkin;
// 
//     private SkinCompatResources(Context context) {
//         mAppContext = context.getApplicationContext();
//         setSkinResource(mAppContext.getResources(), mAppContext.getPackageName());
//     }
// 
//     public static void init(Context context) {
//         if (sInstance == null) {
//             synchronized (SkinCompatResources.class) {
//                 if (sInstance == null) {
//                     sInstance = new SkinCompatResources(context);
//                 }
//             }
//         }
//     }
// 
//     public static SkinCompatResources getInstance() {
//         return sInstance;
//     }
// 
//     public void setSkinResource(Resources resources, String pkgName) {
//         mResources = resources;
//         mSkinPkgName = pkgName;
//         isDefaultSkin = mAppContext.getPackageName().equals(pkgName);
//     }
// 
//     public int getColor(int resId) {
//         int originColor = ContextCompat.getColor(mAppContext, resId);
//         if (isDefaultSkin) {
//             return originColor;
//         }
// 
//         String resName = mAppContext.getResources().getResourceEntryName(resId);
// 
//         int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName);
// 
//         return targetResId == 0 ? originColor : mResources.getColor(targetResId);
//     }
// 
//     public Drawable getDrawable(int resId) {
//         Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId);
//         if (isDefaultSkin) {
//             return originDrawable;
//         }
// 
//         String resName = mAppContext.getResources().getResourceEntryName(resId);
// 
//         int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName);
// 
//         return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId);
//     }
// 
//     public Drawable getMipmap(int resId) {
//         Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId);
//         if (isDefaultSkin) {
//             return originDrawable;
//         }
// 
//         String resName = mAppContext.getResources().getResourceEntryName(resId);
// 
//         int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName);
// 
//         return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId);
//     }
// 
//     public ColorStateList getColorStateList(int resId) {
//         ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId);
//         if (isDefaultSkin) {
//             return colorStateList;
//         }
// 
//         String resName = mAppContext.getResources().getResourceEntryName(resId);
// 
//         int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName);
// 
//         return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId);
//     }
// }
// 
// Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java
// public abstract class SkinCompatHelper {
//     protected static final String TAG = SkinCompatHelper.class.getSimpleName();
//     protected static final String SYSTEM_ID_PREFIX = "1";
//     public static final int INVALID_ID = -1;
// 
//     final static public int checkResourceId(int resId) {
//         String hexResId = Integer.toHexString(resId);
//         SkinLog.d(TAG, "hexResId = " + hexResId);
//         return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId;
//     }
// 
//     abstract public void applySkin();
// }
// 
// Path: skin-support/src/main/java/skin/support/widget/SkinCompatSupportable.java
// public interface SkinCompatSupportable {
//     void applySkin();
// }
// 
// Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java
// public static final int INVALID_ID = -1;


import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.design.widget.TabLayout;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.util.AttributeSet;
import skin.support.content.res.SkinCompatResources;
import skin.support.design.R;
import skin.support.widget.SkinCompatHelper;
import skin.support.widget.SkinCompatSupportable;
import static skin.support.widget.SkinCompatHelper.INVALID_ID;
        // Text colors/sizes come from the text appearance first
        final TypedArray ta = context.obtainStyledAttributes(tabTextAppearance, R.styleable.SkinTextAppearance);
        try {
            mTabTextColorsResId = ta.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
        } finally {
            ta.recycle();
        }

        if (a.hasValue(R.styleable.TabLayout_tabTextColor)) {
            // If we have an explicit text color set, use it instead
            mTabTextColorsResId = a.getResourceId(R.styleable.TabLayout_tabTextColor, INVALID_ID);
        }

        if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) {
            // We have an explicit selected text color set, so we need to make merge it with the
            // current colors. This is exposed so that developers can use theme attributes to set
            // this (theme attrs in ColorStateLists are Lollipop+)
            mTabSelectedTextColorResId = a.getResourceId(R.styleable.TabLayout_tabSelectedTextColor, INVALID_ID);
        }
        a.recycle();
        applySkin();
    }

    @Override
    public void applySkin() {
        int tabTextColor = INVALID_ID;
        mTabIndicatorColorResId = SkinCompatHelper.checkResourceId(mTabIndicatorColorResId);
        if (mTabIndicatorColorResId != INVALID_ID) {
            setSelectedTabIndicatorColor(SkinCompatResources.getInstance().getColor(mTabIndicatorColorResId));
        }
// Path: skin-support/src/main/java/skin/support/content/res/SkinCompatResources.java
// public class SkinCompatResources {
//     private static volatile SkinCompatResources sInstance;
//     private final Context mAppContext;
//     private Resources mResources;
//     private String mSkinPkgName;
//     private boolean isDefaultSkin;
// 
//     private SkinCompatResources(Context context) {
//         mAppContext = context.getApplicationContext();
//         setSkinResource(mAppContext.getResources(), mAppContext.getPackageName());
//     }
// 
//     public static void init(Context context) {
//         if (sInstance == null) {
//             synchronized (SkinCompatResources.class) {
//                 if (sInstance == null) {
//                     sInstance = new SkinCompatResources(context);
//                 }
//             }
//         }
//     }
// 
//     public static SkinCompatResources getInstance() {
//         return sInstance;
//     }
// 
//     public void setSkinResource(Resources resources, String pkgName) {
//         mResources = resources;
//         mSkinPkgName = pkgName;
//         isDefaultSkin = mAppContext.getPackageName().equals(pkgName);
//     }
// 
//     public int getColor(int resId) {
//         int originColor = ContextCompat.getColor(mAppContext, resId);
//         if (isDefaultSkin) {
//             return originColor;
//         }
// 
//         String resName = mAppContext.getResources().getResourceEntryName(resId);
// 
//         int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName);
// 
//         return targetResId == 0 ? originColor : mResources.getColor(targetResId);
//     }
// 
//     public Drawable getDrawable(int resId) {
//         Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId);
//         if (isDefaultSkin) {
//             return originDrawable;
//         }
// 
//         String resName = mAppContext.getResources().getResourceEntryName(resId);
// 
//         int targetResId = mResources.getIdentifier(resName, "drawable", mSkinPkgName);
// 
//         return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId);
//     }
// 
//     public Drawable getMipmap(int resId) {
//         Drawable originDrawable = ContextCompat.getDrawable(mAppContext, resId);
//         if (isDefaultSkin) {
//             return originDrawable;
//         }
// 
//         String resName = mAppContext.getResources().getResourceEntryName(resId);
// 
//         int targetResId = mResources.getIdentifier(resName, "mipmap", mSkinPkgName);
// 
//         return targetResId == 0 ? originDrawable : mResources.getDrawable(targetResId);
//     }
// 
//     public ColorStateList getColorStateList(int resId) {
//         ColorStateList colorStateList = ContextCompat.getColorStateList(mAppContext, resId);
//         if (isDefaultSkin) {
//             return colorStateList;
//         }
// 
//         String resName = mAppContext.getResources().getResourceEntryName(resId);
// 
//         int targetResId = mResources.getIdentifier(resName, "color", mSkinPkgName);
// 
//         return targetResId == 0 ? colorStateList : mResources.getColorStateList(targetResId);
//     }
// }
// 
// Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java
// public abstract class SkinCompatHelper {
//     protected static final String TAG = SkinCompatHelper.class.getSimpleName();
//     protected static final String SYSTEM_ID_PREFIX = "1";
//     public static final int INVALID_ID = -1;
// 
//     final static public int checkResourceId(int resId) {
//         String hexResId = Integer.toHexString(resId);
//         SkinLog.d(TAG, "hexResId = " + hexResId);
//         return hexResId.startsWith(SYSTEM_ID_PREFIX) ? INVALID_ID : resId;
//     }
// 
//     abstract public void applySkin();
// }
// 
// Path: skin-support/src/main/java/skin/support/widget/SkinCompatSupportable.java
// public interface SkinCompatSupportable {
//     void applySkin();
// }
// 
// Path: skin-support/src/main/java/skin/support/widget/SkinCompatHelper.java
// public static final int INVALID_ID = -1;


// Path: skin-support-design/src/main/java/skin/support/design/widget/SkinCompatTabLayout.java
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.design.widget.TabLayout;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.util.AttributeSet;
import skin.support.content.res.SkinCompatResources;
import skin.support.design.R;
import skin.support.widget.SkinCompatHelper;
import skin.support.widget.SkinCompatSupportable;
import static skin.support.widget.SkinCompatHelper.INVALID_ID;

        // Text colors/sizes come from the text appearance first
        final TypedArray ta = context.obtainStyledAttributes(tabTextAppearance, R.styleable.SkinTextAppearance);
        try {
            mTabTextColorsResId = ta.getResourceId(R.styleable.SkinTextAppearance_android_textColor, INVALID_ID);
        } finally {
            ta.recycle();
        }

        if (a.hasValue(R.styleable.TabLayout_tabTextColor)) {
            // If we have an explicit text color set, use it instead
            mTabTextColorsResId = a.getResourceId(R.styleable.TabLayout_tabTextColor, INVALID_ID);
        }

        if (a.hasValue(R.styleable.TabLayout_tabSelectedTextColor)) {
            // We have an explicit selected text color set, so we need to make merge it with the
            // current colors. This is exposed so that developers can use theme attributes to set
            // this (theme attrs in ColorStateLists are Lollipop+)
            mTabSelectedTextColorResId = a.getResourceId(R.styleable.TabLayout_tabSelectedTextColor, INVALID_ID);
        }
        a.recycle();
        applySkin();
    }

    @Override
    public void applySkin() {
        int tabTextColor = INVALID_ID;
        mTabIndicatorColorResId = SkinCompatHelper.checkResourceId(mTabIndicatorColorResId);
        if (mTabIndicatorColorResId != INVALID_ID) {
            setSelectedTabIndicatorColor(SkinCompatResources.getInstance().getColor(mTabIndicatorColorResId));
        }
        mTabTextColorsResId = SkinCompatHelper.checkResourceId(mTabTextColorsResId);