Kufar v3.2.0版本的 MD5 值为:6a4d203db1c561c7e3bcd50d23fed59f
以下内容为反编译后的 o.java 源代码,内容仅作参考
package com.airbnb.epoxy;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.tapjoy.TJAdUnitConstants;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.concurrent.CopyOnWriteArrayList;
public abstract class o implements e0 {
private static final int DELAY_TO_CHECK_ADAPTER_COUNT_MS = 3000;
private static final l0 NO_OP_TIMER = new h0();
public static Handler defaultDiffingHandler;
public static Handler defaultModelBuildingHandler;
private static boolean filterDuplicatesDefault;
private static boolean globalDebugLoggingEnabled;
private static d globalExceptionHandler;
private final EpoxyControllerAdapter adapter;
private final Runnable buildModelsRunnable;
private EpoxyDiffLogger debugObserver;
private volatile boolean filterDuplicates;
private volatile boolean hasBuiltModelsEver;
private final g helper;
private final List<e> interceptors;
private final Handler modelBuildHandler;
private List<f> modelInterceptorCallbacks;
private i modelsBeingBuilt;
private int recyclerViewAttachCount;
private volatile int requestedModelBuildType;
private q<?> stagedModel;
private volatile Thread threadBuildingModels;
private l0 timer;
public class a implements Runnable {
public a() {
}
@Override
public void run() {
o.this.threadBuildingModels = Thread.currentThread();
o.this.cancelPendingModelBuild();
o.this.helper.resetAutoModels();
o.this.modelsBeingBuilt = new i(o.this.getExpectedModelCount());
o.this.timer.a("Models built");
try {
o.this.buildModels();
o.this.addCurrentlyStagedModelIfExists();
o.this.timer.stop();
o.this.runInterceptors();
o oVar = o.this;
oVar.filterDuplicatesIfNeeded(oVar.modelsBeingBuilt);
o.this.modelsBeingBuilt.S();
o.this.timer.a("Models diffed");
o.this.adapter.setModels(o.this.modelsBeingBuilt);
o.this.timer.stop();
o.this.modelsBeingBuilt = null;
o.this.hasBuiltModelsEver = true;
o.this.threadBuildingModels = null;
} catch (Throwable th2) {
o.this.timer.stop();
o.this.modelsBeingBuilt = null;
o.this.hasBuiltModelsEver = true;
o.this.threadBuildingModels = null;
o.this.stagedModel = null;
throw th2;
}
}
}
public class c implements Runnable {
public c() {
}
@Override
public void run() {
if (o.this.recyclerViewAttachCount > 1) {
o.this.onExceptionSwallowed(new IllegalStateException("This EpoxyController had its adapter added to more than one ReyclerView. Epoxy does not support attaching an adapter to multiple RecyclerViews because saved state will not work properly. If you did not intend to attach your adapter to multiple RecyclerViews you may be leaking a reference to a previous RecyclerView. Make sure to remove the adapter from any previous RecyclerViews (eg if the adapter is reused in a Fragment across multiple onCreateView/onDestroyView cycles). See https://github.com/airbnb/epoxy/wiki/Avoiding-Memory-Leaks for more information."));
}
}
}
public interface d {
void a(@NonNull o oVar, @NonNull RuntimeException runtimeException);
}
public interface e {
void a(@NonNull List<q<?>> list);
}
public interface f {
void a(o oVar);
void b(o oVar);
}
static {
Handler handler = d0.f24195c.f24357b;
defaultModelBuildingHandler = handler;
defaultDiffingHandler = handler;
filterDuplicatesDefault = false;
globalDebugLoggingEnabled = false;
globalExceptionHandler = new b();
}
public o() {
this(defaultModelBuildingHandler, defaultDiffingHandler);
}
private void assertIsBuildingModels() {
if (isBuildingModels()) {
} else {
throw new a0("Can only call this when inside the `buildModels` method");
}
}
private void assertNotBuildingModels() {
if (!isBuildingModels()) {
} else {
throw new a0("Cannot call this from inside `buildModels`");
}
}
public void filterDuplicatesIfNeeded(List<q<?>> list) {
if (!this.filterDuplicates) {
return;
}
this.timer.a("Duplicates filtered");
HashSet hashSet = new HashSet(list.size());
ListIterator<q<?>> listIterator = list.listIterator();
while (listIterator.hasNext()) {
q<?> next = listIterator.next();
if (!hashSet.add(Long.valueOf(next.y9()))) {
int previousIndex = listIterator.previousIndex();
listIterator.remove();
int findPositionOfDuplicate = findPositionOfDuplicate(list, next);
q<?> qVar = list.get(findPositionOfDuplicate);
if (previousIndex <= findPositionOfDuplicate) {
findPositionOfDuplicate++;
}
onExceptionSwallowed(new a0("Two models have the same ID. ID's must be unique!\nOriginal has position " + findPositionOfDuplicate + ":\n" + qVar + "\nDuplicate has position " + previousIndex + ":\n" + next));
}
}
this.timer.stop();
}
private int findPositionOfDuplicate(List<q<?>> list, q<?> qVar) {
int size = list.size();
for (int i11 = 0; i11 < size; i11++) {
if (list.get(i11).y9() == qVar.y9()) {
return i11;
}
}
throw new IllegalArgumentException("No duplicates in list");
}
public int getExpectedModelCount() {
int itemCount = this.adapter.getItemCount();
if (itemCount == 0) {
return 25;
}
return itemCount;
}
public void runInterceptors() {
if (!this.interceptors.isEmpty()) {
List<f> list = this.modelInterceptorCallbacks;
if (list != null) {
Iterator<f> it = list.iterator();
while (it.hasNext()) {
it.next().b(this);
}
}
this.timer.a("Interceptors executed");
Iterator<e> it2 = this.interceptors.iterator();
while (it2.hasNext()) {
it2.next().a(this.modelsBeingBuilt);
}
this.timer.stop();
List<f> list2 = this.modelInterceptorCallbacks;
if (list2 != null) {
Iterator<f> it3 = list2.iterator();
while (it3.hasNext()) {
it3.next().a(this);
}
}
}
this.modelInterceptorCallbacks = null;
}
public static void setGlobalDebugLoggingEnabled(boolean z11) {
globalDebugLoggingEnabled = z11;
}
public static void setGlobalDuplicateFilteringDefault(boolean z11) {
filterDuplicatesDefault = z11;
}
public static void setGlobalExceptionHandler(@NonNull d dVar) {
globalExceptionHandler = dVar;
}
@Override
public void add(@NonNull q<?> qVar) {
qVar.m9(this);
}
public void addAfterInterceptorCallback(f fVar) {
assertIsBuildingModels();
if (this.modelInterceptorCallbacks == null) {
this.modelInterceptorCallbacks = new ArrayList();
}
this.modelInterceptorCallbacks.add(fVar);
}
public void addCurrentlyStagedModelIfExists() {
q<?> qVar = this.stagedModel;
if (qVar != null) {
qVar.m9(this);
}
this.stagedModel = null;
}
public void addInterceptor(@NonNull e eVar) {
this.interceptors.add(eVar);
}
public void addInternal(q<?> qVar) {
assertIsBuildingModels();
if (!qVar.x9()) {
if (qVar.D9()) {
clearModelFromStaging(qVar);
qVar.f24272f = null;
this.modelsBeingBuilt.add(qVar);
return;
}
throw new a0("You cannot hide a model in an EpoxyController. Use `addIf` to conditionally add a model instead.");
}
throw new a0("You must set an id on a model before adding it. Use the @AutoModel annotation if you want an id to be automatically generated for you.");
}
public void addModelBuildListener(j0 j0Var) {
this.adapter.addModelBuildListener(j0Var);
}
public abstract void buildModels();
public synchronized void cancelPendingModelBuild() {
if (this.requestedModelBuildType != 0) {
this.requestedModelBuildType = 0;
this.modelBuildHandler.removeCallbacks(this.buildModelsRunnable);
}
}
public void clearModelFromStaging(q<?> qVar) {
if (this.stagedModel != qVar) {
addCurrentlyStagedModelIfExists();
}
this.stagedModel = null;
}
@NonNull
public EpoxyControllerAdapter getAdapter() {
return this.adapter;
}
public int getFirstIndexOfModelInBuildingList(q<?> qVar) {
assertIsBuildingModels();
int size = this.modelsBeingBuilt.size();
for (int i11 = 0; i11 < size; i11++) {
if (this.modelsBeingBuilt.get(i11) == qVar) {
return i11;
}
}
return -1;
}
public int getModelCountBuiltSoFar() {
assertIsBuildingModels();
return this.modelsBeingBuilt.size();
}
public int getSpanCount() {
return this.adapter.getSpanCount();
}
@NonNull
public GridLayoutManager.SpanSizeLookup getSpanSizeLookup() {
return this.adapter.getSpanSizeLookup();
}
public boolean hasPendingModelBuild() {
if (this.requestedModelBuildType == 0 && this.threadBuildingModels == null && !this.adapter.isDiffInProgress()) {
return false;
}
return true;
}
public boolean isBuildingModels() {
if (this.threadBuildingModels == Thread.currentThread()) {
return true;
}
return false;
}
public boolean isDebugLoggingEnabled() {
if (this.timer != NO_OP_TIMER) {
return true;
}
return false;
}
public boolean isDuplicateFilteringEnabled() {
return this.filterDuplicates;
}
public boolean isModelAddedMultipleTimes(q<?> qVar) {
assertIsBuildingModels();
int size = this.modelsBeingBuilt.size();
int i11 = 0;
for (int i12 = 0; i12 < size; i12++) {
if (this.modelsBeingBuilt.get(i12) == qVar) {
i11++;
}
}
if (i11 <= 1) {
return false;
}
return true;
}
public boolean isMultiSpan() {
return this.adapter.isMultiSpan();
}
public boolean isStickyHeader(int i11) {
return false;
}
public void moveModel(int i11, int i12) {
assertNotBuildingModels();
this.adapter.moveModel(i11, i12);
requestDelayedModelBuild(TJAdUnitConstants.DEFAULT_VOLUME_CHECK_INTERVAL);
}
public void onAttachedToRecyclerViewInternal(RecyclerView recyclerView) {
int i11 = this.recyclerViewAttachCount + 1;
this.recyclerViewAttachCount = i11;
if (i11 > 1) {
d0.f24195c.f24357b.postDelayed(new c(), 3000L);
}
onAttachedToRecyclerView(recyclerView);
}
public void onDetachedFromRecyclerViewInternal(RecyclerView recyclerView) {
this.recyclerViewAttachCount--;
onDetachedFromRecyclerView(recyclerView);
}
public void onExceptionSwallowed(@NonNull RuntimeException runtimeException) {
globalExceptionHandler.a(this, runtimeException);
}
public void onRestoreInstanceState(@Nullable Bundle bundle) {
this.adapter.onRestoreInstanceState(bundle);
}
public void onSaveInstanceState(@NonNull Bundle bundle) {
this.adapter.onSaveInstanceState(bundle);
}
public void removeInterceptor(@NonNull e eVar) {
this.interceptors.remove(eVar);
}
public void removeModelBuildListener(j0 j0Var) {
this.adapter.removeModelBuildListener(j0Var);
}
public synchronized void requestDelayedModelBuild(int i11) {
if (!isBuildingModels()) {
int i12 = 1;
if (this.requestedModelBuildType == 2) {
cancelPendingModelBuild();
} else if (this.requestedModelBuildType == 1) {
return;
}
if (i11 != 0) {
i12 = 2;
}
this.requestedModelBuildType = i12;
this.modelBuildHandler.postDelayed(this.buildModelsRunnable, i11);
return;
}
throw new a0("Cannot call `requestDelayedModelBuild` from inside `buildModels`");
}
public void requestModelBuild() {
if (!isBuildingModels()) {
if (this.hasBuiltModelsEver) {
requestDelayedModelBuild(0);
return;
} else {
this.buildModelsRunnable.run();
return;
}
}
throw new a0("Cannot call `requestModelBuild` from inside `buildModels`");
}
public void setDebugLoggingEnabled(boolean z11) {
assertNotBuildingModels();
if (z11) {
this.timer = new j(getClass().getSimpleName());
if (this.debugObserver == null) {
this.debugObserver = new EpoxyDiffLogger(getClass().getSimpleName());
}
this.adapter.registerAdapterDataObserver(this.debugObserver);
return;
}
this.timer = NO_OP_TIMER;
EpoxyDiffLogger epoxyDiffLogger = this.debugObserver;
if (epoxyDiffLogger != null) {
this.adapter.unregisterAdapterDataObserver(epoxyDiffLogger);
}
}
public void setFilterDuplicates(boolean z11) {
this.filterDuplicates = z11;
}
public void setSpanCount(int i11) {
this.adapter.setSpanCount(i11);
}
public void setStagedModel(q<?> qVar) {
if (qVar != this.stagedModel) {
addCurrentlyStagedModelIfExists();
}
this.stagedModel = qVar;
}
public o(Handler handler, Handler handler2) {
this.recyclerViewAttachCount = 0;
this.interceptors = new CopyOnWriteArrayList();
this.filterDuplicates = filterDuplicatesDefault;
this.threadBuildingModels = null;
this.timer = NO_OP_TIMER;
this.helper = h.b(this);
this.requestedModelBuildType = 0;
this.buildModelsRunnable = new a();
this.adapter = new EpoxyControllerAdapter(this, handler2);
this.modelBuildHandler = handler;
setDebugLoggingEnabled(globalDebugLoggingEnabled);
}
public void add(@NonNull q<?>... qVarArr) {
i iVar = this.modelsBeingBuilt;
iVar.ensureCapacity(iVar.size() + qVarArr.length);
for (q<?> qVar : qVarArr) {
add(qVar);
}
}
public void add(@NonNull List<? extends q<?>> list) {
i iVar = this.modelsBeingBuilt;
iVar.ensureCapacity(iVar.size() + list.size());
Iterator<? extends q<?>> it = list.iterator();
while (it.hasNext()) {
add(it.next());
}
}
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
}
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
}
public void setupStickyHeaderView(View view) {
}
public void teardownStickyHeaderView(View view) {
}
public static class b implements d {
@Override
public void a(@NonNull o oVar, @NonNull RuntimeException runtimeException) {
}
}
public void onModelUnbound(@NonNull EpoxyViewHolder epoxyViewHolder, @NonNull q<?> qVar) {
}
public void onViewAttachedToWindow(@NonNull EpoxyViewHolder epoxyViewHolder, @NonNull q<?> qVar) {
}
public void onViewDetachedFromWindow(@NonNull EpoxyViewHolder epoxyViewHolder, @NonNull q<?> qVar) {
}
public void onModelBound(@NonNull EpoxyViewHolder epoxyViewHolder, @NonNull q<?> qVar, int i11, @Nullable q<?> qVar2) {
}
}