package com.ss.android.ugc.aweme.bullet.bridge.framework;

import X.0CB;
import X.0CH;
import X.4UQ;
import X.6Is;
import X.C3050JJh;
import X.JK4;
import X.KT7;
import X.M12;
import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.text.TextUtils;
import android.view.Window;
import com.bytedance.covode.number.Covode;
import com.google.gson.m;
import com.ss.android.ugc.aweme.bullet.bridge.BaseBridgeMethod;
import org.json.JSONObject;

public final class DarkModeMethod extends BaseBridgeMethod implements 6Is {
    public static final JK4 LIZIZ = new JK4((byte) 0);
    public final String LIZJ = "darkMode";

    static {
        Covode.recordClassIndex(55084);
    }

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

    public final String LIZLLL() {
        return this.LIZJ;
    }

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public DarkModeMethod(KT7 kt7) {
        super(kt7);
        M12.LIZ(kt7);
    }

    public final void LIZ(JSONObject jSONObject, 4UQ r7) {
        Activity activity;
        M12.LIZ(jSONObject, r7);
        String optString = jSONObject.optString("enable");
        try {
            Context LJ = LJ();
            Window window = null;
            if (LJ != null) {
                while (true) {
                    if (!(LJ instanceof Activity)) {
                        if (!(LJ instanceof ContextWrapper) || (LJ = ((ContextWrapper) LJ).getBaseContext()) == null) {
                            break;
                        }
                    } else {
                        activity = (Activity) LJ;
                        break;
                    }
                }
            }
            activity = null;
            C3050JJh jJh = C3050JJh.LIZ;
            if (activity != null) {
                window = activity.getWindow();
            }
            jJh.LIZ(activity, window, TextUtils.equals(optString, "true"));
            r7.LIZ(new m());
        } catch (Exception unused) {
            r7.LIZ(0, "");
        }
    }
}
