1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-23 23:02:05 +01:00

Use nextTag and switch in provider

This commit is contained in:
Paul Schaub 2019-08-31 16:56:44 +02:00
parent 609ace2f0d
commit a41430b1fd

View file

@ -46,11 +46,11 @@ public class MetadataProvider extends ExtensionElementProvider<MetadataExtension
List<MetadataInfo> metadataInfos = null;
List<MetadataPointer> pointers = null;
while (true) {
XmlPullParser.Event eventType = parser.next();
if (eventType == XmlPullParser.Event.START_ELEMENT) {
outerloop: while (true) {
XmlPullParser.TagEvent eventType = parser.nextTag();
switch (eventType) {
case START_ELEMENT:
if (parser.getName().equals("info")) {
if (metadataInfos == null) {
metadataInfos = new ArrayList<>();
@ -69,14 +69,13 @@ public class MetadataProvider extends ExtensionElementProvider<MetadataExtension
pointers.add(parsePointer(parser));
}
} else if (eventType == XmlPullParser.Event.END_ELEMENT) {
if (parser.getDepth() == initialDepth) {
break;
case END_ELEMENT:
if (parser.getDepth() == initialDepth) {
break outerloop;
}
}
}
return new MetadataExtension(metadataInfos, pointers);
}
@ -126,10 +125,11 @@ public class MetadataProvider extends ExtensionElementProvider<MetadataExtension
String namespace = null;
HashMap<String, Object> fields = null;
while (true) {
XmlPullParser.Event eventType2 = parser.next();
outperloop: while (true) {
XmlPullParser.TagEvent tag = parser.nextTag();
if (eventType2 == XmlPullParser.Event.START_ELEMENT) {
switch (tag) {
case START_ELEMENT:
if (parser.getName().equals("x")) {
namespace = parser.getNamespace();
} else {
@ -141,9 +141,11 @@ public class MetadataProvider extends ExtensionElementProvider<MetadataExtension
Object value = parser.nextText();
fields.put(name, value);
}
} else if (eventType2 == XmlPullParser.Event.END_ELEMENT) {
if (parser.getDepth() == pointerDepth) {
break;
case END_ELEMENT:
if (parser.getDepth() == pointerDepth) {
break outperloop;
}
}
}