1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-26 04:28:00 +01:00

Avoid getInstanceOf() in listener as it is a costly operation

This commit is contained in:
Florian Schmaus 2018-09-06 18:41:19 +02:00
parent 547138b325
commit 830f3661e7

View file

@ -92,6 +92,8 @@ public final class ChatMarkersManager extends Manager {
private final AsyncButOrdered<Chat> asyncButOrdered = new AsyncButOrdered<>();
private final ChatManager chatManager;
/**
* Get the singleton instance of ChatMarkersManager.
*
@ -111,6 +113,9 @@ public final class ChatMarkersManager extends Manager {
private ChatMarkersManager(XMPPConnection connection) {
super(connection);
chatManager = ChatManager.getInstanceFor(connection);
connection.addStanzaInterceptor(new StanzaListener() {
@Override
public void processStanza(Stanza packet)
@ -135,7 +140,7 @@ public final class ChatMarkersManager extends Manager {
EntityFullJid fullFrom = message.getFrom().asEntityFullJidIfPossible();
EntityBareJid bareFrom = fullFrom.asEntityBareJid();
final Chat chat = ChatManager.getInstanceFor(connection()).chatWith(bareFrom);
final Chat chat = chatManager.chatWith(bareFrom);
asyncButOrdered.performAsyncButOrdered(chat, new Runnable() {
@Override