mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 05:52:06 +01:00
Make MarkableExtension a singleton
to reduce pressure on the memory subsystem.
This commit is contained in:
parent
45736e8ead
commit
b12f5a1591
4 changed files with 7 additions and 5 deletions
|
@ -125,7 +125,7 @@ public final class ChatMarkersManager extends Manager {
|
||||||
SmackException.NotLoggedInException {
|
SmackException.NotLoggedInException {
|
||||||
Message message = (Message) packet;
|
Message message = (Message) packet;
|
||||||
// add a markable extension
|
// add a markable extension
|
||||||
message.addExtension(new ChatMarkersElements.MarkableExtension());
|
message.addExtension(ChatMarkersElements.MarkableExtension.INSTANCE);
|
||||||
}
|
}
|
||||||
}, OUTGOING_MESSAGE_FILTER);
|
}, OUTGOING_MESSAGE_FILTER);
|
||||||
|
|
||||||
|
|
|
@ -41,14 +41,16 @@ public class ChatMarkersElements {
|
||||||
* @author Fernando Ramirez
|
* @author Fernando Ramirez
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static class MarkableExtension implements ExtensionElement {
|
public static final class MarkableExtension implements ExtensionElement {
|
||||||
|
|
||||||
|
public static final MarkableExtension INSTANCE = new MarkableExtension();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* markable element.
|
* markable element.
|
||||||
*/
|
*/
|
||||||
public static final String ELEMENT = ChatMarkersState.markable.toString();
|
public static final String ELEMENT = ChatMarkersState.markable.toString();
|
||||||
|
|
||||||
public MarkableExtension() {
|
private MarkableExtension() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class MarkableProvider extends ExtensionElementProvider<MarkableExtension
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MarkableExtension parse(XmlPullParser parser, int initialDepth) throws Exception {
|
public MarkableExtension parse(XmlPullParser parser, int initialDepth) throws Exception {
|
||||||
return new MarkableExtension();
|
return MarkableExtension.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class MarkableExtensionTest {
|
||||||
Message message = new Message(JidCreate.from("ingrichard@royalty.england.lit/throne"));
|
Message message = new Message(JidCreate.from("ingrichard@royalty.england.lit/throne"));
|
||||||
message.setStanzaId("message-1");
|
message.setStanzaId("message-1");
|
||||||
message.setBody("My lord, dispatch; read o'er these articles.");
|
message.setBody("My lord, dispatch; read o'er these articles.");
|
||||||
message.addExtension(new ChatMarkersElements.MarkableExtension());
|
message.addExtension(ChatMarkersElements.MarkableExtension.INSTANCE);
|
||||||
Assert.assertEquals(markableMessageStanza, message.toXML(null).toString());
|
Assert.assertEquals(markableMessageStanza, message.toXML(null).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue