use of org.jivesoftware.spark.ui.PresenceListener in project Spark by igniterealtime.
the class ApplePlugin method handleIdle.
private void handleIdle() {
SparkManager.getMainWindow().addComponentListener(new ComponentListener() {
public void componentResized(ComponentEvent componentEvent) {
setActivity();
}
public void componentMoved(ComponentEvent componentEvent) {
setActivity();
}
public void componentShown(ComponentEvent componentEvent) {
setActivity();
}
public void componentHidden(ComponentEvent componentEvent) {
setActivity();
}
});
SparkManager.getChatManager().addChatRoomListener(new ChatRoomListenerAdapter() {
public void chatRoomOpened(ChatRoom room) {
if (!addedFrameListener) {
chatFrame = SparkManager.getChatManager().getChatContainer().getChatFrame();
chatFrame.addComponentListener(new ComponentListener() {
public void componentResized(ComponentEvent componentEvent) {
setActivity();
}
public void componentMoved(ComponentEvent componentEvent) {
setActivity();
}
public void componentShown(ComponentEvent componentEvent) {
setActivity();
}
public void componentHidden(ComponentEvent componentEvent) {
setActivity();
}
});
addedFrameListener = true;
}
setActivity();
}
public void chatRoomClosed(ChatRoom room) {
setActivity();
}
});
SparkManager.getSessionManager().addPresenceListener(new PresenceListener() {
public void presenceChanged(Presence presence) {
if (presence.isAvailable() && !presence.isAway()) {
lastActive = System.currentTimeMillis();
}
}
});
final Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
sparkIsIdle();
}
}, 10000, 10000);
lastActive = System.currentTimeMillis();
}
Aggregations