package com.tencent.mm.plugin.appbrand.jsapi.live;

import android.view.View;
import com.google.android.gms.common.internal.ImagesContract;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.plugin.appbrand.jsapi.base.c;
import com.tencent.mm.plugin.appbrand.jsapi.base.g;
import com.tencent.mm.plugin.appbrand.jsapi.coverview.CoverViewContainer;
import com.tencent.mm.plugin.appbrand.jsapi.e;
import com.tencent.mm.plugin.appbrand.s.b;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import org.json.JSONObject;

public final class d extends c {
    private static final int CTRL_INDEX = 363;
    public static final String NAME = "operateLivePusher";

    public final int r(JSONObject jSONObject) {
        AppMethodBeat.i(96114);
        int optInt = jSONObject.optInt("livePusherId");
        AppMethodBeat.o(96114);
        return optInt;
    }

    public final boolean aCE() {
        return true;
    }

    public final boolean b(e eVar, int i, View view, JSONObject jSONObject, g gVar) {
        AppMethodBeat.i(96115);
        ab.i("MicroMsg.JsApiOperateLivePusher", "onOperateView : livePusherId=%d", new Object[]{Integer.valueOf(i)});
        if (view instanceof CoverViewContainer) {
            View view2 = (View) ((CoverViewContainer) view).ah(View.class);
            if (view2 instanceof AppBrandLivePusherView) {
                AppBrandLivePusherView appBrandLivePusherView = (AppBrandLivePusherView) view2;
                String optString = jSONObject.optString("type");
                ab.i("MicroMsg.JsApiOperateLivePusher", "onOperateView operateType=%s", new Object[]{optString});
                if (optString.equalsIgnoreCase("snapshot")) {
                    appBrandLivePusherView.setSnapshotListener(new 2(this, gVar, eVar));
                    if (!appBrandLivePusherView.b("snapshot", null)) {
                        gVar.AR(j("fail:snapshot error", null));
                    }
                } else if (optString.equalsIgnoreCase("playBGM")) {
                    String optString2 = jSONObject.optString(ImagesContract.URL);
                    if (bo.isNullOrNil(optString2)) {
                        ab.w("MicroMsg.JsApiOperateLivePusher", "operatePlayBgm, url is nil");
                        gVar.AR(j("fail:url is nil", null));
                    } else {
                        b.a(eVar, optString2, null, new 1(this, appBrandLivePusherView, optString2));
                        gVar.AR(j("ok", null));
                    }
                } else if (appBrandLivePusherView.b(optString, jSONObject)) {
                    gVar.AR(j("ok", null));
                } else {
                    gVar.AR(j("fail", null));
                }
                boolean b = super.b(eVar, i, view, jSONObject, gVar);
                AppMethodBeat.o(96115);
                return b;
            }
            ab.e("MicroMsg.JsApiOperateLivePusher", "targetView not AppBrandLivePusherView");
            AppMethodBeat.o(96115);
            return false;
        }
        ab.w("MicroMsg.JsApiOperateLivePusher", "the view(%s) is not a instance of CoverViewContainer", new Object[]{Integer.valueOf(i)});
        AppMethodBeat.o(96115);
        return false;
    }
}
