Search in sources :

Example 51 with XmlPullParser

use of org.xmlpull.v1.XmlPullParser in project android-maps-utils by googlemaps.

the class KmlParserTest method createParser.

public XmlPullParser createParser(int res) throws Exception {
    InputStream stream = getInstrumentation().getContext().getResources().openRawResource(res);
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware(true);
    XmlPullParser parser = factory.newPullParser();
    parser.setInput(stream, null);
    parser.next();
    return parser;
}
Also used : XmlPullParserFactory(org.xmlpull.v1.XmlPullParserFactory) InputStream(java.io.InputStream) XmlPullParser(org.xmlpull.v1.XmlPullParser)

Example 52 with XmlPullParser

use of org.xmlpull.v1.XmlPullParser in project android-maps-utils by googlemaps.

the class KmlContainerParserTest method testCDataEntity.

public void testCDataEntity() throws Exception {
    XmlPullParser xmlPullParser = createParser(R.raw.amu_cdata);
    KmlContainer kmlContainer = KmlContainerParser.createContainer(xmlPullParser);
    assertEquals(kmlContainer.getProperty("description"), "TELEPORT");
}
Also used : XmlPullParser(org.xmlpull.v1.XmlPullParser)

Example 53 with XmlPullParser

use of org.xmlpull.v1.XmlPullParser in project android-maps-utils by googlemaps.

the class KmlContainerParserTest method testCreateContainerPlacemark.

public void testCreateContainerPlacemark() throws Exception {
    XmlPullParser xmlPullParser = createParser(R.raw.amu_basic_folder);
    KmlContainer kmlContainer = KmlContainerParser.createContainer(xmlPullParser);
    assertTrue(kmlContainer.hasPlacemarks());
    assertEquals(kmlContainer.getPlacemarksHashMap().size(), 1);
    xmlPullParser = createParser(R.raw.amu_multiple_placemarks);
    kmlContainer = KmlContainerParser.createContainer(xmlPullParser);
    assertTrue(kmlContainer.hasPlacemarks());
    assertEquals(kmlContainer.getPlacemarksHashMap().size(), 2);
}
Also used : XmlPullParser(org.xmlpull.v1.XmlPullParser)

Example 54 with XmlPullParser

use of org.xmlpull.v1.XmlPullParser in project android-maps-utils by googlemaps.

the class KmlContainerParserTest method testCreateContainerProperty.

public void testCreateContainerProperty() throws Exception {
    XmlPullParser xmlPullParser = createParser(R.raw.amu_basic_folder);
    KmlContainer kmlContainer = KmlContainerParser.createContainer(xmlPullParser);
    assertTrue(kmlContainer.hasProperties());
    assertEquals(kmlContainer.getProperty("name"), "Basic Folder");
    xmlPullParser = createParser(R.raw.amu_unknwown_folder);
    kmlContainer = KmlContainerParser.createContainer(xmlPullParser);
    assertTrue(kmlContainer.hasProperty("name"));
}
Also used : XmlPullParser(org.xmlpull.v1.XmlPullParser)

Example 55 with XmlPullParser

use of org.xmlpull.v1.XmlPullParser in project android-maps-utils by googlemaps.

the class KmlFeatureParserTest method testMultiGeometry.

public void testMultiGeometry() throws Exception {
    XmlPullParser xmlPullParser = createParser(R.raw.amu_multigeometry_placemarks);
    KmlPlacemark placemark = KmlFeatureParser.createPlacemark(xmlPullParser);
    assertNotNull(placemark);
    assertEquals(placemark.getGeometry().getGeometryType(), "MultiGeometry");
    KmlMultiGeometry multiGeometry = ((KmlMultiGeometry) placemark.getGeometry());
    assertEquals(multiGeometry.getGeometryObject().size(), 3);
}
Also used : XmlPullParser(org.xmlpull.v1.XmlPullParser)

Aggregations

XmlPullParser (org.xmlpull.v1.XmlPullParser)673 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)623 IOException (java.io.IOException)377 FileInputStream (java.io.FileInputStream)185 FileNotFoundException (java.io.FileNotFoundException)185 File (java.io.File)107 ArrayList (java.util.ArrayList)77 StringReader (java.io.StringReader)65 AttributeSet (android.util.AttributeSet)61 Test (org.junit.Test)57 TypedArray (android.content.res.TypedArray)56 InputStream (java.io.InputStream)48 AtomicFile (android.util.AtomicFile)47 HashMap (java.util.HashMap)45 BridgeXmlBlockParser (com.android.layoutlib.bridge.android.BridgeXmlBlockParser)39 FileReader (java.io.FileReader)36 BufferedInputStream (java.io.BufferedInputStream)30 XmlPullParserFactory (org.xmlpull.v1.XmlPullParserFactory)30 RemoteException (android.os.RemoteException)28 ResourceValue (com.android.ide.common.rendering.api.ResourceValue)28