[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,31 +153,17 @@ public class RNFirebaseDatabaseReference {
}
private void removeChildEventListener(Integer listenerId) {
if (listenerId != null) {
ChildEventListener listener = mChildEventListeners.remove(listenerId);
if (listener != null) {
mQuery.removeEventListener(listener);
}
} else {
for (ChildEventListener listener : mChildEventListeners.values()) {
mQuery.removeEventListener(listener);
}
mChildEventListeners = new HashMap<>();
}
}
private void removeValueEventListener(Integer listenerId) {
if (listenerId != null) {
ValueEventListener listener = mValueEventListeners.remove(listenerId);
if (listener != null) {
mQuery.removeEventListener(listener);
}
} else {
for (ValueEventListener listener : mValueEventListeners.values()) {
mQuery.removeEventListener(listener);
}
mValueEventListeners = new HashMap<>();
}
}
private void handleDatabaseEvent(final String name, final Integer listenerId, final DataSnapshot dataSnapshot) {