Don't use the UI dispatcher thread when not needed.
Actions that don't affect the UI should not be executed in the heavily synchronized dispatcher. It will needlessly delay execution, but also make the dispatcher thread unavailable for tasks that do belong there.
@@ -121,7 +121,6 @@ public class PresenceChangePlugin implements Plugin {
// Check presence changes
SparkManager.getConnection().addAsyncStanzaListener( stanza -> {
try {
- EventQueue.invokeAndWait( () -> {
Presence presence = (Presence) stanza;
if (!presence.isAvailable() || presence.isAway()) {
return;
@@ -147,10 +146,11 @@ String infoText = Res
nickname, time);
if (localPref.getShowToasterPopup()) {
+ EventQueue.invokeLater( () ->
+ {
SparkToaster toaster = new SparkToaster();
toaster.setDisplayTime( 5000 );
-toaster.setBorder(BorderFactory
-.createBevelBorder(0));
+ toaster.setBorder( BorderFactory.createBevelBorder( 0 ) );
toaster.setToasterHeight( 150 );
toaster.setToasterWidth( 200 );
@@ -158,33 +158,34 @@ toaster.setToasterWidth(200);
toaster.setTitle( nickname );
toaster.showToaster( null, infoText );
-toaster.setCustomAction(new AbstractAction() {
+ toaster.setCustomAction( new AbstractAction()
+ {
private static final long serialVersionUID = 4827542713848133369L;
@Override
-public void actionPerformed(
-ActionEvent e) {
-SparkManager.getChatManager()
-.getChatRoom(jid);
+ public void actionPerformed( ActionEvent e )
+ {
+ SparkManager.getChatManager().getChatRoom( jid );
}
} );
+ } );
}
ChatRoom room = SparkManager.getChatManager().getChatRoom(jid);
if (localPref.getWindowTakesFocus())
{
-SparkManager.getChatManager().activateChat(jid, nickname);
+ EventQueue.invokeLater( () -> SparkManager.getChatManager().activateChat( jid, nickname ) );
}
-room.getTranscriptWindow().insertNotificationMessage(infoText, ChatManager.NOTIFICATION_COLOR);
+EventQueue.invokeLater( () -> room.getTranscriptWindow().insertNotificationMessage(infoText, ChatManager.NOTIFICATION_COLOR) );
}
}
for(String s : removelater){
sparkContacts.remove(s);
}
-} );
+
} catch (Exception ex) {
ex.printStackTrace();
}
