mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-14 19:42:05 +01:00
Use nextTag and switch in provider
This commit is contained in:
parent
609ace2f0d
commit
a41430b1fd
1 changed files with 41 additions and 39 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue