package com.bytedance.ies.ugc.statisticlogger.config;

import X.2P1;
import X.AnonymousClass8YD;
import X.AnonymousClass9EH;
import X.AnonymousClass9K1;
import X.AnonymousClass9K6;
import X.AnonymousClass9K7;
import X.AnonymousClass9K8;
import X.AnonymousClass9K9;
import X.AnonymousClass9KA;
import X.AnonymousClass9KB;
import X.AnonymousClass9KC;
import X.C06687pL;
import X.C11817xc;
import X.C22428Zd;
import X.C22438Ze;
import X.C25518ec;
import X.C42869Ft;
import X.C42909Fx;
import X.C43899Js;
import X.C43909Jt;
import X.M12;
import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.common.applog.AppLog;
import java.util.LinkedList;
import java.util.List;
import kotlin.h.b.n;

public final class LazyLoadLegoTask implements C22438Ze {
    public final Application LIZ;

    static {
        Covode.recordClassIndex(31137);
    }

    public final boolean meetTrigger() {
        return true;
    }

    public final String prefix() {
        return "task_";
    }

    public final boolean serialExecute() {
        return false;
    }

    public final int targetProcess() {
        return 1048575;
    }

    public final List triggerOtherLegoComponents() {
        return null;
    }

    public final C42869Ft triggerType() {
        return C22428Zd.LIZ(this);
    }

    public final C42909Fx scenesType() {
        return C42909Fx.DEFAULT;
    }

    public final C25518ec type() {
        return C25518ec.BACKGROUND;
    }

    public final String key() {
        return getClass().getSimpleName();
    }

    public LazyLoadLegoTask(Application application) {
        M12.LIZ(application);
        this.LIZ = application;
    }

    public final void run(Context context) {
        LinkedList linkedList;
        MethodCollector.i(13818);
        M12.LIZ(context);
        AnonymousClass9K9 r1 = new AnonymousClass9K9();
        String str = AnonymousClass9EH.LJIILL;
        String str2 = AnonymousClass9EH.LJIILLIIL;
        r1.LIZ = str;
        r1.LIZIZ = str2;
        r1.LIZLLL = AnonymousClass9EH.LJIJI;
        r1.LIZJ = AnonymousClass9KA.RELEASE;
        r1.LJ = AppLog.getServerDeviceId();
        r1.LJI = AnonymousClass9EH.LJJIFFI.LJFF();
        r1.LJII = (int) AnonymousClass9EH.LJJIFFI.LJ();
        r1.LJIIIIZZ = AnonymousClass9EH.LJIILJJIL;
        AnonymousClass9K8 r2 = new AnonymousClass9K8();
        if (!TextUtils.isEmpty(r1.LIZ)) {
            r2.LIZ = r1.LIZ;
        }
        if (!TextUtils.isEmpty(r1.LIZIZ)) {
            r2.LIZIZ = r1.LIZIZ;
        }
        if (r1.LIZJ != null) {
            r2.LIZJ = r1.LIZJ;
        }
        if (!TextUtils.isEmpty(r1.LIZLLL)) {
            r2.LIZLLL = r1.LIZLLL;
        }
        if (!TextUtils.isEmpty(r1.LJ)) {
            r2.LJ = r1.LJ;
        }
        if (!TextUtils.isEmpty(r1.LJFF)) {
            r2.LJIIIZ = r1.LJFF;
        }
        if (!TextUtils.isEmpty(r1.LJI)) {
            r2.LJFF = r1.LJI;
        }
        if (r1.LJII != 0) {
            r2.LJI = r1.LJII;
        }
        r2.LJIIIIZZ = r1.LJIIIZ;
        r2.LJII = r1.LJIIIIZZ;
        n.LIZIZ(r2, "");
        Application application = this.LIZ;
        boolean LIZ2 = C11817xc.LIZ(context);
        AnonymousClass9K7 r6 = AnonymousClass9K1.LIZ;
        r6.LJFF = application;
        r6.LJI = r2;
        AnonymousClass9K6 r3 = new AnonymousClass9K6();
        String LIZ3 = r3.LIZ();
        if (!TextUtils.isEmpty(LIZ3) && LIZ2) {
            if (!(r6.LJFF == null || r6.LJI == null)) {
                r3.LIZ(r6.LJFF, r6.LJI);
            }
            r6.LIZ.put(LIZ3, r3);
        }
        if (((Boolean) C06687pL.LIZ.getValue()).booleanValue()) {
            r6.LIZJ.set(true);
            if (r6.LIZIZ.get() && !r6.LJ.isEmpty()) {
                synchronized (r6.LJ) {
                    try {
                        linkedList = new LinkedList(r6.LJ);
                        r6.LJ.clear();
                        AnonymousClass9K7.LIZLLL.clear();
                    } catch (Throwable th) {
                        MethodCollector.o(13818);
                        throw th;
                    }
                }
                long j = 0;
                while (!linkedList.isEmpty()) {
                    j += 100;
                    2P1 r4 = (2P1) linkedList.poll();
                    if (C06687pL.LIZIZ.LIZIZ()) {
                        AnonymousClass8YD.LIZ.postDelayed(new AnonymousClass9KC(r6, r4), j);
                    } else {
                        r6.LIZ(r4);
                    }
                }
            }
            AnonymousClass8YD.LIZ.postDelayed(new AnonymousClass9KB(r6), 5000);
        } else {
            r6.LIZIZ.set(true);
            r6.LIZ();
        }
        C43909Jt.LIZ = true;
        new Handler(Looper.getMainLooper()).postAtFrontOfQueue(C43899Js.LIZ);
        MethodCollector.o(13818);
    }
}
