private Collection<CameraItem> readCameraSection(XmlPullParser parser) throws XmlPullParserException, IOException { List<CameraItem> result = new ArrayList<CameraItem>(); String sectionName = ""; while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } String name = parser.getName(); // Starts by looking for the entry tag if (name.equals("name")) { sectionName = parser.nextText(); } else if (name.equals("webcam")) { result.add(createCamera(parser)); } else { skip(parser); } } // Sektion im nachhinein setzen for (CameraItem camera : result) { camera.setSection(sectionName); } return result; }
private CameraItem createCamera(XmlPullParser parser) throws XmlPullParserException, IOException { CameraItem camera = new CameraItem(); while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } String name = parser.getName(); // Starts by looking for the entry tag if (name.equals("id")) { camera.setId(parser.nextText()); } else if (name.equals("plugin")) { String plugin = parser.nextText(); if ("bitctrl".equalsIgnoreCase(plugin)) { camera.setType(CameraType.BITCTRL); } else { camera.setType(CameraType.STRASSEN_SH); } } else if (name.equals("label")) { camera.setName(parser.nextText()); } else if ("description".equalsIgnoreCase(name)) { camera.setDescription(parser.nextText()); } } if (CameraType.BITCTRL.equals(camera.getType())) { camera.setUrl("http://85.214.56.86/live/" + camera.getId() + "/playlist.m3u8"); } // URL für die Webcams bekommen wir im StrassenSHStatusXMLParser return camera; }