mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 14:22:05 +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 AsyncButOrdered<Chat> asyncButOrdered = new AsyncButOrdered<>();
|
||||||
|
|
||||||
|
private final ChatManager chatManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the singleton instance of ChatMarkersManager.
|
* Get the singleton instance of ChatMarkersManager.
|
||||||
*
|
*
|
||||||
|
@ -111,6 +113,9 @@ public final class ChatMarkersManager extends Manager {
|
||||||
|
|
||||||
private ChatMarkersManager(XMPPConnection connection) {
|
private ChatMarkersManager(XMPPConnection connection) {
|
||||||
super(connection);
|
super(connection);
|
||||||
|
|
||||||
|
chatManager = ChatManager.getInstanceFor(connection);
|
||||||
|
|
||||||
connection.addStanzaInterceptor(new StanzaListener() {
|
connection.addStanzaInterceptor(new StanzaListener() {
|
||||||
@Override
|
@Override
|
||||||
public void processStanza(Stanza packet)
|
public void processStanza(Stanza packet)
|
||||||
|
@ -135,7 +140,7 @@ public final class ChatMarkersManager extends Manager {
|
||||||
|
|
||||||
EntityFullJid fullFrom = message.getFrom().asEntityFullJidIfPossible();
|
EntityFullJid fullFrom = message.getFrom().asEntityFullJidIfPossible();
|
||||||
EntityBareJid bareFrom = fullFrom.asEntityBareJid();
|
EntityBareJid bareFrom = fullFrom.asEntityBareJid();
|
||||||
final Chat chat = ChatManager.getInstanceFor(connection()).chatWith(bareFrom);
|
final Chat chat = chatManager.chatWith(bareFrom);
|
||||||
|
|
||||||
asyncButOrdered.performAsyncButOrdered(chat, new Runnable() {
|
asyncButOrdered.performAsyncButOrdered(chat, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue