當前位置: 首頁>>代碼示例>>Java>>正文


Java XmlPullParser.nextToken方法代碼示例

本文整理匯總了Java中org.xmlpull.v1.XmlPullParser.nextToken方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlPullParser.nextToken方法的具體用法?Java XmlPullParser.nextToken怎麽用?Java XmlPullParser.nextToken使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.xmlpull.v1.XmlPullParser的用法示例。


在下文中一共展示了XmlPullParser.nextToken方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: lenientNextToken

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
static int lenientNextToken(XmlPullParser xpp) throws IOException, XmlPullParserException {
    try {
        return xpp.nextToken();
    } catch (XmlPullParserException e) {
        return xpp.getEventType();
    }
}
 
開發者ID:kalikov,項目名稱:lighthouse,代碼行數:8,代碼來源:AbstractLayoutParser.java

示例2: readFromXml

import org.xmlpull.v1.XmlPullParser; //導入方法依賴的package包/類
public void readFromXml(XmlPullParser parser)
{
    clear();
    try
    {
        // On android version < 11, the standard XmlPullParser implementation has a bug:
        // it throws a UnsupportedOperationException at getting CDSECT using nextToken().
        // Therefore, XmlPullParserFactory.newInstance().newPullParser() shall be used
        // to create parser instance in order to get it worked on Android versions 8-10.
        final String type = parser.getAttributeValue(null, XML_PROP_IMAGE_TYPE);
        if (type == null)
        {
            throw new Exception("image type is unknown");
        }
        final int event = parser.nextToken();
        if (event == XmlPullParser.CDSECT)
        {
            final String imageText = parser.getText();
            if (imageText == null || imageText.length() == 0)
            {
                throw new Exception("empty CDSECT");
            }
            byte[] imageDecoded = Base64.decode(imageText, BASE64_OPTIONS);
            if (imageDecoded == null)
            {
                throw new Exception("cannot decode image, string lenght = " + imageText.length());
            }
            if (XML_PROP_IMAGE_PNG.equalsIgnoreCase(type))
            {
                ByteArrayInputStream imageStream = new ByteArrayInputStream(imageDecoded);
                setBitmap(BitmapFactory.decodeStream(imageStream));
                imageStream.close();
            }
            else if (XML_PROP_IMAGE_SVG.equalsIgnoreCase(type))
            {
                setSvg(new String(imageDecoded));
            }
        }
        else
        {
            throw new Exception("CDSECT is not found");
        }
    }
    catch (Exception e)
    {
        ViewUtils.Debug(this, e.getLocalizedMessage());
    }
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:49,代碼來源:CustomImageView.java


注:本文中的org.xmlpull.v1.XmlPullParser.nextToken方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。