导航菜单

页面标题

页面副标题

Chaupal v3.2 - j.java 源代码

正在查看: Chaupal v3.2 应用的 j.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.airbnb.epoxy;

import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import androidx.annotation.NonNull;
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;
import org.jetbrains.annotations.NotNull;

public abstract class j {
    private static final int DELAY_TO_CHECK_ADAPTER_COUNT_MS = 3000;
    private static final h0 NO_OP_TIMER = new a0();
    public static Handler defaultDiffingHandler;
    public static Handler defaultModelBuildingHandler;
    private static boolean filterDuplicatesDefault;
    private static boolean globalDebugLoggingEnabled;
    private static d globalExceptionHandler;
    private final k adapter;
    private final Runnable buildModelsRunnable;
    private l debugObserver;
    private volatile boolean filterDuplicates;
    private volatile boolean hasBuiltModelsEver;
    private final com.airbnb.epoxy.d helper;
    private final List<e> interceptors;
    private final Handler modelBuildHandler;
    private List<f> modelInterceptorCallbacks;
    private ControllerModelList modelsBeingBuilt;
    private int recyclerViewAttachCount;
    private volatile int requestedModelBuildType;
    private n<?> stagedModel;
    private volatile Thread threadBuildingModels;
    private h0 timer;

    class a implements Runnable {
        a() {
        }

        @Override
        public void run() {
            j.this.threadBuildingModels = Thread.currentThread();
            j.this.cancelPendingModelBuild();
            j.this.helper.resetAutoModels();
            j.this.modelsBeingBuilt = new ControllerModelList(j.this.getExpectedModelCount());
            j.this.timer.a("Models built");
            try {
                j.this.buildModels();
                j.this.addCurrentlyStagedModelIfExists();
                j.this.timer.stop();
                j.this.runInterceptors();
                j jVar = j.this;
                jVar.filterDuplicatesIfNeeded(jVar.modelsBeingBuilt);
                j.this.modelsBeingBuilt.freeze();
                j.this.timer.a("Models diffed");
                j.this.adapter.K(j.this.modelsBeingBuilt);
                j.this.timer.stop();
                j.this.modelsBeingBuilt = null;
                j.this.hasBuiltModelsEver = true;
                j.this.threadBuildingModels = null;
            } catch (Throwable th) {
                j.this.timer.stop();
                j.this.modelsBeingBuilt = null;
                j.this.hasBuiltModelsEver = true;
                j.this.threadBuildingModels = null;
                j.this.stagedModel = null;
                throw th;
            }
        }
    }

    class b implements d {
        b() {
        }

        @Override
        public void a(@NonNull j jVar, @NonNull RuntimeException runtimeException) {
        }
    }

    class c implements Runnable {
        c() {
        }

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

    public interface e {
        void a(@NonNull List<n<?>> list);
    }

    interface f {
        void a(j jVar);

        void b(j jVar);
    }

    static {
        Handler handler = y.f6638c.f6635a;
        defaultModelBuildingHandler = handler;
        defaultDiffingHandler = handler;
        filterDuplicatesDefault = false;
        globalDebugLoggingEnabled = false;
        globalExceptionHandler = new b();
    }

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

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

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

    public void filterDuplicatesIfNeeded(List<n<?>> list) {
        if (this.filterDuplicates) {
            this.timer.a("Duplicates filtered");
            HashSet hashSet = new HashSet(list.size());
            ListIterator<n<?>> listIterator = list.listIterator();
            while (listIterator.hasNext()) {
                n<?> next = listIterator.next();
                if (!hashSet.add(Long.valueOf(next.p()))) {
                    int previousIndex = listIterator.previousIndex();
                    listIterator.remove();
                    int findPositionOfDuplicate = findPositionOfDuplicate(list, next);
                    n<?> nVar = 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" + nVar + "\nDuplicate has position " + previousIndex + ":\n" + next));
                }
            }
            this.timer.stop();
        }
    }

    private int findPositionOfDuplicate(List<n<?>> list, n<?> nVar) {
        int size = list.size();
        for (int i7 = 0; i7 < size; i7++) {
            if (list.get(i7).p() == nVar.p()) {
                return i7;
            }
        }
        throw new IllegalArgumentException("No duplicates in list");
    }

    public int getExpectedModelCount() {
        int itemCount = this.adapter.getItemCount();
        if (itemCount != 0) {
            return itemCount;
        }
        return 25;
    }

    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 z6) {
        globalDebugLoggingEnabled = z6;
    }

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

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

    public void add(@NonNull n<?> nVar) {
        nVar.e(this);
    }

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

    void addCurrentlyStagedModelIfExists() {
        n<?> nVar = this.stagedModel;
        if (nVar != null) {
            nVar.e(this);
        }
        this.stagedModel = null;
    }

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

    void addInternal(n<?> nVar) {
        assertIsBuildingModels();
        if (nVar.o()) {
            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.");
        }
        if (!nVar.t()) {
            throw new IllegalEpoxyUsage("You cannot hide a model in an EpoxyController. Use `addIf` to conditionally add a model instead.");
        }
        clearModelFromStaging(nVar);
        nVar.f6587f = null;
        this.modelsBeingBuilt.add(nVar);
    }

    public void addModelBuildListener(d0 d0Var) {
        this.adapter.D(d0Var);
    }

    protected abstract void buildModels();

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

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

    @NonNull
    public k getAdapter() {
        return this.adapter;
    }

    int getFirstIndexOfModelInBuildingList(n<?> nVar) {
        assertIsBuildingModels();
        int size = this.modelsBeingBuilt.size();
        for (int i7 = 0; i7 < size; i7++) {
            if (this.modelsBeingBuilt.get(i7) == nVar) {
                return i7;
            }
        }
        return -1;
    }

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

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

    @NonNull
    public GridLayoutManager.c getSpanSizeLookup() {
        return this.adapter.k();
    }

    public boolean hasPendingModelBuild() {
        return (this.requestedModelBuildType == 0 && this.threadBuildingModels == null && !this.adapter.G()) ? false : true;
    }

    protected boolean isBuildingModels() {
        return this.threadBuildingModels == Thread.currentThread();
    }

    public boolean isDebugLoggingEnabled() {
        return this.timer != NO_OP_TIMER;
    }

    public boolean isDuplicateFilteringEnabled() {
        return this.filterDuplicates;
    }

    boolean isModelAddedMultipleTimes(n<?> nVar) {
        assertIsBuildingModels();
        int size = this.modelsBeingBuilt.size();
        int i7 = 0;
        for (int i8 = 0; i8 < size; i8++) {
            if (this.modelsBeingBuilt.get(i8) == nVar) {
                i7++;
            }
        }
        return i7 > 1;
    }

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

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

    public void moveModel(int i7, int i8) {
        assertNotBuildingModels();
        this.adapter.H(i7, i8);
        requestDelayedModelBuild(500);
    }

    public void notifyModelChanged(int i7) {
        assertNotBuildingModels();
        this.adapter.I(i7);
    }

    protected void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
    }

    void onAttachedToRecyclerViewInternal(RecyclerView recyclerView) {
        int i7 = this.recyclerViewAttachCount + 1;
        this.recyclerViewAttachCount = i7;
        if (i7 > 1) {
            y.f6638c.f6635a.postDelayed(new c(), 3000L);
        }
        onAttachedToRecyclerView(recyclerView);
    }

    protected void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
    }

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

    protected void onExceptionSwallowed(@NonNull RuntimeException runtimeException) {
        globalExceptionHandler.a(this, runtimeException);
    }

    protected void onModelBound(@NonNull q qVar, @NonNull n<?> nVar, int i7, n<?> nVar2) {
    }

    protected void onModelUnbound(@NonNull q qVar, @NonNull n<?> nVar) {
    }

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

    public void onSaveInstanceState(@NonNull Bundle bundle) {
        this.adapter.w(bundle);
    }

    protected void onViewAttachedToWindow(@NonNull q qVar, @NonNull n<?> nVar) {
    }

    protected void onViewDetachedFromWindow(@NonNull q qVar, @NonNull n<?> nVar) {
    }

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

    public void removeModelBuildListener(d0 d0Var) {
        this.adapter.J(d0Var);
    }

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

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

    public void setDebugLoggingEnabled(boolean z6) {
        assertNotBuildingModels();
        if (z6) {
            this.timer = new com.airbnb.epoxy.f(getClass().getSimpleName());
            if (this.debugObserver == null) {
                this.debugObserver = new l(getClass().getSimpleName());
            }
            this.adapter.registerAdapterDataObserver(this.debugObserver);
            return;
        }
        this.timer = NO_OP_TIMER;
        l lVar = this.debugObserver;
        if (lVar != null) {
            this.adapter.unregisterAdapterDataObserver(lVar);
        }
    }

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

    public void setSpanCount(int i7) {
        this.adapter.A(i7);
    }

    void setStagedModel(n<?> nVar) {
        if (nVar != this.stagedModel) {
            addCurrentlyStagedModelIfExists();
        }
        this.stagedModel = nVar;
    }

    public void setupStickyHeaderView(@NotNull View view) {
    }

    public void teardownStickyHeaderView(@NotNull View view) {
    }

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

    protected void add(@NonNull n<?>... nVarArr) {
        ControllerModelList controllerModelList = this.modelsBeingBuilt;
        controllerModelList.ensureCapacity(controllerModelList.size() + nVarArr.length);
        for (n<?> nVar : nVarArr) {
            add(nVar);
        }
    }

    protected void add(@NonNull List<? extends n<?>> list) {
        ControllerModelList controllerModelList = this.modelsBeingBuilt;
        controllerModelList.ensureCapacity(controllerModelList.size() + list.size());
        Iterator<? extends n<?>> it = list.iterator();
        while (it.hasNext()) {
            add(it.next());
        }
    }
}