package androidx.databinding; import androidx.collection.ArrayMap; import androidx.databinding.ObservableMap; import java.util.Collection; import java.util.Iterator; /* loaded from: classes.dex */ public class ObservableArrayMap extends ArrayMap implements ObservableMap { private transient MapChangeRegistry mListeners; @Override // androidx.databinding.ObservableMap public void addOnMapChangedCallback(ObservableMap.OnMapChangedCallback, K, V> onMapChangedCallback) { if (this.mListeners == null) { this.mListeners = new MapChangeRegistry(); } this.mListeners.add(onMapChangedCallback); } @Override // androidx.databinding.ObservableMap public void removeOnMapChangedCallback(ObservableMap.OnMapChangedCallback, K, V> onMapChangedCallback) { MapChangeRegistry mapChangeRegistry = this.mListeners; if (mapChangeRegistry != null) { mapChangeRegistry.remove(onMapChangedCallback); } } @Override // androidx.collection.SimpleArrayMap, java.util.Map public void clear() { if (isEmpty()) { return; } super.clear(); notifyChange(null); } @Override // androidx.collection.SimpleArrayMap, java.util.Map public V put(K k, V v) { super.put(k, v); notifyChange(k); return v; } /* JADX WARN: Multi-variable type inference failed */ @Override // androidx.collection.ArrayMap public boolean removeAll(Collection collection) { Iterator it = collection.iterator(); boolean z = false; while (it.hasNext()) { int indexOfKey = indexOfKey(it.next()); if (indexOfKey >= 0) { removeAt(indexOfKey); z = true; } } return z; } @Override // androidx.collection.ArrayMap public boolean retainAll(Collection collection) { boolean z = false; for (int size = getSize() - 1; size >= 0; size--) { if (!collection.contains(keyAt(size))) { removeAt(size); z = true; } } return z; } @Override // androidx.collection.SimpleArrayMap public V removeAt(int i) { K keyAt = keyAt(i); V v = (V) super.removeAt(i); if (v != null) { notifyChange(keyAt); } return v; } @Override // androidx.collection.SimpleArrayMap public V setValueAt(int i, V v) { K keyAt = keyAt(i); V v2 = (V) super.setValueAt(i, v); notifyChange(keyAt); return v2; } private void notifyChange(Object obj) { MapChangeRegistry mapChangeRegistry = this.mListeners; if (mapChangeRegistry != null) { mapChangeRegistry.notifyCallbacks(this, 0, obj); } } }