[android] More tidy up around multiple listeners

This commit is contained in:
Chris Bianca 2017-04-26 17:27:36 +01:00
parent ef306162b4
commit bb26cb4e2c
1 changed files with 6 additions and 20 deletions

View File

@ -153,30 +153,16 @@ public class RNFirebaseDatabaseReference {
} }
private void removeChildEventListener(Integer listenerId) { private void removeChildEventListener(Integer listenerId) {
if (listenerId != null) { ChildEventListener listener = mChildEventListeners.remove(listenerId);
ChildEventListener listener = mChildEventListeners.remove(listenerId); if (listener != null) {
if (listener != null) { mQuery.removeEventListener(listener);
mQuery.removeEventListener(listener);
}
} else {
for (ChildEventListener listener : mChildEventListeners.values()) {
mQuery.removeEventListener(listener);
}
mChildEventListeners = new HashMap<>();
} }
} }
private void removeValueEventListener(Integer listenerId) { private void removeValueEventListener(Integer listenerId) {
if (listenerId != null) { ValueEventListener listener = mValueEventListeners.remove(listenerId);
ValueEventListener listener = mValueEventListeners.remove(listenerId); if (listener != null) {
if (listener != null) { mQuery.removeEventListener(listener);
mQuery.removeEventListener(listener);
}
} else {
for (ValueEventListener listener : mValueEventListeners.values()) {
mQuery.removeEventListener(listener);
}
mValueEventListeners = new HashMap<>();
} }
} }