Java Code Examples for android.util.AttributeSet#getAttributeIntValue()

The following examples show how to use android.util.AttributeSet#getAttributeIntValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NumberPickerPreference.java    From ForceDoze with GNU General Public License v3.0 6 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    setOnPreferenceClickListener(this);

    if (attrs != null) {
        int title = attrs.getAttributeResourceValue("http://schemas.android.com/apk/res/android", "title", -1);
        if (title != -1) {
            mTitle = context.getString(title);
        }
        mBindSummary = attrs.getAttributeBooleanValue(null, "bindSummary", DEFAULT_BIND_SUMMARY);
        mMin = attrs.getAttributeIntValue(null, "min", DEFAULT_MIN);
        mMax = attrs.getAttributeIntValue(null, "max", DEFAULT_MAX);
        mStep = attrs.getAttributeIntValue(null, "step", DEFAULT_STEP);
        mCurrentValue = mMin;
    }

    if (mTitle == null) {
        mTitle = "Choose delay (minutes)";
    }
    if (mMax < mMin) {
        throw new AssertionError("max value must be > min value");
    }
    if (mStep <= 0) {
        throw new AssertionError("step value must be > 0");
    }

}
 
Example 2
Source File: DefaultViewSkinHelper.java    From ThemeDemo with Apache License 2.0 6 votes vote down vote up
/**
 * 设置背景色
 * Set background Color
 */
public void init(View view, AttributeSet attrs) {
    mView = view;
    if (attrs == null) {
        mEnable = false;
        return;
    }
    mLightBackgroundRes = attrs.getAttributeResourceValue(ANDROIDXML, "background", -1);
    mDarkBackgroundRes = attrs.getAttributeResourceValue(MATERIALDESIGNXML, "nightBackground", -1);
    if (mLightBackgroundRes == -1) {
        mLightBackgroundColor = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
    }
    if (mDarkBackgroundRes == -1) {
        mDarkBackgroundColor = attrs.getAttributeIntValue(MATERIALDESIGNXML, "nightBackground", -1);
    }
    mLightTextColorRes = attrs.getAttributeResourceValue(ANDROIDXML, "textColor", -1);
    if (mLightTextColorRes == -1) {
        mLightTextColor = attrs.getAttributeIntValue(ANDROIDXML, "textColor", -1);
    }
    mNightTextColorRes = attrs.getAttributeResourceValue(MATERIALDESIGNXML, "nightTextColor", -1);
    if (mNightTextColorRes == -1) {
        nightTextColor = attrs.getAttributeIntValue(MATERIALDESIGNXML, "nightTextColor", -1);
    }
}
 
Example 3
Source File: ViewSkinHelper.java    From ThemeDemo with Apache License 2.0 6 votes vote down vote up
/**
 * 设置背景色
 * Set background Color
 */
public void init(View view, AttributeSet attrs) {

    mView = view;
    if (attrs == null) {
        mEnable = false;
        return;
    }
    mLightBackgroundRes = attrs.getAttributeResourceValue(ANDROIDXML, "background", -1);
    mDarkBackgroundRes = attrs.getAttributeResourceValue(MATERIALDESIGNXML, "nightBackground", -1);
    if (mLightBackgroundRes == -1) {
        mLightBackgroundColor = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
    }
    if (mDarkBackgroundRes == -1) {
        mDarkBackgroundColor = attrs.getAttributeIntValue(MATERIALDESIGNXML, "nightBackground", -1);
    }

}
 
Example 4
Source File: SeekBarPreference.java    From SimplePomodoro-android with MIT License 6 votes vote down vote up
private void setValuesFromXml(AttributeSet attrs) {
	mMaxValue = attrs.getAttributeIntValue(ANDROIDNS, "max", 100);
	mMinValue = attrs.getAttributeIntValue(APPLICATIONNS, "min", 0);
	
	mUnitsLeft = getAttributeStringValue(attrs, APPLICATIONNS, "unitsLeft", "");
	String units = getAttributeStringValue(attrs, APPLICATIONNS, "units", "");
	mUnitsRight = getAttributeStringValue(attrs, APPLICATIONNS, "unitsRight", units);
	
	try {
		String newInterval = attrs.getAttributeValue(APPLICATIONNS, "interval");
		if(newInterval != null)
			mInterval = Integer.parseInt(newInterval);
	}
	catch(Exception e) {
		Log.e(TAG, "Invalid interval value", e);
	}
	
}
 
Example 5
Source File: GifTextureView.java    From android-gif-drawable-eclipse-sample with MIT License 6 votes vote down vote up
private void init(AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    if (attrs != null) {
        final int scaleTypeIndex = attrs.getAttributeIntValue(GifViewUtils.ANDROID_NS, "scaleType", -1);
        if (scaleTypeIndex >= 0 && scaleTypeIndex < sScaleTypeArray.length) {
            mScaleType = sScaleTypeArray[scaleTypeIndex];
        }
        final TypedArray textureViewAttributes = getContext().obtainStyledAttributes(attrs, R.styleable
                .GifTextureView, defStyleAttr, defStyleRes);
        mInputSource = findSource(textureViewAttributes);
        super.setOpaque(textureViewAttributes.getBoolean(R.styleable.GifTextureView_isOpaque, false));
        textureViewAttributes.recycle();
        mFreezesAnimation = GifViewUtils.isFreezingAnimation(this, attrs, defStyleAttr, defStyleRes);
    } else {
        super.setOpaque(false);
    }
    if (!isInEditMode()) {
        mRenderThread = new RenderThread();
        if (mInputSource != null) {
            mRenderThread.start();
        }
    }
}
 
Example 6
Source File: RippleView.java    From XERUNG with Apache License 2.0 5 votes vote down vote up
protected void setRippleAttributes(AttributeSet attrs) {
	/**
	 * 初始化按压时涟漪的颜色
	 * Set Ripple Color
	 * Color by resource
	 */
	int color = attrs.getAttributeResourceValue(MATERIALDESIGNXML,"rippleColor",-1);
	if(color != -1){
		rippleColor = getResources().getColor(color);
		settedRippleColor = true;
	}else{
		// Color by hexadecimal
		int rColor = attrs.getAttributeIntValue(MATERIALDESIGNXML, "rippleColor", -1);// 16进制的颜色
		if(rColor != -1 && !isInEditMode()) {
			rippleColor = rColor;
			settedRippleColor = true;
		}
	}
	
	/**
	 * 初始化涟漪扩展的速度 
	 * init Ripple speed
	 */
	rippleSpeed = attrs.getAttributeFloatValue(MATERIALDESIGNXML, "rippleSpeed", rippleSpeed);
	
	/**
	 * 设定涟漪的响应时间
	 */
	clickAfterRipple = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "clickAfterRipple", clickAfterRipple);
}
 
Example 7
Source File: Switch.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
protected void setAttributes(AttributeSet attrs) {

        setBackgroundResource(R.drawable.background_transparent);

        // Set size of view
        setMinimumHeight(Utils.dpToPx(48, getResources()));
        setMinimumWidth(Utils.dpToPx(80, getResources()));

        // Set background Color
        // Color by resource
        int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,
                "background", -1);
        if (bacgroundColor != -1) {
			setBackgroundColor(getResources().getColor(bacgroundColor));
		} else {
			// Color by hexadecimal
			int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
			if (background != -1)
				setBackgroundColor(background);
		}

		check = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "check",
				false);
		eventCheck = check;
		ball = new Ball(getContext());
		RelativeLayout.LayoutParams params = new LayoutParams(Utils.dpToPx(20,
				getResources()), Utils.dpToPx(20, getResources()));
		params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
		ball.setLayoutParams(params);
		addView(ball);

	}
 
Example 8
Source File: Chip.java    From material-components-android with Apache License 2.0 5 votes vote down vote up
private void validateAttributes(@Nullable AttributeSet attributeSet) {
  if (attributeSet == null) {
    return;
  }
  if (attributeSet.getAttributeValue(NAMESPACE_ANDROID, "background") != null) {
    Log.w(TAG, "Do not set the background; Chip manages its own background drawable.");
  }
  if (attributeSet.getAttributeValue(NAMESPACE_ANDROID, "drawableLeft") != null) {
    throw new UnsupportedOperationException("Please set left drawable using R.attr#chipIcon.");
  }
  if (attributeSet.getAttributeValue(NAMESPACE_ANDROID, "drawableStart") != null) {
    throw new UnsupportedOperationException("Please set start drawable using R.attr#chipIcon.");
  }
  if (attributeSet.getAttributeValue(NAMESPACE_ANDROID, "drawableEnd") != null) {
    throw new UnsupportedOperationException("Please set end drawable using R.attr#closeIcon.");
  }
  if (attributeSet.getAttributeValue(NAMESPACE_ANDROID, "drawableRight") != null) {
    throw new UnsupportedOperationException("Please set end drawable using R.attr#closeIcon.");
  }
  if (!attributeSet.getAttributeBooleanValue(NAMESPACE_ANDROID, "singleLine", true)
      || (attributeSet.getAttributeIntValue(NAMESPACE_ANDROID, "lines", 1) != 1)
      || (attributeSet.getAttributeIntValue(NAMESPACE_ANDROID, "minLines", 1) != 1)
      || (attributeSet.getAttributeIntValue(NAMESPACE_ANDROID, "maxLines", 1) != 1)) {
    throw new UnsupportedOperationException("Chip does not support multi-line text");
  }

  if (attributeSet.getAttributeIntValue(
          NAMESPACE_ANDROID, "gravity", (Gravity.CENTER_VERTICAL | Gravity.START))
      != (Gravity.CENTER_VERTICAL | Gravity.START)) {
    Log.w(TAG, "Chip text must be vertically center and start aligned");
  }
}
 
Example 9
Source File: Switch.java    From Social with Apache License 2.0 5 votes vote down vote up
protected void setAttributes(AttributeSet attrs) {

        setBackgroundResource(R.drawable.background_transparent);

        // Set size of view
        setMinimumHeight(Utils.dpToPx(48, getResources()));
        setMinimumWidth(Utils.dpToPx(80, getResources()));

        // Set background Color
        // Color by resource
        int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,
                "background", -1);
        if (bacgroundColor != -1) {
            setBackgroundColor(getResources().getColor(bacgroundColor));
        } else {
            // Color by hexadecimal
            int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
            if (background != -1)
                setBackgroundColor(background);
        }

        check = attrs.getAttributeBooleanValue(MATERIALDESIGNXML, "check",
                false);
        eventCheck = check;
        ball = new Ball(getContext());
        RelativeLayout.LayoutParams params = new LayoutParams(Utils.dpToPx(20,
                getResources()), Utils.dpToPx(20, getResources()));
        params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
        ball.setLayoutParams(params);
        addView(ball);

    }
 
Example 10
Source File: CardUI.java    From Pimp_my_Z1 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructor
 */
public CardUI(Context context, AttributeSet attrs) {
    super(context, attrs);
    //read the number of columns from the attributes
    mColumnNumber = attrs.getAttributeIntValue(null, "columnCount", 1);
    initData(context);
}
 
Example 11
Source File: Slider.java    From DMAudioStreamer with Apache License 2.0 5 votes vote down vote up
protected void setAttributes(AttributeSet attrs) {

        setBackgroundResource(R.drawable.background_transparent);

        // Set size of view
        setMinimumHeight(dpToPx(48, getResources()));
        setMinimumWidth(dpToPx(80, getResources()));

        // Set background Color
        // Color by resource
        int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML, "background", -1);
        if (bacgroundColor != -1) {
            setBackgroundColor(getResources().getColor(bacgroundColor));
        } else {
            // Color by hexadecimal
            int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
            if (background != -1)
                setBackgroundColor(background);
        }

        min = attrs.getAttributeIntValue(MATERIALDESIGNXML, "min", 0);
        max = attrs.getAttributeIntValue(MATERIALDESIGNXML, "max", 0);
        value = attrs.getAttributeIntValue(MATERIALDESIGNXML, "value", min);

        ball = new Ball(getContext());
        LayoutParams params = new LayoutParams(dpToPx(15, getResources()), dpToPx(15, getResources()));
        params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
        ball.setLayoutParams(params);
        addView(ball);

    }
 
Example 12
Source File: CustomView.java    From XERUNG with Apache License 2.0 5 votes vote down vote up
/**
 * 设置背景色
 * Set background Color
 */
protected void setBackgroundAttributes(AttributeSet attrs) {
	int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1);
	if(bacgroundColor != -1){
		setBackgroundColor(getResources().getColor(bacgroundColor));
	}else{
		// Color by hexadecimal
		int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
		if(background != -1 && !isInEditMode()) {
			setBackgroundColor(background);
		}else {
			setBackgroundColor(backgroundColor);// 如果没有设置,就用这个颜色
		}
	}
}
 
Example 13
Source File: Slider.java    From XERUNG with Apache License 2.0 5 votes vote down vote up
@Override
protected void setAttributes(AttributeSet attrs) {
	super.setAttributes(attrs);
	if (!isInEditMode()) {
		getBackground().setAlpha(0);
	}
	showNumberIndicator = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,"showNumberIndicator", false);
	min = attrs.getAttributeIntValue(MATERIALDESIGNXML, "min", 0);
	max = attrs.getAttributeIntValue(MATERIALDESIGNXML, "max", 100);// max > min
	value = attrs.getAttributeIntValue(MATERIALDESIGNXML, "value", min);

	float size = 20;
	String thumbSize = attrs.getAttributeValue(MATERIALDESIGNXML, "thumbSize");
	if (thumbSize != null) {
		size = Utils.dipOrDpToFloat(thumbSize);
	}

	ball = new Ball(getContext());
	setBallParams(size);
	addView(ball);

	// Set if slider content number indicator
	if (showNumberIndicator) {
		if (!isInEditMode()) {
			numberIndicator = new NumberIndicator(getContext());
		}
	}
}
 
Example 14
Source File: CustomView.java    From XERUNG with Apache License 2.0 5 votes vote down vote up
/**
 * 设置背景色
 * Set background Color
 */
protected void setBackgroundAttributes(AttributeSet attrs) {
	int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1);
	if(bacgroundColor != -1){
		setBackgroundColor(getResources().getColor(bacgroundColor));
	}else{
		// Color by hexadecimal
		int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
		if(background != -1 && !isInEditMode()) {
			setBackgroundColor(background);
		}else {
			setBackgroundColor(backgroundColor);// 如果没有设置,就用这个颜色
		}
	}
}
 
Example 15
Source File: SeekBarPreference.java    From screenrecorder with GNU Affero General Public License v3.0 5 votes vote down vote up
public SeekBarPreference(Context context, AttributeSet attrs) {
    super(context,attrs);

    //Set the preferenceto be persistent
    setPersistent(true);

    //Set custom preferece layout
    setDialogLayoutResource(R.layout.layout_floating_control_preview);

    //Get default values from xml
    mSuffix = attrs.getAttributeValue(androidns,"text");
    mDefault = attrs.getAttributeIntValue(androidns,"defaultValue", 100);
    mMax = attrs.getAttributeIntValue(androidns,"max", 200);
}
 
Example 16
Source File: ButtonFlat.java    From MoeGallery with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected void setAttributes(AttributeSet attrs) {
	// Set text button
	String text = null;
	int textResource = attrs.getAttributeResourceValue(ANDROIDXML,"text",-1);
	if(textResource != -1){
		text = getResources().getString(textResource);
	}else{
		text = attrs.getAttributeValue(ANDROIDXML,"text");
	}
	if(text != null){
		textButton = new TextView(getContext());
		textButton.setText(text.toUpperCase());
		textButton.setTextColor(backgroundColor);
		textButton.setTypeface(null, Typeface.BOLD);
		RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
		params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
		textButton.setLayoutParams(params);
		addView(textButton);
	}
	int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,"background",-1);
	if(bacgroundColor != -1){
		setBackgroundColor(getResources().getColor(bacgroundColor));
	}else{
		// Color by hexadecimal
		// Color by hexadecimal
		background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
		if (background != -1)
			setBackgroundColor(background);
	}
}
 
Example 17
Source File: SeekBarPreference.java    From MaxLock with GNU General Public License v3.0 5 votes vote down vote up
private void setValuesFromXml(AttributeSet attrs) {
    mMaxValue = attrs.getAttributeIntValue(ANDROID_XMLNS, "max", 100);
    mMinValue = attrs.getAttributeIntValue(SEEK_BAR_XMLNS, "min", 0);
    try {
        String newInterval = attrs.getAttributeValue(SEEK_BAR_XMLNS, "interval");
        if (newInterval != null)
            mInterval = Integer.parseInt(newInterval);
    } catch (Exception e) {
        Log.e(TAG, "Invalid interval value", e);
    }
}
 
Example 18
Source File: CheckBox.java    From MoeGallery with GNU General Public License v3.0 4 votes vote down vote up
protected void setAttributes(AttributeSet attrs) {

		setBackgroundResource(R.drawable.background_checkbox);

		// Set size of view
		setMinimumHeight(Utils.dpToPx(48, getResources()));
		setMinimumWidth(Utils.dpToPx(48, getResources()));

		// Set background Color
		// Color by resource
		int bacgroundColor = attrs.getAttributeResourceValue(ANDROIDXML,
				"background", -1);
		if (bacgroundColor != -1) {
			setBackgroundColor(getResources().getColor(bacgroundColor));
		} else {
			// Color by hexadecimal
			// Color by hexadecimal
			int background = attrs.getAttributeIntValue(ANDROIDXML, "background", -1);
			if (background != -1)
				setBackgroundColor(background);
		}

		final boolean check = attrs.getAttributeBooleanValue(MATERIALDESIGNXML,
				"check", false);
			post(new Runnable() {

				@Override
				public void run() {
					setChecked(check);
					setPressed(false);
					changeBackgroundColor(getResources().getColor(
							android.R.color.transparent));
				}
			});

		checkView = new Check(getContext());
        checkView.setId(View.generateViewId());
		RelativeLayout.LayoutParams params = new LayoutParams(Utils.dpToPx(20,
				getResources()), Utils.dpToPx(20, getResources()));
		params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
		checkView.setLayoutParams(params);
		addView(checkView);

        // Adding text view to checkbox
        int textResource = attrs.getAttributeResourceValue(ANDROIDXML, "text", -1);
        String text = null;

        if(textResource != -1) {
            text = getResources().getString(textResource);
        } else {
            text = attrs.getAttributeValue(ANDROIDXML, "text");
        }

        if(text != null) {
            params.removeRule(RelativeLayout.CENTER_IN_PARENT);
            params.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
                    TextView textView = new TextView(getContext());
            RelativeLayout.LayoutParams textViewLayoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            textViewLayoutParams.addRule(RelativeLayout.RIGHT_OF, checkView.getId());
            textViewLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE);
            textViewLayoutParams.setMargins(10, 0, 0, 0);
            textView.setLayoutParams(textViewLayoutParams);
            textView.setText(text);

            addView(textView);
        }
	}
 
Example 19
Source File: TextViewSkinHelper.java    From ThemeDemo with Apache License 2.0 4 votes vote down vote up
@Override
public void init(View view, AttributeSet attrs) {
    super.init(view, attrs);
    if (attrs == null) {
        mEnable = false;
        return;
    }

    mLightTextColorRes = attrs.getAttributeResourceValue(ANDROIDXML, "textColor", -1);
    if (mLightTextColorRes == -1) {
        mLightTextColor = attrs.getAttributeIntValue(ANDROIDXML, "textColor", -1);
    }

    int mLightTextColorHighlightRes = attrs.getAttributeResourceValue(ANDROIDXML, "textColorHighlight", -1);
    if (mLightTextColorHighlightRes == -1) {
        mLightTextColorHighlight = attrs.getAttributeIntValue(ANDROIDXML, "textColorHighlight", -1);
    } else {
        mLightTextColorHighlight = view.getContext().getResources().getColor(mLightTextColorHighlightRes);
    }

    mLightTextColorLinkRes = attrs.getAttributeResourceValue(ANDROIDXML, "textColorLink", -1);
    if (mLightTextColorLinkRes == -1) {
        mLightTextColorLink = attrs.getAttributeIntValue(ANDROIDXML, "textColorLink", -1);
    }


    mLightTextColorHintRes = attrs.getAttributeResourceValue(ANDROIDXML, "textColorHint", -1);
    if (mLightTextColorHintRes == -1) {
        mLightTextColorHint = attrs.getAttributeIntValue(ANDROIDXML, "textColorHint", -1);
    }

    mLightTextAppearance = attrs.getAttributeResourceValue(ANDROIDXML, "textAppearance", -1);


    mNightTextColorRes = attrs.getAttributeResourceValue(MATERIALDESIGNXML, "nightTextColor", -1);
    if (mNightTextColorRes == -1) {
        mNightTextColor = attrs.getAttributeIntValue(MATERIALDESIGNXML, "nightTextColor", -1);
    }

    int mNightTextColorHighlightRes = attrs.getAttributeResourceValue(MATERIALDESIGNXML, "nightTextColorHighlight", -1);
    if (mNightTextColorHighlightRes != -1) {
        mNightTextColorHighlight = view.getContext().getResources().getColor(mNightTextColorHighlightRes);

    } else {
        mNightTextColorHighlight = attrs.getAttributeIntValue(MATERIALDESIGNXML, "nightTextColorHighlight", -1);

    }

    mNightTextColorLinkRes = attrs.getAttributeResourceValue(MATERIALDESIGNXML, "nightTextColorLink", -1);
    if (mNightTextColorLinkRes == -1) {
        mNightTextColorLink = attrs.getAttributeIntValue(MATERIALDESIGNXML, "nightTextColorLink", -1);
    }


    mNightTextColorHintRes = attrs.getAttributeResourceValue(MATERIALDESIGNXML, "nightTextColorHint", -1);
    if (mNightTextColorHintRes == -1) {
        mNightTextColorHint = attrs.getAttributeIntValue(MATERIALDESIGNXML, "nightTextColorHint", -1);
    }
    mNightTextColorAppearance = attrs.getAttributeResourceValue(MATERIALDESIGNXML, "nightTextColorAppearance", -1);
}
 
Example 20
Source File: PackageParser.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
private static PackageLite parsePackageLite(Resources res, XmlPullParser parser,
        AttributeSet attrs, int flags, String[] outError) throws IOException,
        XmlPullParserException {

    int type;
    while ((type = parser.next()) != XmlPullParser.START_TAG
            && type != XmlPullParser.END_DOCUMENT) {
        ;
    }

    if (type != XmlPullParser.START_TAG) {
        outError[0] = "No start tag found";
        return null;
    }
    if (DEBUG_PARSER)
        Slog.v(TAG, "Root element name: '" + parser.getName() + "'");
    if (!parser.getName().equals("manifest")) {
        outError[0] = "No <manifest> tag";
        return null;
    }
    String pkgName = attrs.getAttributeValue(null, "package");
    if (pkgName == null || pkgName.length() == 0) {
        outError[0] = "<manifest> does not specify package";
        return null;
    }
    String nameError = validateName(pkgName, true);
    if (nameError != null && !"android".equals(pkgName)) {
        outError[0] = "<manifest> specifies bad package name \""
            + pkgName + "\": " + nameError;
        return null;
    }
    int installLocation = PARSE_DEFAULT_INSTALL_LOCATION;
    for (int i = 0; i < attrs.getAttributeCount(); i++) {
        String attr = attrs.getAttributeName(i);
        if (attr.equals("installLocation")) {
            installLocation = attrs.getAttributeIntValue(i,
                    PARSE_DEFAULT_INSTALL_LOCATION);
            break;
        }
    }

    // Only search the tree when the tag is directly below <manifest>
    final int searchDepth = parser.getDepth() + 1;

    final List<VerifierInfo> verifiers = new ArrayList<VerifierInfo>();
    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
            && (type != XmlPullParser.END_TAG || parser.getDepth() >= searchDepth)) {
        if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
            continue;
        }

        if (parser.getDepth() == searchDepth && "package-verifier".equals(parser.getName())) {
            final VerifierInfo verifier = parseVerifier(res, parser, attrs, flags, outError);
            if (verifier != null) {
                verifiers.add(verifier);
            }
        }
    }

    return new PackageLite(pkgName.intern(), installLocation, verifiers);
}