package com.ss.android.ugc.aweme.sec.captcha;

import X.0CB;
import X.0CH;
import X.0CN;
import X.2kf;
import X.6Is;
import X.7he;
import X.9hh;
import X.C1305KaW;
import X.C4580LmF;
import X.C4583LmI;
import X.C4584LmJ;
import X.C4590LmP;
import X.C4594LmT;
import X.C4638LnB;
import X.C4639LnC;
import X.C4641LnE;
import X.Crj;
import X.KE3;
import X.M12;
import android.app.Activity;
import android.content.Context;
import com.bytedance.covode.number.Covode;
import java.lang.ref.WeakReference;

public final class SecCaptcha implements C4641LnE, 6Is {
    public static final C4638LnB LJIIIIZZ = new C4638LnB((byte) 0);
    public final C4590LmP LIZ;
    public WeakReference<Activity> LIZIZ;
    public KE3 LIZJ;
    public String LIZLLL;
    public String LJ;
    public final Context LJFF;
    public final C4584LmJ LJI;
    public final C4639LnC LJII;
    public final Crj LJIIIZ = 7he.LIZ(new C4583LmI(this));

    static {
        Covode.recordClassIndex(104886);
    }

    public final C4580LmF LIZ() {
        return (C4580LmF) this.LJIIIZ.getValue();
    }

    public final void onStateChanged(0CH r2, 0CB r3) {
        if (r3 == 0CB.ON_DESTROY) {
            release();
        }
    }

    @0CN(LIZ = 0CB.ON_DESTROY)
    public final void release() {
        Activity activity;
        WeakReference<Activity> weakReference = this.LIZIZ;
        if (weakReference != null) {
            activity = (Activity) weakReference.get();
        } else {
            activity = null;
        }
        if (activity instanceof 0CH) {
            ((0CH) activity).getLifecycle().LIZIZ(this);
        }
        C4590LmP lmP = this.LIZ;
        if (lmP != null) {
            lmP.LIZIZ();
        }
    }

    public final void LIZIZ(int i) {
        2kf.LIZ(4, "Sec", "popCaptcha-onSuccess, code=".concat(String.valueOf(i)));
        KE3 ke3 = this.LIZJ;
        if (ke3 != null) {
            ke3.LIZ(true, i);
        }
    }

    public final void LIZ(int i) {
        2kf.LIZ(4, "Sec", "popCaptcha-onFail, code=".concat(String.valueOf(i)));
        KE3 ke3 = this.LIZJ;
        if (ke3 != null) {
            ke3.LIZ(false, i);
        }
        KE3 ke32 = this.LIZJ;
        if (ke32 != null) {
            ke32.LIZ();
        }
    }

    public final void LIZ(String str, String str2) {
        M12.LIZ((Object) str, (Object) str2);
        this.LJI.LIZIZ(str);
        this.LJI.LIZ(str2);
        LIZ().LJII = this.LJI.LIZLLL;
        LIZ().LJIIJJI = this.LJI.LJ;
    }

    public SecCaptcha(Context context, C4584LmJ lmJ, C4639LnC lnC) {
        M12.LIZ(context, lmJ, lnC);
        this.LJFF = context;
        this.LJI = lmJ;
        this.LJII = lnC;
        C4590LmP lmP = C1305KaW.LIZ;
        lmP.LIZ(LIZ());
        this.LIZ = lmP;
        String LIZ2 = lnC.LIZ();
        String str = "";
        this.LIZLLL = LIZ2 == null ? str : LIZ2;
        String LIZIZ2 = lnC.LIZIZ();
        this.LJ = LIZIZ2 != null ? LIZIZ2 : str;
        9hh.LIZ(new C4594LmT());
    }
}
