Example usage for android.content.res TypedArray getPositionDescription

List of usage examples for android.content.res TypedArray getPositionDescription

Introduction

In this page you can find the example usage for android.content.res TypedArray getPositionDescription.

Prototype

public String getPositionDescription() 

Source Link

Document

Returns a message about the parser state suitable for printing error messages.

Usage

From source file:android.support.graphics.drawable.AnimatorInflaterCompat.java

/**
 * Setup ObjectAnimator's property or values from pathData.
 *
 * @param anim                The target Animator which will be updated.
 * @param arrayObjectAnimator TypedArray for the ObjectAnimator.
 * @param pixelSize           The relative pixel size, used to calculate the
 *///w ww.jav a2 s.  c  om
private static void setupObjectAnimator(ValueAnimator anim, TypedArray arrayObjectAnimator, int valueType,
        float pixelSize, XmlPullParser parser) {
    ObjectAnimator oa = (ObjectAnimator) anim;
    String pathData = TypedArrayUtils.getNamedString(arrayObjectAnimator, parser, "pathData",
            AndroidResources.STYLEABLE_PROPERTY_ANIMATOR_PATH_DATA);

    // Path can be involved in an ObjectAnimator in the following 3 ways:
    // 1) Path morphing: the property to be animated is pathData, and valueFrom and valueTo
    //    are both of pathType. valueType = pathType needs to be explicitly defined.
    // 2) A property in X or Y dimension can be animated along a path: the property needs to be
    //    defined in propertyXName or propertyYName attribute, the path will be defined in the
    //    pathData attribute. valueFrom and valueTo will not be necessary for this animation.
    // 3) PathInterpolator can also define a path (in pathData) for its interpolation curve.
    // Here we are dealing with case 2:
    if (pathData != null) {
        String propertyXName = TypedArrayUtils.getNamedString(arrayObjectAnimator, parser, "propertyXName",
                AndroidResources.STYLEABLE_PROPERTY_ANIMATOR_PROPERTY_X_NAME);
        String propertyYName = TypedArrayUtils.getNamedString(arrayObjectAnimator, parser, "propertyYName",
                AndroidResources.STYLEABLE_PROPERTY_ANIMATOR_PROPERTY_Y_NAME);

        if (valueType == VALUE_TYPE_PATH || valueType == VALUE_TYPE_UNDEFINED) {
            // When pathData is defined, we are in case #2 mentioned above. ValueType can only
            // be float type, or int type. Otherwise we fallback to default type.
            valueType = VALUE_TYPE_FLOAT;
        }
        if (propertyXName == null && propertyYName == null) {
            throw new InflateException(arrayObjectAnimator.getPositionDescription()
                    + " propertyXName or propertyYName is needed for PathData");
        } else {
            Path path = PathParser.createPathFromPathData(pathData);
            setupPathMotion(path, oa, 0.5f * pixelSize, propertyXName, propertyYName);
        }
    } else {
        String propertyName = TypedArrayUtils.getNamedString(arrayObjectAnimator, parser, "propertyName",
                AndroidResources.STYLEABLE_PROPERTY_ANIMATOR_PROPERTY_NAME);
        oa.setPropertyName(propertyName);
    }

    return;

}

From source file:com.hippo.vectorold.drawable.VectorDrawable.java

private void updateStateFromTypedArray(TypedArray a) throws XmlPullParserException {
    final VectorDrawableState state = mVectorState;
    final VPathRenderer pathRenderer = state.mVPathRenderer;

    // Account for any configuration changes.
    state.mChangingConfigurations |= 0; //a.getChangingConfigurations();

    final int tintMode = a.getInt(R.styleable.VectorDrawable_tintMode, -1);
    if (tintMode != -1) {
        state.mTintMode = DrawableUtils.parseTintMode(tintMode, Mode.SRC_IN);
    }/*from ww  w  . j ava  2s. c  om*/

    final ColorStateList tint = a.getColorStateList(R.styleable.VectorDrawable_tint);
    if (tint != null) {
        state.mTint = tint;
    }

    state.mAutoMirrored = a.getBoolean(R.styleable.VectorDrawable_autoMirrored, state.mAutoMirrored);

    pathRenderer.mViewportWidth = a.getFloat(R.styleable.VectorDrawable_viewportWidth,
            pathRenderer.mViewportWidth);
    pathRenderer.mViewportHeight = a.getFloat(R.styleable.VectorDrawable_viewportHeight,
            pathRenderer.mViewportHeight);

    if (pathRenderer.mViewportWidth <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportWidth > 0");
    } else if (pathRenderer.mViewportHeight <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportHeight > 0");
    }

    pathRenderer.mBaseWidth = a.getDimension(R.styleable.VectorDrawable_width, pathRenderer.mBaseWidth);
    pathRenderer.mBaseHeight = a.getDimension(R.styleable.VectorDrawable_height, pathRenderer.mBaseHeight);

    if (pathRenderer.mBaseWidth <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires width > 0");
    } else if (pathRenderer.mBaseHeight <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires height > 0");
    }

    final float alphaInFloat = a.getFloat(R.styleable.VectorDrawable_alpha, pathRenderer.getAlpha());
    pathRenderer.setAlpha(alphaInFloat);

    final String name = a.getString(R.styleable.VectorDrawable_name);
    if (name != null) {
        pathRenderer.mRootName = name;
        pathRenderer.mVGTargetsMap.put(name, pathRenderer);
    }
}

From source file:com.wnafee.vector.compat.VectorDrawable.java

private void updateStateFromTypedArray(TypedArray a) throws XmlPullParserException {
    final VectorDrawableState state = mVectorState;
    final VPathRenderer pathRenderer = state.mVPathRenderer;

    // Account for any configuration changes.
    state.mChangingConfigurations |= getChangingConfigurations(a);

    // Extract the theme attributes, if any.
    //TODO: will not support drawable theming yet (applies to tinting mainly)
    //state.mThemeAttrs = a.extractThemeAttrs();

    final int tintMode = a.getInt(R.styleable.VectorDrawable_vc_tintMode, -1);
    if (tintMode != -1) {
        state.mTintMode = parseTintMode(tintMode, Mode.SRC_IN);
    }/*from   w ww  . j  a  va  2 s.  c  om*/

    final ColorStateList tint = a.getColorStateList(R.styleable.VectorDrawable_vc_tint);
    if (tint != null) {
        state.mTint = tint;
    }

    state.mAutoMirrored = a.getBoolean(R.styleable.VectorDrawable_vc_autoMirrored, state.mAutoMirrored);

    pathRenderer.mViewportWidth = a.getFloat(R.styleable.VectorDrawable_vc_viewportWidth,
            pathRenderer.mViewportWidth);
    pathRenderer.mViewportHeight = a.getFloat(R.styleable.VectorDrawable_vc_viewportHeight,
            pathRenderer.mViewportHeight);

    if (pathRenderer.mViewportWidth <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<menu_vector> tag requires viewportWidth > 0");
    } else if (pathRenderer.mViewportHeight <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<menu_vector> tag requires viewportHeight > 0");
    }

    pathRenderer.mBaseWidth = a.getDimension(R.styleable.VectorDrawable_android_width, pathRenderer.mBaseWidth);
    pathRenderer.mBaseHeight = a.getDimension(R.styleable.VectorDrawable_android_height,
            pathRenderer.mBaseHeight);

    if (pathRenderer.mBaseWidth <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<menu_vector> tag requires width > 0");
    } else if (pathRenderer.mBaseHeight <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<menu_vector> tag requires height > 0");
    }

    final float alphaInFloat = a.getFloat(R.styleable.VectorDrawable_android_alpha, pathRenderer.getAlpha());
    pathRenderer.setAlpha(alphaInFloat);

    final String name = a.getString(R.styleable.VectorDrawable_android_name);
    if (name != null) {
        pathRenderer.mRootName = name;
        pathRenderer.mVGTargetsMap.put(name, pathRenderer);
    }
}

From source file:net.zhuoweizhang.vectordrawable.VectorDrawable.java

private void updateStateFromTypedArray(TypedArray a) throws XmlPullParserException {
    final VectorDrawableState state = mVectorState;
    final VPathRenderer pathRenderer = state.mVPathRenderer;

    // Account for any configuration changes.
    //state.mChangingConfigurations |= a.getChangingConfigurations();

    // Extract the theme attributes, if any.
    state.mThemeAttrs = null;//a.extractThemeAttrs();

    final int tintMode = a.getInt(R.styleable.VectorDrawable_tintMode, -1);
    /*if (tintMode != -1) {
    state.mTintMode = Drawable.parseTintMode(tintMode, Mode.SRC_IN);
    }*///from  ww w . ja  va2 s.  co  m

    /*final ColorStateList tint = a.getColorStateList(R.styleable.VectorDrawable_tint);
    if (tint != null) {
    state.mTint = tint;
    }*/

    state.mAutoMirrored = a.getBoolean(R.styleable.VectorDrawable_autoMirrored, state.mAutoMirrored);

    pathRenderer.mViewportWidth = a.getFloat(R.styleable.VectorDrawable_viewportWidth,
            pathRenderer.mViewportWidth);
    pathRenderer.mViewportHeight = a.getFloat(R.styleable.VectorDrawable_viewportHeight,
            pathRenderer.mViewportHeight);

    if (pathRenderer.mViewportWidth <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportWidth > 0");
    } else if (pathRenderer.mViewportHeight <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportHeight > 0");
    }

    pathRenderer.mBaseWidth = a.getDimension(R.styleable.VectorDrawable_android_width, pathRenderer.mBaseWidth);
    pathRenderer.mBaseHeight = a.getDimension(R.styleable.VectorDrawable_android_height,
            pathRenderer.mBaseHeight);

    if (pathRenderer.mBaseWidth <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires width > 0");
    } else if (pathRenderer.mBaseHeight <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires height > 0");
    }

    final float alphaInFloat = a.getFloat(R.styleable.VectorDrawable_android_alpha, pathRenderer.getAlpha());
    pathRenderer.setAlpha(alphaInFloat);

    final String name = a.getString(R.styleable.VectorDrawable_android_name);
    if (name != null) {
        pathRenderer.mRootName = name;
        pathRenderer.mVGTargetsMap.put(name, pathRenderer);
    }
}

From source file:com.bettervectordrawable.lib.graphics.drawable.VectorDrawable.java

private void updateStateFromTypedArray(TypedArray a) throws XmlPullParserException {
    final VectorDrawableState state = mVectorState;
    final VPathRenderer pathRenderer = state.mVPathRenderer;
    // Account for any configuration changes.
    state.mChangingConfigurations |= TypedArrayExtension.getChangingConfigurations(a);
    // Extract the theme attributes, if any.
    state.mThemeAttrs = extractThemeAttrs(a);
    final int tintMode = a.getInt(R.styleable.VectorDrawable_tintMode, -1);
    if (tintMode != -1) {
        state.mTintMode = parseTintMode(tintMode, Mode.SRC_IN);
    }/*  w  w  w.  j a va2s.c o  m*/
    final ColorStateList tint = a.getColorStateList(R.styleable.VectorDrawable_tint);
    if (tint != null) {
        state.mTint = tint;
    }
    state.mAutoMirrored = a.getBoolean(R.styleable.VectorDrawable_autoMirrored, state.mAutoMirrored);
    pathRenderer.mViewportWidth = a.getFloat(R.styleable.VectorDrawable_viewportWidth,
            pathRenderer.mViewportWidth);
    pathRenderer.mViewportHeight = a.getFloat(R.styleable.VectorDrawable_viewportHeight,
            pathRenderer.mViewportHeight);
    if (pathRenderer.mViewportWidth <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportWidth > 0");
    } else if (pathRenderer.mViewportHeight <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportHeight > 0");
    }
    pathRenderer.mBaseWidth = a.getDimension(R.styleable.VectorDrawable_android_width, pathRenderer.mBaseWidth);
    pathRenderer.mBaseHeight = a.getDimension(R.styleable.VectorDrawable_android_height,
            pathRenderer.mBaseHeight);
    if (pathRenderer.mBaseWidth <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires width > 0");
    } else if (pathRenderer.mBaseHeight <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires height > 0");
    }
    final int insetLeft = a.getDimensionPixelSize(R.styleable.VectorDrawable_opticalInsetLeft,
            pathRenderer.mOpticalInsets.left);
    final int insetTop = a.getDimensionPixelSize(R.styleable.VectorDrawable_opticalInsetTop,
            pathRenderer.mOpticalInsets.top);
    final int insetRight = a.getDimensionPixelSize(R.styleable.VectorDrawable_opticalInsetRight,
            pathRenderer.mOpticalInsets.right);
    final int insetBottom = a.getDimensionPixelSize(R.styleable.VectorDrawable_opticalInsetBottom,
            pathRenderer.mOpticalInsets.bottom);
    pathRenderer.mOpticalInsets = Insets.of(insetLeft, insetTop, insetRight, insetBottom);
    final float alphaInFloat = a.getFloat(R.styleable.VectorDrawable_android_alpha, pathRenderer.getAlpha());
    pathRenderer.setAlpha(alphaInFloat);
    final String name = a.getString(R.styleable.VectorDrawable_android_name);
    if (name != null) {
        pathRenderer.mRootName = name;
        pathRenderer.mVGTargetsMap.put(name, pathRenderer);
    }
}

From source file:com.john.main.VectorDrawable.java

private void updateStateFromTypedArray(TypedArray a) throws XmlPullParserException {
    final VectorDrawableState state = mVectorState;
    final VPathRenderer pathRenderer = state.mVPathRenderer;

    // Account for any configuration changes.
    state.mChangingConfigurations |= Utils.getChangingConfigurations(a);

    // Extract the theme attributes, if any.
    state.mThemeAttrs = null; // TODO THEME TINT Not supported yet a.extractThemeAttrs();

    final int tintMode = a.getInt(R.styleable.VectorDrawable_tintMode, -1);
    if (tintMode != -1) {
        state.mTintMode = Utils.parseTintMode(tintMode, DEFAULT_TINT_MODE);
    }/*  w  w w. j a  v a 2  s .c  o m*/

    final ColorStateList tint = a.getColorStateList(R.styleable.VectorDrawable_tint);
    if (tint != null) {
        state.mTint = tint;
    }

    state.mAutoMirrored = a.getBoolean(R.styleable.VectorDrawable_autoMirrored, state.mAutoMirrored);

    pathRenderer.mViewportWidth = a.getFloat(R.styleable.VectorDrawable_viewportWidth,
            pathRenderer.mViewportWidth);
    pathRenderer.mViewportHeight = a.getFloat(R.styleable.VectorDrawable_viewportHeight,
            pathRenderer.mViewportHeight);

    if (pathRenderer.mViewportWidth <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportWidth > 0");
    } else if (pathRenderer.mViewportHeight <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportHeight > 0");
    }

    pathRenderer.mBaseWidth = a.getDimension(R.styleable.VectorDrawable_width, pathRenderer.mBaseWidth);
    pathRenderer.mBaseHeight = a.getDimension(R.styleable.VectorDrawable_height, pathRenderer.mBaseHeight);

    if (pathRenderer.mBaseWidth <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires width > 0");
    } else if (pathRenderer.mBaseHeight <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires height > 0");
    }

    final float alphaInFloat = a.getFloat(R.styleable.VectorDrawable_alpha, pathRenderer.getAlpha());
    pathRenderer.setAlpha(alphaInFloat);

    final String name = a.getString(R.styleable.VectorDrawable_name);
    if (name != null) {
        pathRenderer.mRootName = name;
        pathRenderer.mVGTargetsMap.put(name, pathRenderer);
    }
}

From source file:com.grottworkshop.gwsvectorsandboxlib.VectorDrawable.java

private void updateStateFromTypedArray(TypedArray a) throws XmlPullParserException {
    final VectorDrawableState state = mVectorState;
    final VPathRenderer pathRenderer = state.mVPathRenderer;

    // Account for any configuration changes.
    state.mChangingConfigurations |= Utils.getChangingConfigurations(a);

    // Extract the theme attributes, if any.
    state.mThemeAttrs = null; // TODO THEME TINT Not supported yet a.extractThemeAttrs();

    final int tintMode = a.getInt(R.styleable.VectorDrawable_mv_tintMode, -1);
    if (tintMode != -1) {
        state.mTintMode = Utils.parseTintMode(tintMode, DEFAULT_TINT_MODE);
    }//  ww  w .  ja va  2s . co  m

    final ColorStateList tint = a.getColorStateList(R.styleable.VectorDrawable_mv_tint);
    if (tint != null) {
        state.mTint = tint;
    }

    state.mAutoMirrored = a.getBoolean(R.styleable.VectorDrawable_mv_autoMirrored, state.mAutoMirrored);

    pathRenderer.mViewportWidth = a.getFloat(R.styleable.VectorDrawable_mv_viewportWidth,
            pathRenderer.mViewportWidth);
    pathRenderer.mViewportHeight = a.getFloat(R.styleable.VectorDrawable_mv_viewportHeight,
            pathRenderer.mViewportHeight);

    if (pathRenderer.mViewportWidth <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportWidth > 0");
    } else if (pathRenderer.mViewportHeight <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportHeight > 0");
    }

    pathRenderer.mBaseWidth = a.getDimension(R.styleable.VectorDrawable_mv_width, pathRenderer.mBaseWidth);
    pathRenderer.mBaseHeight = a.getDimension(R.styleable.VectorDrawable_mv_height, pathRenderer.mBaseHeight);

    if (pathRenderer.mBaseWidth <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires width > 0");
    } else if (pathRenderer.mBaseHeight <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires height > 0");
    }

    final float alphaInFloat = a.getFloat(R.styleable.VectorDrawable_mv_alpha, pathRenderer.getAlpha());
    pathRenderer.setAlpha(alphaInFloat);

    final String name = a.getString(R.styleable.VectorDrawable_mv_name);
    if (name != null) {
        pathRenderer.mRootName = name;
        pathRenderer.mVGTargetsMap.put(name, pathRenderer);
    }
}

From source file:com.hippo.vector.VectorDrawable.java

private void updateStateFromTypedArray(TypedArray a) throws XmlPullParserException {
    final VectorDrawableState state = mVectorState;
    final VPathRenderer pathRenderer = state.mVPathRenderer;

    // Account for any configuration changes.
    state.mChangingConfigurations |= Utils.getChangingConfigurations(a);

    final int tintMode = a.getInt(R.styleable.VectorDrawable_tintMode, -1);
    if (tintMode != -1) {
        state.mTintMode = Utils.parseTintMode(tintMode, Mode.SRC_IN);
    }//  w w w.  j  av  a 2s . c  om

    final ColorStateList tint = a.getColorStateList(R.styleable.VectorDrawable_tint);
    if (tint != null) {
        state.mTint = tint;
    }

    state.mAutoMirrored = a.getBoolean(R.styleable.VectorDrawable_autoMirrored, state.mAutoMirrored);

    setAllowCaching(a.getBoolean(R.styleable.VectorDrawable_allowCaching, true));

    pathRenderer.mViewportWidth = a.getFloat(R.styleable.VectorDrawable_viewportWidth,
            pathRenderer.mViewportWidth);
    pathRenderer.mViewportHeight = a.getFloat(R.styleable.VectorDrawable_viewportHeight,
            pathRenderer.mViewportHeight);

    if (pathRenderer.mViewportWidth <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportWidth > 0");
    } else if (pathRenderer.mViewportHeight <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportHeight > 0");
    }

    pathRenderer.mBaseWidth = a.getDimension(R.styleable.VectorDrawable_width, pathRenderer.mBaseWidth);
    pathRenderer.mBaseHeight = a.getDimension(R.styleable.VectorDrawable_height, pathRenderer.mBaseHeight);

    if (pathRenderer.mBaseWidth <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires width > 0");
    } else if (pathRenderer.mBaseHeight <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires height > 0");
    }

    final int insetLeft = a.getDimensionPixelSize(R.styleable.VectorDrawable_opticalInsetLeft,
            pathRenderer.mOpticalInsets.left);
    final int insetTop = a.getDimensionPixelSize(R.styleable.VectorDrawable_opticalInsetTop,
            pathRenderer.mOpticalInsets.top);
    final int insetRight = a.getDimensionPixelSize(R.styleable.VectorDrawable_opticalInsetRight,
            pathRenderer.mOpticalInsets.right);
    final int insetBottom = a.getDimensionPixelSize(R.styleable.VectorDrawable_opticalInsetBottom,
            pathRenderer.mOpticalInsets.bottom);
    pathRenderer.mOpticalInsets = Insets.of(insetLeft, insetTop, insetRight, insetBottom);

    final float alphaInFloat = a.getFloat(R.styleable.VectorDrawable_alpha, pathRenderer.getAlpha());
    pathRenderer.setAlpha(alphaInFloat);

    final String name = a.getString(R.styleable.VectorDrawable_name);
    if (name != null) {
        pathRenderer.mRootName = name;
        pathRenderer.mVGTargetsMap.put(name, pathRenderer);
    }
}

From source file:android.support.graphics.drawable.VectorDrawableCompat.java

private void updateStateFromTypedArray(TypedArray a, XmlPullParser parser) throws XmlPullParserException {
    final VectorDrawableCompatState state = mVectorState;
    final VPathRenderer pathRenderer = state.mVPathRenderer;

    // Account for any configuration changes.
    // state.mChangingConfigurations |= Utils.getChangingConfigurations(a);

    final int mode = TypedArrayUtils.getNamedInt(a, parser, "tintMode",
            AndroidResources.styleable_VectorDrawable_tintMode, -1);
    state.mTintMode = parseTintModeCompat(mode, Mode.SRC_IN);

    final ColorStateList tint = a.getColorStateList(AndroidResources.styleable_VectorDrawable_tint);
    if (tint != null) {
        state.mTint = tint;/*from  w w w  .j a  va 2 s .com*/
    }

    state.mAutoMirrored = TypedArrayUtils.getNamedBoolean(a, parser, "autoMirrored",
            AndroidResources.styleable_VectorDrawable_autoMirrored, state.mAutoMirrored);

    pathRenderer.mViewportWidth = TypedArrayUtils.getNamedFloat(a, parser, "viewportWidth",
            AndroidResources.styleable_VectorDrawable_viewportWidth, pathRenderer.mViewportWidth);

    pathRenderer.mViewportHeight = TypedArrayUtils.getNamedFloat(a, parser, "viewportHeight",
            AndroidResources.styleable_VectorDrawable_viewportHeight, pathRenderer.mViewportHeight);

    if (pathRenderer.mViewportWidth <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportWidth > 0");
    } else if (pathRenderer.mViewportHeight <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<vector> tag requires viewportHeight > 0");
    }

    pathRenderer.mBaseWidth = a.getDimension(AndroidResources.styleable_VectorDrawable_width,
            pathRenderer.mBaseWidth);
    pathRenderer.mBaseHeight = a.getDimension(AndroidResources.styleable_VectorDrawable_height,
            pathRenderer.mBaseHeight);
    if (pathRenderer.mBaseWidth <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires width > 0");
    } else if (pathRenderer.mBaseHeight <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<vector> tag requires height > 0");
    }

    // shown up from API 11.
    final float alphaInFloat = TypedArrayUtils.getNamedFloat(a, parser, "alpha",
            AndroidResources.styleable_VectorDrawable_alpha, pathRenderer.getAlpha());
    pathRenderer.setAlpha(alphaInFloat);

    final String name = a.getString(AndroidResources.styleable_VectorDrawable_name);
    if (name != null) {
        pathRenderer.mRootName = name;
        pathRenderer.mVGTargetsMap.put(name, pathRenderer);
    }
}

From source file:im.ene.lab.design.widget.vector.VectorDrawable.java

private void updateStateFromTypedArray(TypedArray a) throws XmlPullParserException {
    final VectorDrawableState state = mVectorState;
    final VPathRenderer pathRenderer = state.mVPathRenderer;

    // Account for any configuration changes.
    state.mChangingConfigurations |= getChangingConfigurations(a);

    // Extract the theme attributes, if any.
    //TODO: will not support drawable theming yet (applies to tinting mainly)
    //state.mThemeAttrs = a.extractThemeAttrs();

    //        final int tintMode = a.getInt(R.styleable.VectorDrawable_vc_tintMode, -1);
    final int tintMode = a.getInt(R.styleable.VectorDrawable_android_tintMode, -1);
    if (tintMode != -1) {
        state.mTintMode = parseTintMode(tintMode, Mode.SRC_IN);
    }//w w w.ja v  a  2 s.c o  m

    //        final ColorStateList tint = a.getColorStateList(R.styleable.VectorDrawable_vc_tint);
    final ColorStateList tint = a.getColorStateList(R.styleable.VectorDrawable_android_tint);
    if (tint != null) {
        state.mTint = tint;
    }

    //        state.mAutoMirrored = a.getBoolean(
    //                R.styleable.VectorDrawable_vc_autoMirrored, state.mAutoMirrored);
    state.mAutoMirrored = a.getBoolean(R.styleable.VectorDrawable_android_autoMirrored, state.mAutoMirrored);

    //        pathRenderer.mViewportWidth = a.getFloat(
    //                R.styleable.VectorDrawable_vc_viewportWidth, pathRenderer.mViewportWidth);
    pathRenderer.mViewportWidth = a.getFloat(R.styleable.VectorDrawable_android_viewportWidth,
            pathRenderer.mViewportWidth);
    //        pathRenderer.mViewportHeight = a.getFloat(
    //                R.styleable.VectorDrawable_vc_viewportHeight, pathRenderer.mViewportHeight);
    pathRenderer.mViewportHeight = a.getFloat(R.styleable.VectorDrawable_android_viewportHeight,
            pathRenderer.mViewportHeight);

    if (pathRenderer.mViewportWidth <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<menu_vector> tag requires viewportWidth > 0");
    } else if (pathRenderer.mViewportHeight <= 0) {
        throw new XmlPullParserException(
                a.getPositionDescription() + "<menu_vector> tag requires viewportHeight > 0");
    }

    pathRenderer.mBaseWidth = a.getDimension(R.styleable.VectorDrawable_android_width, pathRenderer.mBaseWidth);
    pathRenderer.mBaseHeight = a.getDimension(R.styleable.VectorDrawable_android_height,
            pathRenderer.mBaseHeight);

    if (pathRenderer.mBaseWidth <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<menu_vector> tag requires width > 0");
    } else if (pathRenderer.mBaseHeight <= 0) {
        throw new XmlPullParserException(a.getPositionDescription() + "<menu_vector> tag requires height > 0");
    }

    final float alphaInFloat = a.getFloat(R.styleable.VectorDrawable_android_alpha, pathRenderer.getAlpha());
    pathRenderer.setAlpha(alphaInFloat);

    final String name = a.getString(R.styleable.VectorDrawable_android_name);
    if (name != null) {
        pathRenderer.mRootName = name;
        pathRenderer.mVGTargetsMap.put(name, pathRenderer);
    }
}