当前位置: 首页>>代码示例>>Java>>正文


Java TypedArray.peekValue方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:DialogUtils.java

示例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();
}
 
开发者ID:Krupen,项目名称:FabulousFilter,代码行数:19,代码来源:ViewPagerBottomSheetBehavior.java

示例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;
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:17,代码来源:KeyboardBuilder.java

示例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();
}
 
开发者ID:OhMyLob,项目名称:Paper-Launcher,代码行数:25,代码来源:BottomSheetBehaviorV2.java

示例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;
}
 
开发者ID:salim3dd,项目名称:hsv-alpha-color-picker,代码行数:11,代码来源:ColorPreference.java

示例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));
    }
}
 
开发者ID:Tamicer,项目名称:FilterBar,代码行数:14,代码来源:RangeSeekBar.java

示例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;
}
 
开发者ID:treasure-lau,项目名称:CSipSimple,代码行数:14,代码来源:GlowPadView.java

示例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);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:8,代码来源:ResourceUtils.java

示例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);
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:8,代码来源:ResourceUtils.java

示例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;
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:14,代码来源:ResourceUtils.java

示例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;
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:11,代码来源:ResourceUtils.java

示例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;
    }
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:9,代码来源:ThemeUtil.java

示例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();
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:14,代码来源:GradientDrawableUtils.java

示例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;
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:12,代码来源:GradientDrawableUtils.java

示例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();
	}
}
 
开发者ID:1313ou,项目名称:TreebolicLib,代码行数:65,代码来源:SplitPaneLayout.java


注:本文中的android.content.res.TypedArray.peekValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。