package com.ss.android.ugc.aweme.commercialize.business;

import X.C1897Kk4;
import X.C2140Knz;
import X.C2271Kq6;
import X.C2276KqB;
import X.C2283KqI;
import X.C2329Kr2;
import X.M12;
import X.TSt;
import android.app.Activity;
import android.webkit.WebView;
import android.widget.FrameLayout;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.bullet.business.BulletBusinessService$Business;
import org.json.JSONObject;

public final class DownloadBusiness extends BulletBusinessService$Business {
    public String LIZ;
    public int LIZIZ;
    public int LIZJ;
    public final C2283KqI LIZLLL = new C2283KqI();
    public final boolean LJ;

    static {
        Covode.recordClassIndex(58333);
    }

    public final void LIZ() {
        Activity LIZ2 = this.LJIIJ.LIZ();
        if (LIZ2 != null) {
            int i = this.LIZIZ;
            if (i == 0) {
                i = 2131362006;
            }
            LIZ2.findViewById(i);
        }
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public DownloadBusiness(C2140Knz knz) {
        super(knz);
        M12.LIZ((Object) knz);
    }

    public final void LIZ(WebView webView) {
        FrameLayout frameLayout;
        int i;
        int i2;
        Activity LIZ2 = this.LJIIJ.LIZ();
        C2276KqB kqB = null;
        if (LIZ2 != null) {
            int i3 = this.LIZIZ;
            if (i3 == 0) {
                i3 = 2131362006;
            }
            frameLayout = (FrameLayout) LIZ2.findViewById(i3);
        } else {
            frameLayout = null;
        }
        boolean z = false;
        if (!this.LJ) {
            if (frameLayout != null) {
                frameLayout.setVisibility(8);
            }
        } else if (frameLayout != null) {
            frameLayout.setVisibility(0);
        }
        C1897Kk4 kk4 = this.LJIIJ.LIZ;
        if (kk4 instanceof C2276KqB) {
            kqB = kk4;
        }
        C2276KqB kqB2 = kqB;
        C2283KqI kqI = this.LIZLLL;
        if (kqB2 != null) {
            kqI.LIZ = kqB2.LJJLIIIJLLLLLLLZ.LIZIZ();
            kqI.LIZJ = kqB2.LJII();
            kqI.LIZLLL = kqB2.LIZJ();
            kqI.LJ = kqB2.LJJLIIIJILLIZJL.LIZIZ();
            kqI.LJI = kqB2.LJJLIIIIJ.LIZIZ();
            kqI.LJFF = kqB2.LJJLIIIJ.LIZIZ();
            if (kqB2.LJJLJ.LIZIZ() != null) {
                i = ((Integer) kqB2.LJJLJ.LIZIZ()).intValue();
            } else {
                i = 0;
            }
            kqI.LJII = i;
            kqI.LJIIIZ = kqB2.LJJLIIIJJI.LIZIZ();
            if (kqB2.LJJLL.LIZIZ() != null) {
                i2 = ((Integer) kqB2.LJJLL.LIZIZ()).intValue();
            } else {
                i2 = 0;
            }
            kqI.LJIIL = i2;
            if (kqB2.LJJZZI.LIZIZ() == Boolean.TRUE) {
                z = true;
            }
            kqI.LJIILIIL = z;
            try {
                kqI.LJIIJ = new JSONObject(kqB2.LJJZZIII.LIZIZ());
            } catch (Exception e) {
                TSt.LIZ(e);
            }
            kqI.LJIIJJI = kqB2.LJJLIL.LIZIZ();
            kqI.LJIIIIZZ = kqI.LIZ(kqI.LJII);
            try {
                kqI.LIZIZ = Long.parseLong(kqI.LIZ);
            } catch (Exception e2) {
                TSt.LIZ(e2);
            }
        }
        if (frameLayout != null) {
            frameLayout.setOnClickListener(C2329Kr2.LIZ);
        }
        if (webView != null) {
            webView.setDownloadListener(new C2271Kq6(this, webView, LIZ2, kqB2));
        }
    }
}
