1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-22 20:47:57 +01:00

Make MarkableExtension a singleton

to reduce pressure on the memory subsystem.
This commit is contained in:
Florian Schmaus 2018-09-06 18:45:41 +02:00
parent 45736e8ead
commit b12f5a1591
4 changed files with 7 additions and 5 deletions

View file

@ -125,7 +125,7 @@ public final class ChatMarkersManager extends Manager {
SmackException.NotLoggedInException {
Message message = (Message) packet;
// add a markable extension
message.addExtension(new ChatMarkersElements.MarkableExtension());
message.addExtension(ChatMarkersElements.MarkableExtension.INSTANCE);
}
}, OUTGOING_MESSAGE_FILTER);

View file

@ -41,14 +41,16 @@ public class ChatMarkersElements {
* @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.
*/
public static final String ELEMENT = ChatMarkersState.markable.toString();
public MarkableExtension() {
private MarkableExtension() {
}
@Override

View file

@ -34,7 +34,7 @@ public class MarkableProvider extends ExtensionElementProvider<MarkableExtension
@Override
public MarkableExtension parse(XmlPullParser parser, int initialDepth) throws Exception {
return new MarkableExtension();
return MarkableExtension.INSTANCE;
}
}

View file

@ -41,7 +41,7 @@ public class MarkableExtensionTest {
Message message = new Message(JidCreate.from("ingrichard@royalty.england.lit/throne"));
message.setStanzaId("message-1");
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());
}