public GSYVideoControlView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { super(context, attrs, defStyleAttr); }
public GSYTextureRenderView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { super(context, attrs, defStyleAttr); }
final int resolveResIdAttr(@AttrRes int attrResId, int defResId) { mAttrs[0] = attrResId; TypedArray a = mTheme.obtainStyledAttributes(mAttrs); try { return a.getResourceId(0, defResId); } finally { a.recycle(); } }
@NonNull protected static TypedValue getTypedValue(@NonNull Context context, @AttrRes int resId) { TypedValue tv = new TypedValue(); context.getTheme().resolveAttribute(resId, tv, true); return tv; }
public static int getThemeAttrId(Context context, @AttrRes int attr) { TEMP_ARRAY[0] = attr; TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY); try { return a.getResourceId(0, 0); } finally { a.recycle(); } }
public static boolean hasThemeAttr(Context context, @AttrRes int attr) { TEMP_ARRAY[0] = attr; TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY); try { return a.hasValue(0); } finally { a.recycle(); } }
public static boolean getThemeAttrBoolean(Context context, @AttrRes int attr) { TEMP_ARRAY[0] = attr; TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY); try { return a.getBoolean(0, false); } finally { a.recycle(); } }
/** * Get a color from an attr styled according to the the context's theme. */ public static int resolveColorFromAttr(Context context, @AttrRes int attrColor) { final TypedValue value = new TypedValue(); context.getTheme().resolveAttribute(attrColor, value, true); if (value.resourceId != 0) { return ContextCompat.getColor(context, value.resourceId); } return value.data; }
/** * Get a resource id from a resource styled according to the the context's theme. */ public static int resolveResourceIdFromAttr(Context context, @AttrRes int attr) { TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr}); int attributeResourceId = a.getResourceId(0, 0); a.recycle(); return attributeResourceId; }
private static int resolveResourceIdFromAttr(Context context, @AttrRes int attr) { TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{attr}); int attributeResourceId = a.getResourceId(0, 0); a.recycle(); return attributeResourceId; } }
public GSYVideoView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) { super(context, attrs, defStyleAttr); init(context); }
@ColorInt protected static int getColor(@NonNull Context context, @AttrRes int color) { return getTypedValue(context, color).data; }
@DrawableRes protected static int getDrawableRes(@NonNull Context context, @AttrRes int drawable) { return getTypedValue(context, drawable).resourceId; }
public int resolveColorAttr(@AttrRes int attrResId, @ColorRes int defResId) { mAttrs[0] = attrResId; TypedArray a = mTheme.obtainStyledAttributes(mAttrs); try { return a.getColor(0, resolveColorRes(defResId)); } finally { a.recycle(); } }
/** * Specifies the border radius for all corners * * @param attrId The attribute id to retrieve the border radius value from */ public Builder radiusAttr(@AttrRes int attrId) { return radiusAttr(attrId, 0); }
public static ColorStateList getThemeAttrColorStateList(Context context, @AttrRes int attr) { TEMP_ARRAY[0] = attr; TypedArray a = context.obtainStyledAttributes(null, TEMP_ARRAY); try { return a.getColorStateList(0); } finally { a.recycle(); } }
@Nullable public String[] resolveStringArrayAttr(@AttrRes int attrResId, @ArrayRes int defResId) { mAttrs[0] = attrResId; TypedArray a = mTheme.obtainStyledAttributes(mAttrs); try { return resolveStringArrayRes(a.getResourceId(0, defResId)); } finally { a.recycle(); } }
@Nullable public int[] resolveIntArrayAttr(@AttrRes int attrResId, @ArrayRes int defResId) { mAttrs[0] = attrResId; TypedArray a = mTheme.obtainStyledAttributes(mAttrs); try { return resolveIntArrayRes(a.getResourceId(0, defResId)); } finally { a.recycle(); } }
public int resolveIntAttr(@AttrRes int attrResId, @IntegerRes int defResId) { mAttrs[0] = attrResId; TypedArray a = mTheme.obtainStyledAttributes(mAttrs); try { return a.getInt(0, resolveIntRes(defResId)); } finally { a.recycle(); } }
public boolean resolveBoolAttr(@AttrRes int attrResId, @BoolRes int defResId) { mAttrs[0] = attrResId; TypedArray a = mTheme.obtainStyledAttributes(mAttrs); try { return a.getBoolean(0, resolveBoolRes(defResId)); } finally { a.recycle(); } }