diff options
author | iNPUTmice <daniel@gultsch.de> | 2014-07-18 15:35:31 +0200 |
---|---|---|
committer | iNPUTmice <daniel@gultsch.de> | 2014-07-18 15:35:31 +0200 |
commit | 4307b1de723a5ec28610580ad04bb7cb327b264c (patch) | |
tree | 0493a9df396a565afa903ee74e1334533ac1acf6 /src/eu/siacs/conversations | |
parent | 6b74c0594e95dcedfdbeeb33ef7bdd8b52c1093e (diff) |
notify ui on roster changes
Diffstat (limited to 'src/eu/siacs/conversations')
5 files changed, 55 insertions, 0 deletions
diff --git a/src/eu/siacs/conversations/parser/IqParser.java b/src/eu/siacs/conversations/parser/IqParser.java index acbeee4d..049d37e1 100644 --- a/src/eu/siacs/conversations/parser/IqParser.java +++ b/src/eu/siacs/conversations/parser/IqParser.java @@ -38,6 +38,7 @@ public class IqParser extends AbstractParser implements OnIqPacketReceived { } } } + mXmppConnectionService.updateRosterUi(); } @Override diff --git a/src/eu/siacs/conversations/parser/PresenceParser.java b/src/eu/siacs/conversations/parser/PresenceParser.java index bd2aa636..3a06f302 100644 --- a/src/eu/siacs/conversations/parser/PresenceParser.java +++ b/src/eu/siacs/conversations/parser/PresenceParser.java @@ -99,6 +99,7 @@ public class PresenceParser extends AbstractParser implements } } } + mXmppConnectionService.updateRosterUi(); } @Override diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index dd4363f4..bbc9861a 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -105,6 +105,7 @@ public class XmppConnectionService extends Service { private OnConversationUpdate mOnConversationUpdate = null; private int convChangedListenerCount = 0; private OnAccountUpdate mOnAccountUpdate = null; + private OnRosterUpdate mOnRosterUpdate = null; private OnTLSExceptionReceived tlsException = null; public OnContactStatusChanged onContactStatusChanged = new OnContactStatusChanged() { @@ -917,6 +918,14 @@ public class XmppConnectionService extends Service { public void removeOnAccountListChangedListener() { this.mOnAccountUpdate = null; } + + public void setOnRosterUpdateListener(OnRosterUpdate listener) { + this.mOnRosterUpdate = listener; + } + + public void removeOnRosterUpdateListener() { + this.mOnRosterUpdate = null; + } public void connectMultiModeConversations(Account account) { List<Conversation> conversations = getConversations(); @@ -1261,6 +1270,12 @@ public class XmppConnectionService extends Service { mOnAccountUpdate.onAccountUpdate(); } } + + public void updateRosterUi() { + if (mOnRosterUpdate != null) { + mOnRosterUpdate.onRosterUpdate(); + } + } public Account findAccountByJid(String accountJid) { for (Account account : this.accounts) { diff --git a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java index a8527feb..e29a6390 100644 --- a/src/eu/siacs/conversations/ui/ContactDetailsActivity.java +++ b/src/eu/siacs/conversations/ui/ContactDetailsActivity.java @@ -31,6 +31,7 @@ import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Presences; import eu.siacs.conversations.services.XmppConnectionService; +import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.utils.UIHelper; import eu.siacs.conversations.xmpp.stanzas.PresencePacket; @@ -89,6 +90,20 @@ public class ContactDetailsActivity extends XmppActivity { private LinearLayout keys; + private OnRosterUpdate rosterUpdate = new OnRosterUpdate() { + + @Override + public void onRosterUpdate() { + runOnUiThread(new Runnable() { + + @Override + public void run() { + populateView(); + } + }); + } + }; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -270,6 +285,7 @@ public class ContactDetailsActivity extends XmppActivity { @Override public void onBackendConnected() { + xmppConnectionService.setOnRosterUpdateListener(this.rosterUpdate ); if ((accountJid != null)&&(contactJid != null)) { Account account = xmppConnectionService.findAccountByJid(accountJid); if (account==null) { @@ -356,6 +372,7 @@ public class ContactDetailsActivity extends XmppActivity { } } } + xmppConnectionService.removeOnRosterUpdateListener(); } } diff --git a/src/eu/siacs/conversations/ui/StartConversationActivity.java b/src/eu/siacs/conversations/ui/StartConversationActivity.java index 5e22b65f..d12d2878 100644 --- a/src/eu/siacs/conversations/ui/StartConversationActivity.java +++ b/src/eu/siacs/conversations/ui/StartConversationActivity.java @@ -40,6 +40,7 @@ import eu.siacs.conversations.entities.Bookmark; import eu.siacs.conversations.entities.Contact; import eu.siacs.conversations.entities.Conversation; import eu.siacs.conversations.entities.ListItem; +import eu.siacs.conversations.services.XmppConnectionService.OnRosterUpdate; import eu.siacs.conversations.ui.adapter.KnownHostsAdapter; import eu.siacs.conversations.ui.adapter.ListItemAdapter; import eu.siacs.conversations.utils.Validator; @@ -139,6 +140,19 @@ public class StartConversationActivity extends XmppActivity { int count) { } }; + private OnRosterUpdate onRosterUpdate = new OnRosterUpdate() { + + @Override + public void onRosterUpdate() { + runOnUiThread(new Runnable() { + + @Override + public void run() { + filter(mSearchEditText.getText().toString()); + } + }); + } + }; @Override public void onCreate(Bundle savedInstanceState) { @@ -200,6 +214,12 @@ public class StartConversationActivity extends XmppActivity { }); } + + @Override + public void onStop() { + super.onStop(); + xmppConnectionService.removeOnRosterUpdateListener(); + } protected void openConversationForContact(int position) { Contact contact = (Contact) contacts.get(position); @@ -444,6 +464,7 @@ public class StartConversationActivity extends XmppActivity { @Override void onBackendConnected() { + xmppConnectionService.setOnRosterUpdateListener(this.onRosterUpdate ); if (mSearchEditText != null) { filter(mSearchEditText.getText().toString()); } else { |