package com.ss.android.ugc.aweme.fe.method;

import X.0CB;
import X.0CH;
import X.6Is;
import X.C0679KDe;
import X.C0680KDf;
import X.C0681KDg;
import X.C0682KDh;
import X.C0865KKi;
import X.CqM;
import X.ETN;
import X.FIu;
import X.HtZ;
import android.app.Activity;
import android.content.Context;
import android.webkit.WebView;
import com.bytedance.covode.number.Covode;
import com.bytedance.hybrid.spark.SparkContext;
import com.ss.android.ugc.aweme.fe.base.BaseCommonJavaMethod;
import org.json.JSONObject;

public final class CloseMethod extends BaseCommonJavaMethod implements 6Is {
    public static final C0682KDh LIZ = new C0682KDh((byte) 0);

    static {
        Covode.recordClassIndex(76047);
    }

    public CloseMethod(byte b) {
        this();
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
        super.onStateChanged(r1, r2);
    }

    public /* synthetic */ CloseMethod() {
        this((C0865KKi) null);
    }

    public CloseMethod(C0865KKi kKi) {
        super(kKi);
    }

    public final void handle(JSONObject jSONObject, FIu fIu) {
        int i;
        WebView webView;
        WebView webView2;
        if (this.mJsBridge != null) {
            int i2 = 0;
            if (jSONObject != null) {
                String optString = jSONObject.optString("reactId");
                HtZ LIZ2 = SparkContext.LJ.LIZ(optString);
                if (LIZ2 != null) {
                    LIZ2.LIZJ();
                    return;
                } else if (!(optString == null || optString.length() == 0 || optString == null)) {
                    CqM.LIZ(new C0681KDg(optString));
                    return;
                }
            }
            if (this.mContextRef != null) {
                Context actContext = getActContext();
                if (actContext instanceof Activity) {
                    Activity activity = (Activity) actContext;
                    if (activity.isFinishing()) {
                        return;
                    }
                    if (actContext instanceof ETN) {
                        C0865KKi kKi = this.mJsBridge;
                        if (kKi == null || (webView2 = kKi.LIZLLL) == null) {
                            i = 0;
                        } else {
                            i = webView2.hashCode();
                        }
                        CqM.LIZ(new C0679KDe(i));
                        C0865KKi kKi2 = this.mJsBridge;
                        if (!(kKi2 == null || (webView = kKi2.LIZLLL) == null)) {
                            i2 = webView.hashCode();
                        }
                        CqM.LIZ(new C0680KDf(i2));
                        return;
                    }
                    activity.finish();
                }
            }
        }
    }
}
