discord-jadx/app/src/main/java/androidx/recyclerview/widget/AsyncDifferConfig.java

78 lines
2.5 KiB
Java

package androidx.recyclerview.widget;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RestrictTo;
import androidx.recyclerview.widget.DiffUtil;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
public final class AsyncDifferConfig<T> {
@NonNull
private final Executor mBackgroundThreadExecutor;
@NonNull
private final DiffUtil.ItemCallback<T> mDiffCallback;
@Nullable
private final Executor mMainThreadExecutor;
public static final class Builder<T> {
private static Executor sDiffExecutor;
private static final Object sExecutorLock = new Object();
private Executor mBackgroundThreadExecutor;
private final DiffUtil.ItemCallback<T> mDiffCallback;
@Nullable
private Executor mMainThreadExecutor;
public Builder(@NonNull DiffUtil.ItemCallback<T> itemCallback) {
this.mDiffCallback = itemCallback;
}
@NonNull
public AsyncDifferConfig<T> build() {
if (this.mBackgroundThreadExecutor == null) {
synchronized (sExecutorLock) {
if (sDiffExecutor == null) {
sDiffExecutor = Executors.newFixedThreadPool(2);
}
}
this.mBackgroundThreadExecutor = sDiffExecutor;
}
return new AsyncDifferConfig<>(this.mMainThreadExecutor, this.mBackgroundThreadExecutor, this.mDiffCallback);
}
@NonNull
public Builder<T> setBackgroundThreadExecutor(Executor executor) {
this.mBackgroundThreadExecutor = executor;
return this;
}
@NonNull
@RestrictTo({RestrictTo.Scope.LIBRARY})
public Builder<T> setMainThreadExecutor(Executor executor) {
this.mMainThreadExecutor = executor;
return this;
}
}
public AsyncDifferConfig(@Nullable Executor executor, @NonNull Executor executor2, @NonNull DiffUtil.ItemCallback<T> itemCallback) {
this.mMainThreadExecutor = executor;
this.mBackgroundThreadExecutor = executor2;
this.mDiffCallback = itemCallback;
}
@NonNull
public Executor getBackgroundThreadExecutor() {
return this.mBackgroundThreadExecutor;
}
@NonNull
public DiffUtil.ItemCallback<T> getDiffCallback() {
return this.mDiffCallback;
}
@Nullable
@RestrictTo({RestrictTo.Scope.LIBRARY})
public Executor getMainThreadExecutor() {
return this.mMainThreadExecutor;
}
}