mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-26 14:17:57 +01:00
Make BlockContactsIQProvider idiomatic
The jids list doesn't have to be lazy initialized, because every IQ of that type is guaranteed to contain at least one JID. Also use ParserUtils.getJidAttribute().
This commit is contained in:
parent
b3662c0682
commit
ff97d2eb35
1 changed files with 4 additions and 6 deletions
|
@ -20,9 +20,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smack.provider.IQProvider;
|
||||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jivesoftware.smackx.blocking.element.BlockContactsIQ;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ public class BlockContactsIQProvider extends IQProvider<BlockContactsIQ> {
|
|||
|
||||
@Override
|
||||
public BlockContactsIQ parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||
List<Jid> jids = null;
|
||||
List<Jid> jids = new ArrayList<>();
|
||||
|
||||
outerloop: while (true) {
|
||||
int eventType = parser.next();
|
||||
|
@ -45,10 +45,8 @@ public class BlockContactsIQProvider extends IQProvider<BlockContactsIQ> {
|
|||
|
||||
case XmlPullParser.START_TAG:
|
||||
if (parser.getName().equals("item")) {
|
||||
if (jids == null) {
|
||||
jids = new ArrayList<>();
|
||||
}
|
||||
jids.add(JidCreate.from(parser.getAttributeValue("", "jid")));
|
||||
Jid jid = ParserUtils.getJidAttribute(parser);
|
||||
jids.add(jid);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Reference in a new issue