Java 类org.xmlpull.v1.XmlPullParserFactory 实例源码

项目:directory-ldap-api    文件:Dsmlv2Parser.java   
/**
 * Creates a new instance of Dsmlv2Parser.
 *
 * @param storeMsgInBatchReq flag to set if the parsed requests should b stored
 * @throws XmlPullParserException if an error occurs during the initialization of the parser
 */
public Dsmlv2Parser( boolean storeMsgInBatchReq ) throws XmlPullParserException
{
    this.storeMsgInBatchReq = storeMsgInBatchReq;

    this.grammar = new Dsmlv2Grammar();
    this.container = new Dsmlv2Container( grammar.getLdapCodecService() );

    this.container.setGrammar( grammar );

    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware( true );
    XmlPullParser xpp = factory.newPullParser();

    container.setParser( xpp );
}
项目:IconPackParser-Android    文件:XmlPullParserGenerator.java   
public static XmlPullParser getXmlPullParser(Resources resources, String packageName, String file) throws XMLNotFoundException, XmlPullParserException {

        XmlPullParser xpp = null;

        int xmlId = resources.getIdentifier(file, DEF_XML, packageName);

        if (xmlId > 0) {
            xpp = resources.getXml(xmlId);
        } else {
            // no resource found, try to open it from assets folder
            try {
                InputStream appfilterstream = resources.getAssets().open(file + EXT_XML);

                XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
                factory.setNamespaceAware(true);
                xpp = factory.newPullParser();
                xpp.setInput(appfilterstream, UTF_8);
            } catch (IOException e) {
                throw new XMLNotFoundException(file + EXT_XML, e);
            }
        }
        return xpp;
    }
项目:boohee_v5.6    文件:k.java   
private void i() {
    XmlPullParser newPullParser;
    InputStream open;
    try {
        XmlPullParserFactory newInstance = XmlPullParserFactory.newInstance();
        newInstance.setNamespaceAware(true);
        newPullParser = newInstance.newPullParser();
        open = this.b.getAssets().open("ShareSDK.xml");
    } catch (Throwable th) {
        Ln.e(th);
        return;
    }
    newPullParser.setInput(open, Constants.UTF_8);
    for (int eventType = newPullParser.getEventType(); eventType != 1; eventType = newPullParser.next()) {
        if (eventType == 2) {
            String name = newPullParser.getName();
            HashMap hashMap = new HashMap();
            int attributeCount = newPullParser.getAttributeCount();
            for (eventType = 0; eventType < attributeCount; eventType++) {
                hashMap.put(newPullParser.getAttributeName(eventType), newPullParser.getAttributeValue(eventType).trim());
            }
            this.c.put(name, hashMap);
        }
    }
    open.close();
}
项目:lighthouse    文件:PodcastsLayoutParser.java   
Podcasts parse(InputStream input, @Nullable String charset, String baseUri) throws IOException {
    try {
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        factory.setValidating(false);

        XmlPullParser xpp = factory.newPullParser();
        xpp.setInput(input, charset);

        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                String tag = xpp.getName();
                if (LayoutUtils.isDiv(tag) && hasClass(xpp, PODCAST_LIST_CLASS)) {
                    return parsePodcasts(xpp, NetworkUtils.toOptURI(baseUri));
                }
            }
            eventType = lenientNext(xpp);
        }
        return new Podcasts();
    } catch (XmlPullParserException e) {
        throw new IOException(e);
    }
}
项目:android-apkbox    文件:ApkManifestParser.java   
/**
 * get application name
 *
 * @param apkPath apkPath
 * @return String
 */
public static String getApplicationName(String apkPath) {
    if (apkPath == null || "".equals(apkPath)) {
        return null;
    }
    try {
        ZipFile zipFile = new ZipFile(new File(apkPath), ZipFile.OPEN_READ);
        ZipEntry manifestXmlEntry = zipFile.getEntry(ApkManifestReader.DEFAULT_XML);
        String manifestXML = ApkManifestReader.getManifestXMLFromAPK(zipFile, manifestXmlEntry);
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        XmlPullParser parser = factory.newPullParser();
        parser.setInput(new StringReader(manifestXML));
        String applicationName = parseApplicationNameByManifest(parser);
        return applicationName;
    } catch (Exception e1) {
    }
    return "";
}
项目:aos-MediaLib    文件:XMLRPCServer.java   
XmlPullParser xmlPullParserFromSocket(InputStream socketInputStream) throws IOException, XmlPullParserException {

    String line;
    StringBuilder xmlRpcText = new StringBuilder();
    BufferedReader br = new BufferedReader(new InputStreamReader(socketInputStream));
    while ((line = br.readLine()) != null && line.length() > 0); // eat the HTTP POST headers
    while (br.ready())
        xmlRpcText.append(br.readLine());
    // Log.d(Tag.LOG, "xml received:" + xmlRpcText.toString());

    InputStream inputStream = new ByteArrayInputStream(xmlRpcText.toString().getBytes("UTF-8"));
    XmlPullParser pullParser = XmlPullParserFactory.newInstance().newPullParser();
    Reader streamReader = new InputStreamReader(inputStream);
    pullParser.setInput(streamReader);
    return pullParser;
}
项目:starcor.xul    文件:XulDebugMonitor.java   
public boolean getItemContent(final int itemId, final XulHttpServer.XulHttpServerRequest request, final XulHttpServer.XulHttpServerResponse response) {
    return execUiOpAndWait(itemId, new UiOpRunnable() {
        @Override
        boolean beginExec() {
            return !(_xulPage == null && _xulView == null);
        }

        @Override
        protected void exec(PageInfo pageInfo, XulPage xulPage, XulView xulView) throws Exception {
            if (xulView == null) {
                xulView = xulPage.getLayout();
            }

            XmlPullParserFactory xmlPullParserFactory = XmlPullParserFactory.newInstance();
            XmlSerializer writer = xmlPullParserFactory.newSerializer();
            writer.setOutput(response.getBodyStream(), "utf-8");

            writer.startDocument("utf-8", Boolean.TRUE);
            dumpItem(xulView, writer, request.queries);

            writer.endDocument();
            writer.flush();
        }
    });
}
项目:ararat    文件:SimpleXmlParser.java   
protected void parseXml(InputStream inputStream)
        throws XmlPullParserException, IOException
{
    mStack.clear();

    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware(false);

    XmlPullParser parser = factory.newPullParser();
    parser.setInput(inputStream, "UTF-8");
    parser.setFeature(Xml.FEATURE_RELAXED, true);

    int eventType = parser.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
        if (eventType == XmlPullParser.START_TAG) {
            mStack.push(parser.getName());
            onStartElement(new SimpleXmlPath(mStack), parser);
        } else if (eventType == XmlPullParser.END_TAG) {
            mStack.pop();
        } else if (eventType == XmlPullParser.TEXT) {
            onTextContent(new SimpleXmlPath(mStack), parser.getText());
        }

        eventType = parser.next();
    }
}
项目:Stringlate    文件:Resources.java   
public static Resources fromFile(final File file) {
    Resources result = new Resources(file);

    if (file.isFile()) {
        InputStream is = null;
        try {
            is = new FileInputStream(file);
            // Load the resources from the XML into our resulting Resources
            final XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
            ResourcesParser.loadFromXml(is, result, parser);
        } catch (IOException | XmlPullParserException e) {
            e.printStackTrace();
        } finally {
            try {
                if (is != null)
                    is.close();
            } catch (IOException ignored) {
            }
        }
    }

    // If loading went okay, the resources will have been loaded into the result
    return result;
}
项目:Stringlate    文件:Resources.java   
public boolean save() {
    if (mSavedChanges)
        return true;

    if (mFile == null)
        return false;

    try {
        if (!mFile.getParentFile().isDirectory())
            mFile.getParentFile().mkdirs();

        FileOutputStream out = new FileOutputStream(mFile);
        final XmlSerializer serializer = XmlPullParserFactory.newInstance().newSerializer();
        mSavedChanges = ResourcesParser.parseToXml(this, out, serializer);
        mModified = true;
        out.close();
    } catch (IOException | XmlPullParserException e) {
        e.printStackTrace();
    }
    // We do not want empty files, if it exists and it's empty delete it
    if (mFile.isFile() && mFile.length() == 0)
        mFile.delete();

    return mFile.isFile();
}
项目:XmlToJson    文件:XmlToJson.java   
private
@Nullable
JSONObject convertToJSONObject() {
    try {
        Tag parentTag = new Tag("", "xml");

        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(false);   // tags with namespace are taken as-is ("namespace:tagname")
        XmlPullParser xpp = factory.newPullParser();

        setInput(xpp);

        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.START_DOCUMENT) {
            eventType = xpp.next();
        }
        readTags(parentTag, xpp);

        unsetInput();

        return convertTagToJson(parentTag, false);
    } catch (XmlPullParserException | IOException e) {
        e.printStackTrace();
        return null;
    }
}
项目:PhoneChat    文件:AsyncKmlParser.java   
public AsyncKmlParser(Activity activity, GoogleMaps mapCtrl, String kmlId, CallbackContext callbackContext, Bundle option) {
  this.kmlId = kmlId;
  mCallback = callbackContext;
  mMapCtrl = mapCtrl;
  mActivity = activity;
  mOption = option;
  if (option.containsKey("preserveViewport")) {
    preserveViewport = option.getBoolean("preserveViewport");
  }
  if (option.containsKey("animation")) {
    animation = option.getBoolean("animation");
  }

  mProgress = ProgressDialog.show(activity, "", "Please wait...", false);
  start = System.currentTimeMillis();

  try {
    parser = XmlPullParserFactory.newInstance().newPullParser();
  } catch (Exception e) {
    e.printStackTrace();
    callbackContext.error(e.toString());
  }
}
项目:WechatLuckyMoney    文件:XmlToJson.java   
private
@Nullable
JSONObject convertToJSONObject() {
    try {
        Tag parentTag = new Tag("", "xml");

        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(false);   // tags with namespace are taken as-is ("namespace:tagname")
        XmlPullParser xpp = factory.newPullParser();

        setInput(xpp);

        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.START_DOCUMENT) {
            eventType = xpp.next();
        }
        readTags(parentTag, xpp);

        unsetInput();

        return convertTagToJson(parentTag, false);
    } catch (XmlPullParserException | IOException e) {
        e.printStackTrace();
        return null;
    }
}
项目:osmapi    文件:XmlWriter.java   
@Override
public final void write(OutputStream out) throws IOException
{
    try
    {
        xml = XmlPullParserFactory.newInstance().newSerializer();
    }
    catch(XmlPullParserException e)
    {
        throw new RuntimeException("Cannot initialize serializer", e);
    }
    xml.setOutput(out, CHARSET);
    xml.startDocument(CHARSET, null);

    write();

    if(xml.getName() != null)
    {
        throw new IllegalStateException("Forgot to close a tag");
    }

    xml.endDocument();
    xml.flush();
}
项目:nmud    文件:MainActivity.java   
void doLoadLocalMap(final String path) {
    new Thread(){

        @Override
        public void run() {
            try {
                XmlPullParserFactory factory = XmlPullParserFactory.newInstance();

                XmlPullParser xpp = factory.newPullParser();
                xpp.setInput(new InputStreamReader(new FileInputStream(new File(path)), "UTF-8"));
                xpp.next();


                ObjectsLocalActivity.domainEntity = (DomainEntity) DomainUtils.recursiveEntityReading(xpp);
                ObjectsLocalActivity.domainLocalPath = path;
                postConnInfo("Domain entity successfully loaded");
            } catch (XmlPullParserException | IOException e) {
                postConnInfo("" + e);
            }
        }

    }.start();
}
项目:mConference-Framework    文件:IndexParser.java   
public static ArrayList<ConferenceMeta> parseIndex() throws XmlPullParserException, IOException {

        conferences = new ArrayList<>();

        pullParserFactory = XmlPullParserFactory.newInstance();
        XmlPullParser parser = pullParserFactory.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);

        Log.d("Parse", "parse");
        URL url = new URL(INDEX_FILE_URL);
        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
        InputStream inputStream = null;

        try {
            inputStream = new BufferedInputStream(urlConnection.getInputStream());
            parser.setInput(inputStream, null);
            readIndex(parser);
        } finally {
            urlConnection.disconnect();
            inputStream.close();
        }

        return conferences;
    }
项目:ChannelSurfer    文件:XMLTVParser.java   
public static List<Program> parse(String in) throws XmlPullParserException, IOException {
        try {
            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            factory.setNamespaceAware(true);
            XmlPullParser xpp = factory.newPullParser();
            Log.d(TAG, "Start parsing");
            Log.d(TAG, in.substring(0, 36));
            xpp.setInput(new StringReader(in));
            int eventType = xpp.getEventType();
            Log.d(TAG, eventType+"");
//            if(eventType == XmlPullParser.START_DOCUMENT)
//                xpp.next();
            /*
            xpp.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
            xpp.setInput(new InputStreamReader(in));*/
            /*xpp.nextTag();
            xpp.nextTag();
            */return readFeed(xpp);
        } finally {
//            in.close();
        }
    }
项目:luckymoney    文件:GhostLuckyMoney.java   
private String readxml(String xmlstr) {
    int i = xmlstr.indexOf("<msg>");
    String xml = xmlstr.substring(i);
    String keyurl = "";
    try {
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        XmlPullParser xpp = factory.newPullParser();
        xpp.setInput(new StringReader(xml));
        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                if (xpp.getName().equals("nativeurl")) {
                    xpp.nextToken();
                    keyurl = xpp.getText();
                    break;
                }
            }
            eventType = xpp.next();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return keyurl;
}
项目:Smack    文件:PacketParserUtils.java   
/**
 * Creates a new XmlPullParser suitable for parsing XMPP. This means in particular that
 * FEATURE_PROCESS_NAMESPACES is enabled.
 * <p>
 * Note that not all XmlPullParser implementations will return a String on
 * <code>getText()</code> if the parser is on START_TAG or END_TAG. So you must not rely on this
 * behavior when using the parser.
 * </p>
 * 
 * @return A suitable XmlPullParser for XMPP parsing
 * @throws XmlPullParserException
 */
public static XmlPullParser newXmppParser() throws XmlPullParserException {
    XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
    if (XML_PULL_PARSER_SUPPORTS_ROUNDTRIP) {
        try {
            parser.setFeature(FEATURE_XML_ROUNDTRIP, true);
        }
        catch (XmlPullParserException e) {
            LOGGER.log(Level.SEVERE,
                            "XmlPullParser does not support XML_ROUNDTRIP, although it was first determined to be supported",
                            e);
        }
    }
    return parser;
}
项目:Smack    文件:SmackInitialization.java   
public static void processConfigFile(InputStream cfgFileStream,
                Collection<Exception> exceptions, ClassLoader classLoader) throws Exception {
    XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
    parser.setInput(cfgFileStream, "UTF-8");
    int eventType = parser.getEventType();
    do {
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("startupClasses")) {
                parseClassesToLoad(parser, false, exceptions, classLoader);
            }
            else if (parser.getName().equals("optionalStartupClasses")) {
                parseClassesToLoad(parser, true, exceptions, classLoader);
            }
        }
        eventType = parser.next();
    }
    while (eventType != XmlPullParser.END_DOCUMENT);
    try {
        cfgFileStream.close();
    }
    catch (IOException e) {
        LOGGER.log(Level.SEVERE, "Error while closing config file input stream", e);
    }
}
项目:Smack    文件:Macros.java   
public MacroGroup parseMacroGroups(String macros) throws XmlPullParserException, IOException {

            MacroGroup group = null;
            XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
            parser.setInput(new StringReader(macros));
            int eventType = parser.getEventType();
            while (eventType != XmlPullParser.END_DOCUMENT) {       
                eventType = parser.next();
                 if (eventType == XmlPullParser.START_TAG) {
                        if (parser.getName().equals("macrogroup")) {
                            group = parseMacroGroup(parser);
                        }
                 }
            }
            return group;
        }
项目:ODK-Liberia    文件:XmlParserUtils.java   
/**
 * This method returns an xml parser fed by the first existing file found from the path send as parameters.
 */
public static XmlPullParserHolder getXMLFile(String... filenames) throws XmlPullParserException, FileNotFoundException {
    if (filenames != null) {
        for (String filename : filenames) {
            // get a reference to the file.
            File file = new File(filename);
            if (file.exists()) {
                // if the file exists than we create the parser and return the instance
                XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
                factory.setNamespaceAware(true);
                XmlPullParser xpp = factory.newPullParser();

                // create an input stream to be read by the stream reader.
                FileInputStream fis = new FileInputStream(file);

                // set the input for the parser using an InputStreamReader
                xpp.setInput(new InputStreamReader(fis));
                return new XmlPullParserHolder(xpp, fis);
            }
            // If the file was not found than continue to iterate until all paths are checked
        }
    }

    // If there is no file found then throw an exception
    throw new FileNotFoundException("No XML file was found to load");
}
项目:mindraider    文件:Resource.java   
/**
 * To XML.
 *
 * @param outputStream
 *            the output stream.
 * @throws Exception
 *             a generic exception.
 */
public void toXml(OutputStream outputStream) throws Exception {
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    XmlSerializer xs = factory.newSerializer();
    xs
            .setProperty(
                    "http://xmlpull.org/v1/doc/properties.html#serializer-indentation",
                    "  ");

    xs.setOutput(outputStream, "UTF-8");

    // first write XML declaration
    xs.startDocument("UTF-8", null);
    // add some empty lines before first start tag
    xs.ignorableWhitespace("\n");

    toXml(xs);

    xs.endDocument();
}
项目:picframe    文件:ShareXMLParser.java   
/**
 * Parse is as response of Share API
 * @param is
 * @return List of ShareRemoteFiles
 * @throws XmlPullParserException
 * @throws IOException
 */
public ArrayList<OCShare> parseXMLResponse(InputStream is) throws XmlPullParserException, IOException {

    try {
        // XMLPullParser
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);

        XmlPullParser parser = Xml.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(is, null);
        parser.nextTag();
        return readOCS(parser);

    } finally {
        is.close();
    }
}
项目:picframe    文件:InvalidCharacterExceptionParser.java   
/**
 * Parse is as an Invalid Path Exception
 * @param is
 * @return if The exception is an Invalid Char Exception
 * @throws XmlPullParserException
 * @throws IOException
 */
public boolean parseXMLResponse(InputStream is) throws XmlPullParserException,
           IOException {
       boolean result = false;

    try {
        // XMLPullParser
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);

        XmlPullParser parser = Xml.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(is, null);
        parser.nextTag();
        result = readError(parser);

    } finally {
        is.close();
    }
    return result;
}
项目:awesomeguy    文件:InitBackground.java   
public boolean setXmlPullParser(boolean mLookForXml) throws XmlPullParserException, IOException{
    if (!mLookForXml) {
        mXpp = mContext.getResources().getXml(R.xml.awesomeguy);
    }
    else {

       XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
       factory.setNamespaceAware(true);
       mXpp = factory.newPullParser();  
       File sdcard = Environment.getExternalStorageDirectory();
       //Log.e("XML", sdcard.getAbsolutePath());
       int BUFFER_SIZE = 8192;


       File mFileInput = new File(sdcard, SDCARD_FILE);

       FileReader mReader = new FileReader(mFileInput);

       BufferedReader in = new BufferedReader(mReader,BUFFER_SIZE);

       mXpp.setInput(in);

    }
    return true;
}
项目:PhotoGalleryPlusPlus    文件:FlickrFetchr.java   
private ArrayList<Photo> downloadGalleryItems(String url) {
    ArrayList<Photo> items = new ArrayList<>();
    try {
        String xmlString = getUrl(url);
        Timber.i("Received xml: " + xmlString);
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        XmlPullParser parser = factory.newPullParser();
        parser.setInput(new StringReader(xmlString));
        parseItems(items, parser);
    } catch (IOException ioe) {
        Timber.e("Failed to fetch items", ioe);
    } catch (XmlPullParserException xppe) {
        Timber.e("Failed to parse items", xppe);
    }
    return items;
}
项目:androidPN-client.    文件:Macros.java   
public MacroGroup parseMacroGroups(String macros) throws Exception {

            MacroGroup group = null;
            XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
            parser.setInput(new StringReader(macros));
            int eventType = parser.getEventType();
            while (eventType != XmlPullParser.END_DOCUMENT) {       
                eventType = parser.next();
                 if (eventType == XmlPullParser.START_TAG) {
                        if (parser.getName().equals("macrogroup")) {
                            group = parseMacroGroup(parser);
                        }
                 }
            }
            return group;
        }
项目:androidPN-client.    文件:BodyParserXmlPull.java   
/**
 * Gets a XmlPullParser for use in parsing incoming messages.
 *
 * @return parser instance
 */
private static XmlPullParser getXmlPullParser() {
    SoftReference<XmlPullParser> ref = XPP_PARSER.get();
    XmlPullParser result = ref.get();
    if (result == null) {
        Exception thrown;
        try {
            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            factory.setNamespaceAware(true);
            factory.setValidating(false);
            result = factory.newPullParser();
            ref = new SoftReference<XmlPullParser>(result);
            XPP_PARSER.set(ref);
            return result;
        } catch (Exception ex) {
            thrown = ex;
        }
        throw(new IllegalStateException(
                "Could not create XmlPull parser", thrown));
    } else {
        return result;
    }
}
项目:neo4art    文件:AsyncKmlParser.java   
public AsyncKmlParser(Activity activity, GoogleMaps mapCtrl, String kmlId, CallbackContext callbackContext, Bundle option) {
  this.kmlId = kmlId;
  mCallback = callbackContext;
  mMapCtrl = mapCtrl;
  mActivity = activity;
  mOption = option;
  if (option.containsKey("preserveViewport")) {
    preserveViewport = option.getBoolean("preserveViewport");
  }
  if (option.containsKey("animation")) {
    animation = option.getBoolean("animation");
  }

  mProgress = ProgressDialog.show(activity, "", "Please wait...", false);
  start = System.currentTimeMillis();

  try {
    parser = XmlPullParserFactory.newInstance().newPullParser();
  } catch (Exception e) {
    e.printStackTrace();
    callbackContext.error(e.toString());
  }
}
项目:neo4art    文件:AsyncKmlParser.java   
public AsyncKmlParser(Activity activity, GoogleMaps mapCtrl, String kmlId, CallbackContext callbackContext, Bundle option) {
  this.kmlId = kmlId;
  mCallback = callbackContext;
  mMapCtrl = mapCtrl;
  mActivity = activity;
  mOption = option;
  if (option.containsKey("preserveViewport")) {
    preserveViewport = option.getBoolean("preserveViewport");
  }
  if (option.containsKey("animation")) {
    animation = option.getBoolean("animation");
  }

  mProgress = ProgressDialog.show(activity, "", "Please wait...", false);
  start = System.currentTimeMillis();

  try {
    parser = XmlPullParserFactory.newInstance().newPullParser();
  } catch (Exception e) {
    e.printStackTrace();
    callbackContext.error(e.toString());
  }
}
项目:neo4art    文件:AsyncKmlParser.java   
public AsyncKmlParser(Activity activity, GoogleMaps mapCtrl, String kmlId, CallbackContext callbackContext, Bundle option) {
  this.kmlId = kmlId;
  mCallback = callbackContext;
  mMapCtrl = mapCtrl;
  mActivity = activity;
  mOption = option;
  if (option.containsKey("preserveViewport")) {
    preserveViewport = option.getBoolean("preserveViewport");
  }
  if (option.containsKey("animation")) {
    animation = option.getBoolean("animation");
  }

  mProgress = ProgressDialog.show(activity, "", "Please wait...", false);
  start = System.currentTimeMillis();

  try {
    parser = XmlPullParserFactory.newInstance().newPullParser();
  } catch (Exception e) {
    e.printStackTrace();
    callbackContext.error(e.toString());
  }
}
项目:Flickr-Photos    文件:FlickrUtils.java   
/**
     * Get a list of photo item
     * @param url photo item
     * @return a photo list
     */
    public static ArrayList<Photo> fetchPhotos(String url){
        Log.d(TAG, "fetchPhotos");
        ArrayList<Photo> _photos = new ArrayList<>();
        try{
            String _xmlString = getUrl(url);
//            Log.i(TAG, "Get the items: " + _xmlString);


            /**Create a xmlPullParser*/
            XmlPullParserFactory _factory = XmlPullParserFactory.newInstance();
            XmlPullParser _xmlPullParser = _factory.newPullParser();
            _xmlPullParser.setInput(new StringReader(_xmlString));

            parsePhotos(_photos, _xmlPullParser);                       /**Parser the xml String*/


        } catch (XmlPullParserException e){
            e.printStackTrace();
        } catch (IOException e2) {
            // TODO: handle exception
        }

        return _photos;
    }
项目:Flickr-Photos    文件:FlickrUtils.java   
/**
     * Get a list of group
     * @param url group url
     * @return a group list
     */
    public static ArrayList<Group> fetchGroups(String url){

        ArrayList<Group> _groups = new ArrayList<>();
        try{
            String _xmlString = getUrl(url);
//            Log.i(TAG, "Get the items: " + _xmlString);


            /**Create a xmlPullParser*/
            XmlPullParserFactory _factory = XmlPullParserFactory.newInstance();
            XmlPullParser _xmlPullParser = _factory.newPullParser();
            _xmlPullParser.setInput(new StringReader(_xmlString));

            parseGroups(_groups, _xmlPullParser);                       /**Parser the xml String*/


        } catch (XmlPullParserException e){
            e.printStackTrace();
        } catch (IOException e2) {
            // TODO: handle exception
        }

        return _groups;
    }
项目:Flickr-Photos    文件:FlickrUtils.java   
/**
 * Get a list of galleries
 * @param url  url
 * @return gallery list
 */
public static ArrayList<Gallery> fetchGalleries(String url){
    ArrayList<Gallery> _galleries = new ArrayList<>();
    try{
        String _xmlString = getUrl(url);


        /**Create a xmlPullParser*/
        XmlPullParserFactory _factory = XmlPullParserFactory.newInstance();
        XmlPullParser _xmlPullParser = _factory.newPullParser();
        _xmlPullParser.setInput(new StringReader(_xmlString));

        parseGalleries(_galleries, _xmlPullParser);                       /**Parser the xml String*/


    } catch (XmlPullParserException e){
        e.printStackTrace();
    } catch (IOException e2) {
        // TODO: handle exception
    }

    return _galleries;
}
项目:Flickr-Photos    文件:FlickrUtils.java   
/**
     * A method to get a list of photoset
     * @param url  url
     * @return  a list of photoset
     */
    public static ArrayList<Photoset> fetchPhotosets(String url){
        ArrayList<Photoset> _photosets = new ArrayList<>();
        try{
            String _xmlString = getUrl(url);
//            Log.i(TAG, "Get the items: " + _xmlString);


            /**Create a xmlPullParser*/
            XmlPullParserFactory _factory = XmlPullParserFactory.newInstance();
            XmlPullParser _xmlPullParser = _factory.newPullParser();
            _xmlPullParser.setInput(new StringReader(_xmlString));

            parsePhotosets(_photosets, _xmlPullParser);                       /**Parser the xml String*/


        } catch (XmlPullParserException e){
            e.printStackTrace();
        } catch (IOException e2) {
            // TODO: handle exception
        }

        return _photosets;
    }
项目:Flickr-Photos    文件:FlickrUtils.java   
/**
     * A method to get a people
     * @param url url
     * @return a people
     */
    public static People fetchPeople(String url){
        People _people = new People();

        try{
            String _xmlString = getUrl(url);
//            Log.i(TAG, "Get the items: " + _xmlString);


            /**Create a xmlPullParser*/
            XmlPullParserFactory _factory = XmlPullParserFactory.newInstance();
            XmlPullParser _xmlPullParser = _factory.newPullParser();
            _xmlPullParser.setInput(new StringReader(_xmlString));

            parsePeople(_people, _xmlPullParser);                       /**Parser the xml String*/


        } catch (XmlPullParserException e){
            e.printStackTrace();
        } catch (IOException e2) {
            // TODO: handle exception
        }

        return _people;
    }
项目:Flickr-Photos    文件:FlickrUtils.java   
/**
     * A method to a photo's comments
     * @param url url
     * @return a list of comment
     */
    public static ArrayList<Comment> fetchComments(String url){
        ArrayList<Comment> _comments = new ArrayList<>();
        try{
            String _xmlString = getUrl(url);
//            Log.i(TAG, "Get the items: " + _xmlString);


            /**Create a xmlPullParser*/
            XmlPullParserFactory _factory = XmlPullParserFactory.newInstance();
            XmlPullParser _xmlPullParser = _factory.newPullParser();
            _xmlPullParser.setInput(new StringReader(_xmlString));

            parseComments(_comments, _xmlPullParser);                       /**Parser the xml String*/


        } catch (XmlPullParserException e){
            e.printStackTrace();
        } catch (IOException e2) {
            // TODO: handle exception
        }

        return _comments;
    }
项目:q-mail    文件:SettingsImporter.java   
@VisibleForTesting
static Imported parseSettings(InputStream inputStream, boolean globalSettings, List<String> accountUuids,
        boolean overview) throws SettingsImportExportException {

    if (!overview && accountUuids == null) {
        throw new IllegalArgumentException("Argument 'accountUuids' must not be null.");
    }

    try {
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        //factory.setNamespaceAware(true);
        XmlPullParser xpp = factory.newPullParser();

        InputStreamReader reader = new InputStreamReader(inputStream);
        xpp.setInput(reader);

        Imported imported = null;
        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                if (SettingsExporter.ROOT_ELEMENT.equals(xpp.getName())) {
                    imported = parseRoot(xpp, globalSettings, accountUuids, overview);
                } else {
                    Timber.w("Unexpected start tag: %s", xpp.getName());
                }
            }
            eventType = xpp.next();
        }

        if (imported == null || (overview && imported.globalSettings == null && imported.accounts == null)) {
            throw new SettingsImportExportException("Invalid import data");
        }

        return imported;
    } catch (Exception e) {
        throw new SettingsImportExportException(e);
    }
}