public void update(User user) { this.hasFocus = true; if (user != currentUser) { updateHistoricMessages(revedereManager.getCurrentSession().getMessagesForUser(user)); } this.currentUser = user; this.userNameLabel.setText(user.getName()); addListenerOnShortMessageUpdateIfMissing(); }
private void addListenerOnShortMessageUpdateIfMissing() { final RevedereSession currentRevedereSession = revedereManager.getCurrentSession(); if (currentRevedereSession != null && collectorListener == null) { collectorListener = new CollectorListener<ShortMessageUpdate>() { @Override public void onUpdate( Collector<ShortMessageUpdate> collector, ShortMessageUpdate update) { if (hasFocus) { updateHistoricMessages(currentRevedereSession.getMessagesForUser(currentUser)); } } }; currentRevedereSession.addListenerToShortMessageCollector(collectorListener); } }