mirror of
https://github.com/androidx/media.git
synced 2025-04-30 06:46:50 +08:00
Save state throwsWhenUsingWrongThread when copy()
This commit is contained in:
parent
49ea280bb8
commit
c331ac64e7
@ -99,14 +99,15 @@ public final class ListenerSet<T extends @NonNull Object> {
|
||||
* during one {@link Looper} message queue iteration were handled by the listeners.
|
||||
*/
|
||||
public ListenerSet(Looper looper, Clock clock, IterationFinishedEvent<T> iterationFinishedEvent) {
|
||||
this(/* listeners= */ new CopyOnWriteArraySet<>(), looper, clock, iterationFinishedEvent);
|
||||
this(/* listeners= */ new CopyOnWriteArraySet<>(), looper, clock, iterationFinishedEvent, true);
|
||||
}
|
||||
|
||||
private ListenerSet(
|
||||
CopyOnWriteArraySet<ListenerHolder<T>> listeners,
|
||||
Looper looper,
|
||||
Clock clock,
|
||||
IterationFinishedEvent<T> iterationFinishedEvent) {
|
||||
IterationFinishedEvent<T> iterationFinishedEvent,
|
||||
Boolean throwsWhenUsingWrongThread) {
|
||||
this.clock = clock;
|
||||
this.listeners = listeners;
|
||||
this.iterationFinishedEvent = iterationFinishedEvent;
|
||||
@ -117,7 +118,7 @@ public final class ListenerSet<T extends @NonNull Object> {
|
||||
@SuppressWarnings("nullness:methodref.receiver.bound")
|
||||
HandlerWrapper handler = clock.createHandler(looper, this::handleMessage);
|
||||
this.handler = handler;
|
||||
throwsWhenUsingWrongThread = true;
|
||||
this.throwsWhenUsingWrongThread = throwsWhenUsingWrongThread;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,7 +150,7 @@ public final class ListenerSet<T extends @NonNull Object> {
|
||||
@CheckResult
|
||||
public ListenerSet<T> copy(
|
||||
Looper looper, Clock clock, IterationFinishedEvent<T> iterationFinishedEvent) {
|
||||
return new ListenerSet<>(listeners, looper, clock, iterationFinishedEvent);
|
||||
return new ListenerSet<>(listeners, looper, clock, iterationFinishedEvent, throwsWhenUsingWrongThread);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user