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


Java XmlPullParser.getDepth方法代码示例

本文整理汇总了Java中org.xmlpull.v1.XmlPullParser.getDepth方法的典型用法代码示例。如果您正苦于以下问题:Java XmlPullParser.getDepth方法的具体用法?Java XmlPullParser.getDepth怎么用?Java XmlPullParser.getDepth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xmlpull.v1.XmlPullParser的用法示例。


在下文中一共展示了XmlPullParser.getDepth方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: f

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static String f(XmlPullParser xmlPullParser) {
    String str = "";
    int depth = xmlPullParser.getDepth();
    while (true) {
        if (xmlPullParser.next() == 3 && xmlPullParser.getDepth() == depth) {
            return str;
        }
        str = str + xmlPullParser.getText();
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:c.java

示例2: newFilter

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
@Override
public Filter newFilter(XmlPullParser parser)
        throws IOException, XmlPullParserException {
    Filter child = null;
    int outerDepth = parser.getDepth();
    while (XmlUtils.nextElementWithin(parser, outerDepth)) {
        Filter filter = IntentFirewall.parseFilter(parser);
        if (child == null) {
            child = filter;
        } else {
            throw new XmlPullParserException(
                    "<not> tag can only contain a single child filter.", parser, null);
        }
    }
    return new NotFilter(child);
}
 
开发者ID:TaRGroup,项目名称:IFWManager,代码行数:17,代码来源:NotFilter.java

示例3: inflateChildren

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private void inflateChildren(XmlPullParser parser, Node node) throws IOException, XmlPullParserException {
   final int depth=parser.getDepth();
   int type;
   while (((type = parser.next()) != XmlPullParser.END_TAG ||
           parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {
       if(type!=XmlPullParser.START_TAG){
           continue;
       }
       String tagName=parser.getName();
       //创建当前标签Node
       Node view=createNodeFromTag(tagName);
       if(view!=null&&node instanceof ViewGroup){
           ViewGroup viewGroup= (ViewGroup) node;
           //查找当前标签其内是否还有其他标签如果没有就直接返回
           inflateChildren(parser,view);
           viewGroup.addNode(view);
       }
   }
}
 
开发者ID:whitewoodcity,项目名称:xbrowser,代码行数:20,代码来源:LayoutInflater.java

示例4: inflateColorStateList

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
static ColorStateList inflateColorStateList(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException {
    final int innerDepth = parser.getDepth() + 1;
    int depth;
    int type;

    LinkedList<int[]> stateList = new LinkedList<>();
    LinkedList<Integer> colorList = new LinkedList<>();

    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
            && ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) {
        if (type != XmlPullParser.START_TAG || depth > innerDepth
                || !parser.getName().equals("item")) {
            continue;
        }

        TypedArray a1 = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.color});
        final int value = a1.getResourceId(0, Color.MAGENTA);
        final int baseColor = value == Color.MAGENTA ? Color.MAGENTA : ThemeUtils.replaceColorById(context, value);
        a1.recycle();
        TypedArray a2 = context.obtainStyledAttributes(attrs, new int[]{android.R.attr.alpha});
        final float alphaMod = a2.getFloat(0, 1.0f);
        a2.recycle();
        colorList.add(alphaMod != 1.0f
                ? ColorUtils.setAlphaComponent(baseColor, Math.round(Color.alpha(baseColor) * alphaMod))
                : baseColor);

        stateList.add(extractStateSet(attrs));
    }

    if (stateList.size() > 0 && stateList.size() == colorList.size()) {
        int[] colors = new int[colorList.size()];
        for (int i = 0; i < colorList.size(); i++) {
            colors[i] = colorList.get(i);
        }
        return new ColorStateList(stateList.toArray(new int[stateList.size()][]), colors);
    }
    return null;
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:39,代码来源:ColorStateListUtils.java

示例5: readFromXml

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public FilterList readFromXml(XmlPullParser parser) throws IOException, XmlPullParserException {
    int outerDepth = parser.getDepth();
    while (XmlUtils.nextElementWithin(parser, outerDepth)) {
        readChild(parser);
    }
    return this;
}
 
开发者ID:TaRGroup,项目名称:IFWManager,代码行数:8,代码来源:FilterList.java

示例6: skipCurrentTag

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public static void skipCurrentTag(XmlPullParser parser)
        throws XmlPullParserException, IOException {
    int outerDepth = parser.getDepth();
    int type;
    while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
            && (type != XmlPullParser.END_TAG
            || parser.getDepth() > outerDepth)) {
    }
}
 
开发者ID:Pixplicity,项目名称:HtmlCompat,代码行数:10,代码来源:XmlUtils.java

示例7: nextElementWithin

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public static boolean nextElementWithin(XmlPullParser parser, int outerDepth)
        throws IOException, XmlPullParserException {
    for (;;) {
        int type = parser.next();
        if (type == XmlPullParser.END_DOCUMENT
                || (type == XmlPullParser.END_TAG && parser.getDepth() == outerDepth)) {
            return false;
        }
        if (type == XmlPullParser.START_TAG
                && parser.getDepth() == outerDepth + 1) {
            return true;
        }
    }
}
 
开发者ID:Pixplicity,项目名称:HtmlCompat,代码行数:15,代码来源:XmlUtils.java

示例8: skipCurrentTag

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public static void skipCurrentTag(XmlPullParser parser)
        throws XmlPullParserException, IOException {
    int outerDepth = parser.getDepth();
    int type;
    while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
           && (type != XmlPullParser.END_TAG
                   || parser.getDepth() > outerDepth)) {
    }
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:10,代码来源:XmlUtils.java

示例9: rInflate

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
/**
 * Recursive method used to descend down the xml hierarchy and instantiate
 * items, instantiate their children, and then call onFinishInflate().
 */
private void rInflate(XmlPullParser parser, T node, final AttributeSet attrs)
        throws XmlPullParserException, IOException {
    final int depth = parser.getDepth();

    int type;
    while (((type = parser.next()) != XmlPullParser.END_TAG ||
            parser.getDepth() > depth) && type != XmlPullParser.END_DOCUMENT) {

        if (type != XmlPullParser.START_TAG) {
            continue;
        }

        if (onCreateCustomFromTag(parser, node, attrs)) {
            continue;
        }

        if (DEBUG) Log.v(TAG, "Now inflating tag: " + parser.getName());
        String name = parser.getName();

        T item = createItemFromTag(parser, name, attrs);

        if (DEBUG) Log.v(TAG, "Creating params from parent: " + node);

        onAddChildItem(node, item);


        if (DEBUG) Log.v(TAG, "-----> start inflating children");
        rInflate(parser, item, attrs);
        if (DEBUG) Log.v(TAG, "-----> done inflating children");
    }
}
 
开发者ID:Trumeet,项目名称:SetupWizardLibCompat,代码行数:36,代码来源:GenericInflater.java

示例10: parseCurrentView

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public static synchronized ArrayList<ViewItem> parseCurrentView() {
//        File f = new File("/mnt/sdcard/dump.xml");
//        if (f.exists()) f.delete();


        ShellUtils.execCommand("uiautomator dump /mnt/sdcard/dump.xml", true, false);
        String xml = MainActivity.Read_File("dump.xml").replace("\n", "");
        ArrayList<ViewItem> itemList = new ArrayList<>();
        ViewItem temp;
        XmlPullParser parser = Xml.newPullParser();
        try {
            parser.setInput(new StringReader(xml));
            int eventType = parser.getEventType();
            while (eventType != XmlPullParser.END_DOCUMENT) {
                String tagName = parser.getName();
                switch (eventType) {
                    case XmlPullParser.START_TAG:
                        if (tagName.equals("node")) {
                            temp = new ViewItem();
                            //读类名
                            String[] className = parser.getAttributeValue(null, "class").split("\\.");
                            temp.simpleClassName = className[className.length - 1];
                            //读坐标
                            String bounds = parser.getAttributeValue(null, "bounds");
                            String[] temp_n = bounds.replaceFirst("\\[", "").split("\\]\\[");
                            String[] point = temp_n[0].split(",");
                            if (point.length == 2)
                                temp.bounds = new Point(Integer.valueOf(point[0]), Integer.valueOf(point[1]));
                            else
                                temp.bounds = new Point();
                            //读宽高
                            point = bounds.split("\\]\\[")[1].split(",");
                            if (point.length == 2)
                                temp.wh = new Point(Integer.valueOf(point[0]) - temp.bounds.x, Integer.valueOf(point[1].replaceFirst("\\]", "")) - temp.bounds.y);
                            else
                                temp.wh = new Point();
                            //其他杂类信息
                            temp.id = itemList.size();
                            temp.level = parser.getDepth();
                            ViewItem vi = getLastTopLevelNode(itemList, temp.level - 1);
                            temp.parentId = (vi == null ? NO_PARENT : vi.id);
                            itemList.add(temp);
                        }
                        break;
                }
                eventType = parser.next();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return itemList;
    }
 
开发者ID:w568w,项目名称:fuckView,代码行数:53,代码来源:ViewDumper.java

示例11: createAnimationFromXml

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static Animation createAnimationFromXml(Context c, XmlPullParser parser,
                                                AnimationSet parent, AttributeSet attrs) throws XmlPullParserException, IOException {

    Animation anim = null;

    // Make sure we are on a start tag.
    int type;
    int depth = parser.getDepth();

    while (((type=parser.next()) != XmlPullParser.END_TAG || parser.getDepth() > depth)
            && type != XmlPullParser.END_DOCUMENT) {

        if (type != XmlPullParser.START_TAG) {
            continue;
        }

        String  name = parser.getName();

        if (name.equals("set")) {
            anim = new AnimationSet(c, attrs);
            createAnimationFromXml(c, parser, (AnimationSet)anim, attrs);
        } else if (name.equals("alpha")) {
            anim = new AlphaAnimation(c, attrs);
        } else if (name.equals("scale")) {
            anim = new ScaleAnimation(c, attrs);
        }  else if (name.equals("rotate")) {
            anim = new RotateAnimation(c, attrs);
        }  else if (name.equals("translate")) {
            anim = new TranslateAnimation(c, attrs);
        } else {
            try {
                anim = (Animation) Class.forName(name).getConstructor(Context.class, AttributeSet.class).newInstance(c, attrs);
            } catch (Exception te) {
                throw new RuntimeException("Unknown animation name: " + parser.getName() + " error:" + te.getMessage());
            }
        }

        if (parent != null) {
            parent.addAnimation(anim);
        }
    }

    return anim;

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:46,代码来源:OptAnimationLoader.java

示例12: event

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public void event(XmlPullParser var1) throws XmlPullParserException, IOException {
   int var2 = var1.getEventType();
   switch(var2) {
   case 0:
      Boolean var3 = (Boolean)var1.getProperty("http://xmlpull.org/v1/doc/features.html#xmldecl-standalone");
      this.startDocument(var1.getInputEncoding(), var3);
      break;
   case 1:
      this.endDocument();
      break;
   case 2:
      this.writeStartTag(var1);
      break;
   case 3:
      this.endTag(var1.getNamespace(), var1.getName());
      break;
   case 4:
      if(var1.getDepth() > 0) {
         this.text(var1.getText());
      } else {
         this.ignorableWhitespace(var1.getText());
      }
      break;
   case 5:
      this.cdsect(var1.getText());
      break;
   case 6:
      this.entityRef(var1.getName());
      break;
   case 7:
      String var4 = var1.getText();
      this.ignorableWhitespace(var4);
      break;
   case 8:
      this.processingInstruction(var1.getText());
      break;
   case 9:
      this.comment(var1.getText());
      break;
   case 10:
      this.docdecl(var1.getText());
   }

}
 
开发者ID:imkiva,项目名称:AndroidApktool,代码行数:45,代码来源:StaticXmlSerializerWrapper.java

示例13: inflateDrawable

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
@Override
protected Drawable inflateDrawable(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException {
    final int innerDepth = parser.getDepth() + 1;
    int type;
    int depth;
    int layerAttrUseCount = 0;
    int drawableUseCount = 0;
    int space = STEP << 1;
    //L,T,R,B,S,E,id
    int[][] childLayersAttrs = new int[space][ATTRS.length];
    Drawable[] drawables = new Drawable[space];

    while ((type = parser.next()) != XmlPullParser.END_DOCUMENT
            && ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) {
        if (type != XmlPullParser.START_TAG) {
            continue;
        }

        if (depth > innerDepth || !parser.getName().equals("item")) {
            continue;
        }

        if (layerAttrUseCount >= childLayersAttrs.length) {
            int[][] dstInt = new int[drawables.length + STEP][ATTRS.length];
            System.arraycopy(childLayersAttrs, 0, dstInt, 0, childLayersAttrs.length);
            childLayersAttrs = dstInt;
        }
        updateLayerAttrs(context, attrs, childLayersAttrs[layerAttrUseCount]);
        layerAttrUseCount++;

        Drawable drawable = getAttrDrawable(context, attrs, android.R.attr.drawable);

        // If the layer doesn't have a drawable or unresolved theme
        // attribute for a drawable, attempt to parse one from the child
        // element.
        if (drawable == null) {
            while ((type = parser.next()) == XmlPullParser.TEXT) {
            }
            if (type != XmlPullParser.START_TAG) {
                throw new XmlPullParserException(parser.getPositionDescription()
                        + ": <item> tag requires a 'drawable' attribute or "
                        + "child tag defining a drawable");
            }
            drawable = createFromXmlInner(context, parser, attrs);
        } else {
            final ColorStateList cls = getTintColorList(context, attrs, R.attr.drawableTint);
            if (cls != null) {
                drawable = ThemeUtils.tintDrawable(drawable, cls, getTintMode(context, attrs, R.attr.drawableTintMode));
            }
        }

        if (drawable != null) {
            if (drawableUseCount >= drawables.length) {
                Drawable[] dst = new Drawable[drawables.length + STEP];
                System.arraycopy(drawables, 0, dst, 0, drawables.length);
                drawables = dst;
            }
            drawables[drawableUseCount] = drawable;
            drawableUseCount++;
        }
    }

    if (drawables[0] == null || drawableUseCount != layerAttrUseCount) {
        return null;
    } else {
        LayerDrawable layerDrawable = new LayerDrawable(drawables);
        for (int i = 0; i < drawables.length; i++) {
            int[] childLayersAttr = childLayersAttrs[i];
            if (childLayersAttr[0] != 0 || childLayersAttr[1] != 0 || childLayersAttr[2] != 0 || childLayersAttr[3] != 0) {
                layerDrawable.setLayerInset(i, childLayersAttr[0], childLayersAttr[1], childLayersAttr[2], childLayersAttr[3]);
            }
            if (childLayersAttr[4] != 0) {
                layerDrawable.setId(i, childLayersAttr[4]);
            }
        }
        return layerDrawable;
    }
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:79,代码来源:LayerDrawableUtils.java

示例14: getValueForPath

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
/**
 * Retrieves the value of an XPath from an XML stream.
 */
private static String getValueForPath(String xpath, Reader xml) throws XmlPullParserException, IOException
{
	XmlPullParser parser = new MXParser();
	parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
	parser.setInput(xml);

	int depth = 1;
	String[] splits = xpath.split("/");

	int event = parser.getEventType();
	while( event != XmlPullParser.END_DOCUMENT )
	{
		if( event == XmlPullParser.START_TAG && parser.getDepth() == depth )
		{
			String[] elemNames = splits[depth - 1].split("\\|");
			for( int i = 0; i < elemNames.length; i++ )
			{
				if( parser.getName().equals(elemNames[i]) )
				{
					if( depth == splits.length )
					{
						if( parser.next() == XmlPullParser.TEXT )
						{
							return parser.getText();
						}
						else
						{
							return null;
						}
					}
					else
					{
						depth++;
					}
				}
			}
		}
		event = parser.next();
	}

	return null;
}
 
开发者ID:equella,项目名称:Equella,代码行数:46,代码来源:IMSUtilities.java


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