mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-25 15:52:06 +01:00
Avoid getInstanceOf() in listener as it is a costly operation
This commit is contained in:
parent
547138b325
commit
830f3661e7
1 changed files with 6 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue