diff --git a/android/src/main/java/io/invertase/firebase/database/RNFirebaseDatabaseReference.java b/android/src/main/java/io/invertase/firebase/database/RNFirebaseDatabaseReference.java index 725ffae4..4eaa48a0 100644 --- a/android/src/main/java/io/invertase/firebase/database/RNFirebaseDatabaseReference.java +++ b/android/src/main/java/io/invertase/firebase/database/RNFirebaseDatabaseReference.java @@ -153,30 +153,16 @@ 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<>(); + ChildEventListener listener = mChildEventListeners.remove(listenerId); + if (listener != null) { + mQuery.removeEventListener(listener); } } 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<>(); + ValueEventListener listener = mValueEventListeners.remove(listenerId); + if (listener != null) { + mQuery.removeEventListener(listener); } }