From e8290d52b1e71dd8ab2a1d50e9a5d96a7f9a204d Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 29 Mar 2014 20:29:03 +0100 Subject: [PATCH] finally fixed #notificationgate --- .../conversations/services/XmppConnectionService.java | 9 ++++++++- src/eu/siacs/conversations/ui/ConversationActivity.java | 1 - src/eu/siacs/conversations/ui/ConversationFragment.java | 7 ------- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/eu/siacs/conversations/services/XmppConnectionService.java b/src/eu/siacs/conversations/services/XmppConnectionService.java index 57a028e7d..2a8ee4a7c 100644 --- a/src/eu/siacs/conversations/services/XmppConnectionService.java +++ b/src/eu/siacs/conversations/services/XmppConnectionService.java @@ -85,6 +85,7 @@ public class XmppConnectionService extends Service { private List conversations = null; public OnConversationListChangedListener convChangedListener = null; + private int convChangedListenerCount = 0; private OnAccountListChangedListener accountChangedListener = null; private OnTLSExceptionReceived tlsException = null; @@ -1009,10 +1010,16 @@ public class XmppConnectionService extends Service { public void setOnConversationListChangedListener( OnConversationListChangedListener listener) { this.convChangedListener = listener; + this.convChangedListenerCount++; + Log.d(LOGTAG,"registered on conv changed in backend ("+convChangedListenerCount+")"); } public void removeOnConversationListChangedListener() { - this.convChangedListener = null; + this.convChangedListenerCount--; + Log.d(LOGTAG,"someone on conv changed listener removed listener ("+convChangedListenerCount+")"); + if (this.convChangedListenerCount==0) { + this.convChangedListener = null; + } } public void setOnAccountListChangedListener( diff --git a/src/eu/siacs/conversations/ui/ConversationActivity.java b/src/eu/siacs/conversations/ui/ConversationActivity.java index 61a23e770..ef1d051b9 100644 --- a/src/eu/siacs/conversations/ui/ConversationActivity.java +++ b/src/eu/siacs/conversations/ui/ConversationActivity.java @@ -417,7 +417,6 @@ public class ConversationActivity extends XmppActivity { @Override void onBackendConnected() { - this.registerListener(); if (conversationList.size()==0) { updateConversationList(); diff --git a/src/eu/siacs/conversations/ui/ConversationFragment.java b/src/eu/siacs/conversations/ui/ConversationFragment.java index 55a0d1a51..7bbef42fc 100644 --- a/src/eu/siacs/conversations/ui/ConversationFragment.java +++ b/src/eu/siacs/conversations/ui/ConversationFragment.java @@ -333,15 +333,8 @@ public class ConversationFragment extends Fragment { this.onBackendConnected(); } } - - @Override - public void onResume() { - super.onResume(); - activity.registerListener(); - } public void onBackendConnected() { - activity.registerListener(); this.conversation = activity.getSelectedConversation(); if (this.conversation == null) { return;