Money Lover v8.14.0.6版本的 MD5 值为:48b9d922212c7ccfd438cdcc183ff396

以下内容为反编译后的 q.java 源代码,内容仅作参考


package com.airbnb.epoxy;

import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
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 q implements k0 {
    private static final int DELAY_TO_CHECK_ADAPTER_COUNT_MS = 3000;
    private static final v0 NO_OP_TIMER = new n0();
    public static Handler defaultDiffingHandler;
    public static Handler defaultModelBuildingHandler;
    private static boolean filterDuplicatesDefault;
    private static boolean globalDebugLoggingEnabled;
    private static d globalExceptionHandler;
    private final r adapter;
    private final Runnable buildModelsRunnable;
    private s debugObserver;
    private volatile boolean filterDuplicates;
    private volatile boolean hasBuiltModelsEver;
    private final i helper;
    private final List<e> interceptors;
    private final Handler modelBuildHandler;
    private List<f> modelInterceptorCallbacks;
    private k modelsBeingBuilt;
    private int recyclerViewAttachCount;
    private volatile int requestedModelBuildType;
    private v<?> stagedModel;
    private volatile Thread threadBuildingModels;
    private v0 timer;

    class a implements Runnable {
        a() {
        }

        @Override
        public void run() {
            q.this.threadBuildingModels = Thread.currentThread();
            q.this.cancelPendingModelBuild();
            q.this.helper.resetAutoModels();
            q.this.modelsBeingBuilt = new k(q.this.getExpectedModelCount());
            q.this.timer.a("Models built");
            try {
                q.this.buildModels();
                q.this.addCurrentlyStagedModelIfExists();
                q.this.timer.stop();
                q.this.runInterceptors();
                q qVar = q.this;
                qVar.filterDuplicatesIfNeeded(qVar.modelsBeingBuilt);
                q.this.modelsBeingBuilt.M();
                q.this.timer.a("Models diffed");
                q.this.adapter.N(q.this.modelsBeingBuilt);
                q.this.timer.stop();
                q.this.modelsBeingBuilt = null;
                q.this.hasBuiltModelsEver = true;
                q.this.threadBuildingModels = null;
            } catch (Throwable th2) {
                q.this.timer.stop();
                q.this.modelsBeingBuilt = null;
                q.this.hasBuiltModelsEver = true;
                q.this.threadBuildingModels = null;
                q.this.stagedModel = null;
                throw th2;
            }
        }
    }

    class b implements d {
        b() {
        }

        @Override
        public void a(q qVar, RuntimeException runtimeException) {
        }
    }

    class c implements Runnable {
        c() {
        }

        @Override
        public void run() {
            if (q.this.recyclerViewAttachCount > 1) {
                q.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(q qVar, RuntimeException runtimeException);
    }

    public interface e {
        void a(List<v<?>> list);
    }

    public interface f {
        void a(q qVar);

        void b(q qVar);
    }

    static {
        Handler handler = j0.f7603b.f7572a;
        defaultModelBuildingHandler = handler;
        defaultDiffingHandler = handler;
        filterDuplicatesDefault = false;
        globalDebugLoggingEnabled = false;
        globalExceptionHandler = new b();
    }

    public q() {
        this(defaultModelBuildingHandler, defaultDiffingHandler);
    }

    private void assertIsBuildingModels() {
        if (isBuildingModels()) {
        } else {
            throw new IllegalEpoxyUsage("Can only call this when inside the `buildModels` method");
        }
    }

    private void assertNotBuildingModels() {
        if (!isBuildingModels()) {
        } else {
            throw new IllegalEpoxyUsage("Cannot call this from inside `buildModels`");
        }
    }

    public void filterDuplicatesIfNeeded(List<v<?>> list) {
        if (!this.filterDuplicates) {
            return;
        }
        this.timer.a("Duplicates filtered");
        HashSet hashSet = new HashSet(list.size());
        ListIterator<v<?>> listIterator = list.listIterator();
        while (listIterator.hasNext()) {
            v<?> next = listIterator.next();
            if (!hashSet.add(Long.valueOf(next.w2()))) {
                int previousIndex = listIterator.previousIndex();
                listIterator.remove();
                int findPositionOfDuplicate = findPositionOfDuplicate(list, next);
                v<?> vVar = list.get(findPositionOfDuplicate);
                if (previousIndex <= findPositionOfDuplicate) {
                    findPositionOfDuplicate++;
                }
                onExceptionSwallowed(new IllegalEpoxyUsage("Two models have the same ID. ID's must be unique!\nOriginal has position " + findPositionOfDuplicate + ":\n" + vVar + "\nDuplicate has position " + previousIndex + ":\n" + next));
            }
        }
        this.timer.stop();
    }

    private int findPositionOfDuplicate(List<v<?>> list, v<?> vVar) {
        int size = list.size();
        for (int i10 = 0; i10 < size; i10++) {
            if (list.get(i10).w2() == vVar.w2()) {
                return i10;
            }
        }
        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 z10) {
        globalDebugLoggingEnabled = z10;
    }

    public static void setGlobalDuplicateFilteringDefault(boolean z10) {
        filterDuplicatesDefault = z10;
    }

    public static void setGlobalExceptionHandler(d dVar) {
        globalExceptionHandler = dVar;
    }

    @Override
    public void add(v<?> vVar) {
        vVar.k2(this);
    }

    public void addAfterInterceptorCallback(f fVar) {
        assertIsBuildingModels();
        if (this.modelInterceptorCallbacks == null) {
            this.modelInterceptorCallbacks = new ArrayList();
        }
        this.modelInterceptorCallbacks.add(fVar);
    }

    void addCurrentlyStagedModelIfExists() {
        v<?> vVar = this.stagedModel;
        if (vVar != null) {
            vVar.k2(this);
        }
        this.stagedModel = null;
    }

    public void addInterceptor(e eVar) {
        this.interceptors.add(eVar);
    }

    public void addInternal(v<?> vVar) {
        assertIsBuildingModels();
        if (!vVar.v2()) {
            if (vVar.B2()) {
                clearModelFromStaging(vVar);
                vVar.f7716f = null;
                this.modelsBeingBuilt.add(vVar);
                return;
            }
            throw new IllegalEpoxyUsage("You cannot hide a model in an EpoxyController. Use `addIf` to conditionally add a model instead.");
        }
        throw new IllegalEpoxyUsage("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(q0 q0Var) {
        this.adapter.G(q0Var);
    }

    protected abstract void buildModels();

    public synchronized void cancelPendingModelBuild() {
        if (this.requestedModelBuildType != 0) {
            this.requestedModelBuildType = 0;
            this.modelBuildHandler.removeCallbacks(this.buildModelsRunnable);
        }
    }

    void clearModelFromStaging(v<?> vVar) {
        if (this.stagedModel != vVar) {
            addCurrentlyStagedModelIfExists();
        }
        this.stagedModel = null;
    }

    public r getAdapter() {
        return this.adapter;
    }

    public int getFirstIndexOfModelInBuildingList(v<?> vVar) {
        assertIsBuildingModels();
        int size = this.modelsBeingBuilt.size();
        for (int i10 = 0; i10 < size; i10++) {
            if (this.modelsBeingBuilt.get(i10) == vVar) {
                return i10;
            }
        }
        return -1;
    }

    protected int getModelCountBuiltSoFar() {
        assertIsBuildingModels();
        return this.modelsBeingBuilt.size();
    }

    public int getSpanCount() {
        return this.adapter.m();
    }

    public GridLayoutManager.c getSpanSizeLookup() {
        return this.adapter.n();
    }

    public boolean hasPendingModelBuild() {
        if (this.requestedModelBuildType == 0 && this.threadBuildingModels == null && !this.adapter.J()) {
            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(v<?> vVar) {
        assertIsBuildingModels();
        int size = this.modelsBeingBuilt.size();
        int i10 = 0;
        for (int i11 = 0; i11 < size; i11++) {
            if (this.modelsBeingBuilt.get(i11) == vVar) {
                i10++;
            }
        }
        if (i10 <= 1) {
            return false;
        }
        return true;
    }

    public boolean isMultiSpan() {
        return this.adapter.o();
    }

    public boolean isStickyHeader(int i10) {
        return false;
    }

    public void moveModel(int i10, int i11) {
        assertNotBuildingModels();
        this.adapter.K(i10, i11);
        requestDelayedModelBuild(500);
    }

    public void notifyModelChanged(int i10) {
        assertNotBuildingModels();
        this.adapter.L(i10);
    }

    protected void onAttachedToRecyclerView(RecyclerView recyclerView) {
    }

    public void onAttachedToRecyclerViewInternal(RecyclerView recyclerView) {
        int i10 = this.recyclerViewAttachCount + 1;
        this.recyclerViewAttachCount = i10;
        if (i10 > 1) {
            j0.f7603b.f7572a.postDelayed(new c(), 3000L);
        }
        onAttachedToRecyclerView(recyclerView);
    }

    protected void onDetachedFromRecyclerView(RecyclerView recyclerView) {
    }

    public void onDetachedFromRecyclerViewInternal(RecyclerView recyclerView) {
        this.recyclerViewAttachCount--;
        onDetachedFromRecyclerView(recyclerView);
    }

    public void onExceptionSwallowed(RuntimeException runtimeException) {
        globalExceptionHandler.a(this, runtimeException);
    }

    public void onModelBound(y yVar, v<?> vVar, int i10, v<?> vVar2) {
    }

    public void onModelUnbound(y yVar, v<?> vVar) {
    }

    public void onRestoreInstanceState(Bundle bundle) {
        this.adapter.y(bundle);
    }

    public void onSaveInstanceState(Bundle bundle) {
        this.adapter.z(bundle);
    }

    public void onViewAttachedToWindow(y yVar, v<?> vVar) {
    }

    public void onViewDetachedFromWindow(y yVar, v<?> vVar) {
    }

    public void removeInterceptor(e eVar) {
        this.interceptors.remove(eVar);
    }

    public void removeModelBuildListener(q0 q0Var) {
        this.adapter.M(q0Var);
    }

    public synchronized void requestDelayedModelBuild(int i10) {
        if (!isBuildingModels()) {
            int i11 = 1;
            if (this.requestedModelBuildType == 2) {
                cancelPendingModelBuild();
            } else if (this.requestedModelBuildType == 1) {
                return;
            }
            if (i10 != 0) {
                i11 = 2;
            }
            this.requestedModelBuildType = i11;
            this.modelBuildHandler.postDelayed(this.buildModelsRunnable, i10);
            return;
        }
        throw new IllegalEpoxyUsage("Cannot call `requestDelayedModelBuild` from inside `buildModels`");
    }

    public void requestModelBuild() {
        if (!isBuildingModels()) {
            if (this.hasBuiltModelsEver) {
                requestDelayedModelBuild(0);
                return;
            } else {
                this.buildModelsRunnable.run();
                return;
            }
        }
        throw new IllegalEpoxyUsage("Cannot call `requestModelBuild` from inside `buildModels`");
    }

    public void setDebugLoggingEnabled(boolean z10) {
        assertNotBuildingModels();
        if (z10) {
            this.timer = new l(getClass().getSimpleName());
            if (this.debugObserver == null) {
                this.debugObserver = new s(getClass().getSimpleName());
            }
            this.adapter.registerAdapterDataObserver(this.debugObserver);
            return;
        }
        this.timer = NO_OP_TIMER;
        s sVar = this.debugObserver;
        if (sVar != null) {
            this.adapter.unregisterAdapterDataObserver(sVar);
        }
    }

    public void setFilterDuplicates(boolean z10) {
        this.filterDuplicates = z10;
    }

    public void setSpanCount(int i10) {
        this.adapter.D(i10);
    }

    public void setStagedModel(v<?> vVar) {
        if (vVar != this.stagedModel) {
            addCurrentlyStagedModelIfExists();
        }
        this.stagedModel = vVar;
    }

    public void setupStickyHeaderView(View view) {
    }

    public void teardownStickyHeaderView(View view) {
    }

    public q(Handler handler, Handler handler2) {
        this.recyclerViewAttachCount = 0;
        this.interceptors = new CopyOnWriteArrayList();
        this.filterDuplicates = filterDuplicatesDefault;
        this.threadBuildingModels = null;
        this.timer = NO_OP_TIMER;
        this.helper = j.b(this);
        this.requestedModelBuildType = 0;
        this.buildModelsRunnable = new a();
        this.adapter = new r(this, handler2);
        this.modelBuildHandler = handler;
        setDebugLoggingEnabled(globalDebugLoggingEnabled);
    }

    protected void add(v<?>... vVarArr) {
        k kVar = this.modelsBeingBuilt;
        kVar.ensureCapacity(kVar.size() + vVarArr.length);
        for (v<?> vVar : vVarArr) {
            add(vVar);
        }
    }

    public void add(List<? extends v<?>> list) {
        k kVar = this.modelsBeingBuilt;
        kVar.ensureCapacity(kVar.size() + list.size());
        Iterator<? extends v<?>> it = list.iterator();
        while (it.hasNext()) {
            add(it.next());
        }
    }
}