37 lines
1.1 KiB
Java
37 lines
1.1 KiB
Java
|
package com.discord.utilities.collections;
|
||
|
|
||
|
import android.util.Log;
|
||
|
import d0.z.d.m;
|
||
|
import java.util.concurrent.CopyOnWriteArraySet;
|
||
|
import kotlin.Unit;
|
||
|
import kotlin.jvm.functions.Function1;
|
||
|
/* compiled from: ListenerCollection.kt */
|
||
|
public final class ListenerCollectionSubject<T> implements ListenerCollection<T> {
|
||
|
private final CopyOnWriteArraySet<T> listeners = new CopyOnWriteArraySet<>();
|
||
|
|
||
|
@Override // com.discord.utilities.collections.ListenerCollection
|
||
|
public void add(T t) {
|
||
|
this.listeners.add(t);
|
||
|
}
|
||
|
|
||
|
public final void clear() {
|
||
|
this.listeners.clear();
|
||
|
}
|
||
|
|
||
|
public final void notify(Function1<? super T, Unit> function1) {
|
||
|
m.checkNotNullParameter(function1, "action");
|
||
|
for (T t : this.listeners) {
|
||
|
try {
|
||
|
function1.invoke(t);
|
||
|
} catch (Exception e) {
|
||
|
Log.e("ListenerCollection", "Exception calling handler: " + e);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.discord.utilities.collections.ListenerCollection
|
||
|
public boolean remove(T t) {
|
||
|
return this.listeners.remove(t);
|
||
|
}
|
||
|
}
|