package com.ss.android.ugc.aweme.live.jsb;

import X.0CB;
import X.0CH;
import X.0HH;
import X.6Is;
import X.FIu;
import X.KKi;
import X.Lea;
import X.M12;
import android.content.Context;
import com.bytedance.android.livesdkapi.session.EnterRoomConfig;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.fe.base.BaseCommonJavaMethod;
import com.ss.android.ugc.aweme.live.ILiveOuterService;
import com.ss.android.ugc.aweme.live.LiveOuterService;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import kotlin.h.b.n;
import org.json.JSONArray;
import org.json.JSONObject;

public final class LiveMethod extends BaseCommonJavaMethod implements 6Is {
    public final WeakReference<Context> LIZ;

    static {
        Covode.recordClassIndex(91186);
    }

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

    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public LiveMethod(WeakReference<Context> weakReference, KKi kKi) {
        super(kKi);
        M12.LIZ(weakReference);
        this.LIZ = weakReference;
    }

    public final void handle(JSONObject jSONObject, FIu fIu) {
        if (jSONObject != null) {
            try {
                JSONArray jSONArray = jSONObject.getJSONArray("room_id_list");
                ArrayList arrayList = new ArrayList();
                int length = jSONArray.length();
                for (int i = 0; i < length; i++) {
                    arrayList.add(Long.valueOf(Long.parseLong(jSONArray.get(i).toString())));
                }
                String string = jSONObject.getString("current_room_id");
                n.LIZIZ(string, "");
                long parseLong = Long.parseLong(string);
                String string2 = jSONObject.getString("enter_from");
                EnterRoomConfig enterRoomConfig = new EnterRoomConfig();
                enterRoomConfig.LIZLLL.LJJJJZI = parseLong;
                enterRoomConfig.LIZLLL.LJJJJI = string2;
                enterRoomConfig.LIZLLL.LJJJI = Lea.LJI(arrayList);
                ILiveOuterService LJJI = LiveOuterService.LJJI();
                n.LIZIZ(LJJI, "");
                LJJI.LJIIIZ().LIZ((Context) this.LIZ.get(), enterRoomConfig);
                if (fIu != null) {
                    fIu.LIZ((Object) null);
                }
            } catch (Exception e) {
                if (fIu != null) {
                    fIu.LIZ(-1, e.getMessage());
                }
                0HH.LIZ(e);
            }
        }
    }
}
