本文整理汇总了Java中android.content.res.TypedArray.peekValue方法的典型用法代码示例。如果您正苦于以下问题:Java TypedArray.peekValue方法的具体用法?Java TypedArray.peekValue怎么用?Java TypedArray.peekValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.res.TypedArray
的用法示例。
在下文中一共展示了TypedArray.peekValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveActionTextColorStateList
import android.content.res.TypedArray; //导入方法依赖的package包/类
public static ColorStateList resolveActionTextColorStateList(
Context context, @AttrRes int colorAttr, ColorStateList fallback) {
TypedArray a = context.getTheme().obtainStyledAttributes(new int[]{colorAttr});
try {
final TypedValue value = a.peekValue(0);
if (value == null) {
return fallback;
}
if (value.type >= TypedValue.TYPE_FIRST_COLOR_INT && value.type <= TypedValue.TYPE_LAST_COLOR_INT) {
return getActionTextStateList(context, value.data);
} else {
final ColorStateList stateList = a.getColorStateList(0);
if (stateList != null) {
return stateList;
} else {
return fallback;
}
}
} finally {
a.recycle();
}
}
示例2: ViewPagerBottomSheetBehavior
import android.content.res.TypedArray; //导入方法依赖的package包/类
public ViewPagerBottomSheetBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.BottomSheetBehavior_Layout);
TypedValue value = a.peekValue(R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight);
if (value != null && value.data == PEEK_HEIGHT_AUTO) {
setPeekHeight(value.data);
} else {
setPeekHeight(a.getDimensionPixelSize(
R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight, PEEK_HEIGHT_AUTO));
}
setHideable(a.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_hideable, false));
setSkipCollapsed(a.getBoolean(R.styleable.BottomSheetBehavior_Layout_behavior_skipCollapsed,
false));
a.recycle();
ViewConfiguration configuration = ViewConfiguration.get(context);
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}
示例3: matchTypedValue
import android.content.res.TypedArray; //导入方法依赖的package包/类
private static boolean matchTypedValue(final TypedArray a, final int index, final int intValue,
final String strValue) {
// If <case> does not have "index" attribute, that means this <case> is wild-card for
// the attribute.
final TypedValue v = a.peekValue(index);
if (v == null) {
return true;
}
if (ResourceUtils.isIntegerValue(v)) {
return intValue == a.getInt(index, 0);
}
if (ResourceUtils.isStringValue(v)) {
return StringUtils.containsInArray(strValue, a.getString(index).split("\\|"));
}
return false;
}
示例4: BottomSheetBehaviorV2
import android.content.res.TypedArray; //导入方法依赖的package包/类
/**
* Default constructor for inflating BottomSheetBehaviors from layout.
*
* @param context The {@link Context}.
* @param attrs The {@link AttributeSet}.
*/
public BottomSheetBehaviorV2(Context context, AttributeSet attrs) {
super(context, attrs);
TypedArray a = context.obtainStyledAttributes(attrs,
android.support.design.R.styleable.BottomSheetBehavior_Layout);
TypedValue value = a.peekValue(android.support.design.R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight);
if (value != null && value.data == PEEK_HEIGHT_AUTO) {
setPeekHeight(value.data);
} else {
setPeekHeight(a.getDimensionPixelSize(
android.support.design.R.styleable.BottomSheetBehavior_Layout_behavior_peekHeight, PEEK_HEIGHT_AUTO));
}
setHideable(a.getBoolean(android.support.design.R.styleable.BottomSheetBehavior_Layout_behavior_hideable, false));
setSkipCollapsed(a.getBoolean(android.support.design.R.styleable.BottomSheetBehavior_Layout_behavior_skipCollapsed,
false));
a.recycle();
ViewConfiguration configuration = ViewConfiguration.get(context);
mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
}
示例5: onGetDefaultValue
import android.content.res.TypedArray; //导入方法依赖的package包/类
@Override
protected Object onGetDefaultValue(TypedArray a, int index) {
if (a.peekValue(index) != null && a.peekValue(index).type == TypedValue.TYPE_STRING) {
defaultColor = Color.parseColor(standardiseColorDigits(a.getString(index)));
}
else {
defaultColor = a.getColor(index, Color.GRAY);
}
return defaultColor;
}
示例6: extractNumericValueFromAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
private T extractNumericValueFromAttributes(TypedArray a, int attribute, int defaultValue) {
TypedValue tv = a.peekValue(attribute);
if (tv == null) {
return (T) Integer.valueOf(defaultValue);
}
int type = tv.type;
if (type == TypedValue.TYPE_FLOAT) {
return (T) Float.valueOf(a.getFloat(attribute, defaultValue));
} else {
return (T) Integer.valueOf(a.getInteger(attribute, defaultValue));
}
}
示例7: loadDrawableArray
import android.content.res.TypedArray; //导入方法依赖的package包/类
private ArrayList<TargetDrawable> loadDrawableArray(int resourceId) {
Resources res = getContext().getResources();
TypedArray array = res.obtainTypedArray(resourceId);
final int count = array.length();
ArrayList<TargetDrawable> drawables = new ArrayList<TargetDrawable>(count);
for (int i = 0; i < count; i++) {
TypedValue value = array.peekValue(i);
TargetDrawable target = new TargetDrawable(res, value != null ? value.resourceId : 0);
drawables.add(target);
}
array.recycle();
return drawables;
}
示例8: getFraction
import android.content.res.TypedArray; //导入方法依赖的package包/类
public static float getFraction(final TypedArray a, final int index, final float defValue) {
final TypedValue value = a.peekValue(index);
if (value == null || !isFractionValue(value)) {
return defValue;
}
return a.getFraction(index, 1, 1, defValue);
}
示例9: getDimensionPixelSize
import android.content.res.TypedArray; //导入方法依赖的package包/类
public static int getDimensionPixelSize(final TypedArray a, final int index) {
final TypedValue value = a.peekValue(index);
if (value == null || !isDimensionValue(value)) {
return ResourceUtils.UNDEFINED_DIMENSION;
}
return a.getDimensionPixelSize(index, ResourceUtils.UNDEFINED_DIMENSION);
}
示例10: getDimensionOrFraction
import android.content.res.TypedArray; //导入方法依赖的package包/类
public static float getDimensionOrFraction(final TypedArray a, final int index, final int base,
final float defValue) {
final TypedValue value = a.peekValue(index);
if (value == null) {
return defValue;
}
if (isFractionValue(value)) {
return a.getFraction(index, base, base, defValue);
} else if (isDimensionValue(value)) {
return a.getDimension(index, defValue);
}
return defValue;
}
示例11: getEnumValue
import android.content.res.TypedArray; //导入方法依赖的package包/类
public static int getEnumValue(final TypedArray a, final int index, final int defValue) {
final TypedValue value = a.peekValue(index);
if (value == null) {
return defValue;
}
if (isIntegerValue(value)) {
return a.getInt(index, defValue);
}
return defValue;
}
示例12: getType
import android.content.res.TypedArray; //导入方法依赖的package包/类
public static int getType(TypedArray array, int index){
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP)
return array.getType(index);
else{
TypedValue value = array.peekValue(index);
return value == null ? TypedValue.TYPE_NULL : value.type;
}
}
示例13: setGradientRadius
import android.content.res.TypedArray; //导入方法依赖的package包/类
void setGradientRadius(Context context, AttributeSet attrs, GradientDrawable drawable, int gradientType) throws XmlPullParserException {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{android.R.attr.gradientRadius});
TypedValue value = a.peekValue(0);
if (value != null) {
boolean radiusRel = value.type == TypedValue.TYPE_FRACTION;
drawable.setGradientRadius(radiusRel ? value.getFraction(1.0f, 1.0f) : value.getFloat());
} else if (gradientType == GradientDrawable.RADIAL_GRADIENT) {
throw new XmlPullParserException(
"<gradient> tag requires 'gradientRadius' "
+ "attribute with radial type");
}
a.recycle();
}
示例14: getAttrFloatOrFraction
import android.content.res.TypedArray; //导入方法依赖的package包/类
float getAttrFloatOrFraction(Context context, AttributeSet attrs, int attr, float defaultValue, float base, float pbase) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
TypedValue tv = a.peekValue(0);
float v = defaultValue;
if (tv != null) {
boolean isFraction = tv.type == TypedValue.TYPE_FRACTION;
v = isFraction ? tv.getFraction(base, pbase) : tv.getFloat();
}
a.recycle();
return v;
}
示例15: extractAttributes
import android.content.res.TypedArray; //导入方法依赖的package包/类
private void extractAttributes(@NonNull final Context context, @Nullable final AttributeSet attrs)
{
if (attrs != null)
{
final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.SplitPaneLayout);
// misc
this.orientation = array.getInt(R.styleable.SplitPaneLayout_orientation, 0);
this.splitterSize = array.getDimensionPixelSize(R.styleable.SplitPaneLayout_splitterSize, context.getResources().getDimensionPixelSize(R.dimen.spl_default_splitter_size));
this.splitterMovable = array.getBoolean(R.styleable.SplitPaneLayout_splitterMovable, true);
// position
TypedValue value = array.peekValue(R.styleable.SplitPaneLayout_splitterPosition);
if (value != null)
{
if (value.type == TypedValue.TYPE_DIMENSION)
{
this.splitterPosition = array.getDimensionPixelSize(R.styleable.SplitPaneLayout_splitterPosition, Integer.MIN_VALUE);
this.splitterPositionPercent = -1;
}
else if (value.type == TypedValue.TYPE_FRACTION)
{
this.splitterPositionPercent = array.getFraction(R.styleable.SplitPaneLayout_splitterPosition, 100, 100, 50) * 0.01f;
this.splitterPosition = Integer.MIN_VALUE;
}
}
else
{
this.splitterPosition = Integer.MIN_VALUE;
this.splitterPositionPercent = 0.5f;
}
// backgrounds
value = array.peekValue(R.styleable.SplitPaneLayout_splitterBackground);
if (value != null)
{
if (value.type == TypedValue.TYPE_REFERENCE || value.type == TypedValue.TYPE_STRING)
{
this.splitterDrawable = array.getDrawable(R.styleable.SplitPaneLayout_splitterBackground);
}
else if (value.type == TypedValue.TYPE_INT_COLOR_ARGB8 || value.type == TypedValue.TYPE_INT_COLOR_ARGB4 || value.type == TypedValue.TYPE_INT_COLOR_RGB8 || value.type == TypedValue.TYPE_INT_COLOR_RGB4)
{
this.splitterDrawable = new PaintDrawable(array.getColor(R.styleable.SplitPaneLayout_splitterBackground, 0xFF000000));
}
}
value = array.peekValue(R.styleable.SplitPaneLayout_splitterDraggingBackground);
if (value != null)
{
if (value.type == TypedValue.TYPE_REFERENCE || value.type == TypedValue.TYPE_STRING)
{
this.splitterDraggingDrawable = array.getDrawable(R.styleable.SplitPaneLayout_splitterDraggingBackground);
}
else if (value.type == TypedValue.TYPE_INT_COLOR_ARGB8 || value.type == TypedValue.TYPE_INT_COLOR_ARGB4 || value.type == TypedValue.TYPE_INT_COLOR_RGB8 || value.type == TypedValue.TYPE_INT_COLOR_RGB4)
{
this.splitterDraggingDrawable = new PaintDrawable(array.getColor(R.styleable.SplitPaneLayout_splitterDraggingBackground, SPLITTER_DRAG_COLOR));
}
}
else
{
this.splitterDraggingDrawable = new PaintDrawable(SPLITTER_DRAG_COLOR);
}
array.recycle();
}
}