List of usage examples for android.util StateSet stateSetMatches
public static boolean stateSetMatches(int[] stateSpec, int state)
From source file:com.bilibili.magicasakura.utils.ThemeUtils.java
public static ColorStateList getThemeColorStateList(Context context, ColorStateList origin) { if (origin == null) return null; if (origin.isStateful()) { TintInfo tintInfo = parseColorStateList(origin); if (tintInfo == null || tintInfo.isInvalid()) { return origin; }// w w w. ja v a 2s .c o m int[] newColors; int[][] newStates; int index = 0; boolean hasDisableColor = StateSet.stateSetMatches(tintInfo.mTintStates[0], DISABLED_STATE_SET); if (!hasDisableColor) { newStates = new int[tintInfo.mTintStates.length + 1][]; newColors = new int[tintInfo.mTintStates.length + 1]; newStates[index] = DISABLED_STATE_SET; newColors[index] = getDisabledThemeAttrColor(context, R.attr.themeColorSecondary); index++; } else { newStates = new int[tintInfo.mTintStates.length][]; newColors = new int[tintInfo.mTintStates.length]; } for (int i = 0; i < tintInfo.mTintStates.length; i++) { newStates[index] = tintInfo.mTintStates[i]; newColors[index] = replaceColor(context, tintInfo.mTintColors[i]); index++; } return new ColorStateList(newStates, newColors); } return ColorStateList.valueOf(replaceColor(context, origin.getDefaultColor())); }