package com.bytedance.android.livesdk.broadcast.interaction.toolbar;

import X.0CH;
import X.0ZZ;
import X.0Zc;
import X.0Ze;
import X.0b0;
import X.0cm;
import X.158;
import X.15A;
import X.15B;
import X.2D8;
import X.BRR;
import X.C1044Fun;
import X.C1064Fv7;
import X.C1336FzV;
import X.C1337FzW;
import X.C1393G1a;
import X.C1856GIv;
import X.C2103GSi;
import X.C2104GSj;
import X.C2402Gbb;
import X.C3491GtA;
import X.C5627HmW;
import X.C5629HmY;
import X.C5633Hmc;
import X.K4o;
import X.K4r;
import X.KB8;
import X.Kek;
import X.LsC;
import X.M12;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.DialogInterface;
import android.net.Uri;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import com.bytedance.android.live.base.model.user.User;
import com.bytedance.android.live.browser.IBrowserService;
import com.bytedance.android.live.browser.IHybridContainerService;
import com.bytedance.android.livesdk.LiveDialogFragment;
import com.bytedance.android.livesdk.livesetting.broadcast.BroadcastLiveCenterUrl;
import com.bytedance.android.livesdk.livesetting.broadcast.LiveCenterLayoutStyleSetting;
import com.bytedance.android.livesdk.model.RoomAuthStatus;
import com.bytedance.android.livesdkapi.depend.model.live.Room;
import com.bytedance.android.livesdkapi.host.IHostAction;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import java.util.HashMap;
import java.util.List;
import kotlin.h.b.n;
import org.json.JSONObject;

public final class ToolbarButtonMoreDialog extends LiveDialogFragment implements C5633Hmc {
    public static final C2104GSj LIZ = new C2104GSj((byte) 0);
    public final 0Ze LIZIZ;
    public Kek LIZJ;
    public ValueAnimator LIZLLL;
    public long LJ;
    public final List<158> LJFF;
    public final DataChannel LJI;
    public HashMap LJII;

    static {
        Covode.recordClassIndex(11867);
    }

    public final View LIZ(int i) {
        if (this.LJII == null) {
            this.LJII = new HashMap();
        }
        View view = (View) this.LJII.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LJII.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

    public final /* synthetic */ void onDestroyView() {
        super.onDestroyView();
        z_();
    }

    public final void z_() {
        HashMap hashMap = this.LJII;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public final C1044Fun LIZ() {
        C1044Fun fun = new C1044Fun(2131561637);
        fun.LIZ = 2;
        fun.LIZIZ = 2131887253;
        fun.LJI = 80;
        fun.LJIIIZ = 50;
        return fun;
    }

    public final void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        this.LJI.LIZ((0CH) this, 2D8.class, new C1337FzW(this));
    }

    private final void LIZIZ(BRR brr) {
        float f;
        ValueAnimator duration;
        LinearLayout linearLayout = (LinearLayout) LIZ(2131369304);
        n.LIZIZ(linearLayout, "");
        ViewGroup.LayoutParams layoutParams = linearLayout.getLayoutParams();
        K4r k4r = brr.LIZIZ;
        if (k4r != null) {
            f = (float) K4o.LIZ(k4r, "height", 160);
        } else {
            f = 160.0f;
        }
        ValueAnimator ofInt = ObjectAnimator.ofInt(new int[]{layoutParams.height, 0b0.LIZ(f)});
        this.LIZLLL = ofInt;
        if (ofInt != null) {
            ofInt.addUpdateListener(new C1336FzV(this, layoutParams));
        }
        ValueAnimator valueAnimator = this.LIZLLL;
        if (valueAnimator != null && (duration = valueAnimator.setDuration(300)) != null) {
            duration.start();
        }
    }

    public final void LIZ(BRR brr) {
        Boolean bool;
        Room room;
        RoomAuthStatus roomAuthStatus;
        M12.LIZ(brr);
        if (n.LIZ(brr.LIZ, "anchor_center_request_room_info")) {
            LIZIZ(brr);
            long currentTimeMillis = System.currentTimeMillis();
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("room_id", String.valueOf(C2402Gbb.LIZ.LJIIIIZZ()));
            DataChannel dataChannel = this.LJIILIIL;
            if (dataChannel == null || (room = (Room) dataChannel.LIZIZ(C1064Fv7.class)) == null || (roomAuthStatus = room.getRoomAuthStatus()) == null) {
                bool = null;
            } else {
                bool = Boolean.valueOf(roomAuthStatus.isEnableGift());
            }
            jSONObject.put("gift_permission", bool);
            C5629HmY.LIZ(new C5627HmW("anchor_center_response_room_info", currentTimeMillis, new KB8(jSONObject)));
        }
        if (n.LIZ(brr.LIZ, "anchor_center_receive_flash_card")) {
            LIZIZ(brr);
        }
    }

    public final void onDismiss(DialogInterface dialogInterface) {
        super.onDismiss(dialogInterface);
        15A.POPUP.release(this.LJIILIIL);
        0Ze r0 = this.LIZIZ;
        if (r0 != null) {
            r0.LIZ();
        }
        if (LiveCenterLayoutStyleSetting.INSTANCE.enableNewStyle()) {
            long currentTimeMillis = System.currentTimeMillis();
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("room_id", String.valueOf(C2402Gbb.LIZ.LJIIIIZZ()));
            C5629HmY.LIZ(new C5627HmW("live_anchor_center_mask_will_disappear", currentTimeMillis, new KB8(jSONObject)));
            C3491GtA LIZ2 = C3491GtA.LJFF.LIZ("livesdk_live_center_leave");
            LIZ2.LIZ(this.LJIILIIL);
            LIZ2.LIZ("enter_type", "click_more");
            LIZ2.LIZ("duration", SystemClock.elapsedRealtime() - this.LJ);
            LIZ2.LIZLLL();
        }
        C5629HmY.LIZIZ("anchor_center_request_room_info", (C5633Hmc) this);
        C5629HmY.LIZIZ("anchor_center_receive_flash_card", (C5633Hmc) this);
        Kek kek = this.LIZJ;
        if (kek != null) {
            kek.LIZJ();
        }
    }

    public ToolbarButtonMoreDialog(List<? extends 158> list, DataChannel dataChannel) {
        M12.LIZ(list, dataChannel);
        this.LJFF = list;
        this.LJI = dataChannel;
        IBrowserService LIZ2 = 0cm.LIZ(IBrowserService.class);
        n.LIZIZ(LIZ2, "");
        this.LIZIZ = LIZ2.getHybridContainerManager();
    }

    public final void onViewCreated(View view, Bundle bundle) {
        DataChannel dataChannel;
        Room room;
        C1856GIv streamType;
        Long l;
        Long l2;
        Room room2;
        RoomAuthStatus roomAuthStatus;
        Room room3;
        User owner;
        Room room4;
        MethodCollector.i(10078);
        View view2 = view;
        M12.LIZ(view2);
        super.onViewCreated(view2, bundle);
        15A r5 = 15A.POPUP;
        DataChannel dataChannel2 = this.LJI;
        LinearLayout linearLayout = (LinearLayout) LIZ(2131371330);
        if (linearLayout == null) {
            MethodCollector.o(10078);
            return;
        }
        r5.createHolder(dataChannel2, linearLayout, this.LJFF, 15B.ICON_TITLE_HORIZONTAL);
        if (!(!LiveCenterLayoutStyleSetting.INSTANCE.enableNewStyle() || (dataChannel = this.LJIILIIL) == null || (room = (Room) dataChannel.LIZIZ(C1064Fv7.class)) == null || (streamType = room.getStreamType()) == null || !C1393G1a.LIZIZ(streamType))) {
            LinearLayout linearLayout2 = (LinearLayout) LIZ(2131369304);
            n.LIZIZ(linearLayout2, "");
            linearLayout2.setVisibility(0);
            Uri.Builder buildUpon = Uri.parse(BroadcastLiveCenterUrl.INSTANCE.getValue()).buildUpon();
            DataChannel dataChannel3 = this.LJIILIIL;
            Boolean bool = null;
            if (dataChannel3 == null || (room4 = (Room) dataChannel3.LIZIZ(C1064Fv7.class)) == null) {
                l = null;
            } else {
                l = Long.valueOf(room4.getId());
            }
            Uri.Builder appendQueryParameter = buildUpon.appendQueryParameter("room_id", String.valueOf(l));
            DataChannel dataChannel4 = this.LJIILIIL;
            if (dataChannel4 == null || (room3 = (Room) dataChannel4.LIZIZ(C1064Fv7.class)) == null || (owner = room3.getOwner()) == null) {
                l2 = null;
            } else {
                l2 = Long.valueOf(owner.getId());
            }
            Uri.Builder appendQueryParameter2 = appendQueryParameter.appendQueryParameter("anchor_id", String.valueOf(l2));
            DataChannel dataChannel5 = this.LJIILIIL;
            if (!(dataChannel5 == null || (room2 = (Room) dataChannel5.LIZIZ(C1064Fv7.class)) == null || (roomAuthStatus = room2.getRoomAuthStatus()) == null)) {
                bool = Boolean.valueOf(roomAuthStatus.isEnableGift());
            }
            Uri build = appendQueryParameter2.appendQueryParameter("gift_permission", String.valueOf(bool)).appendQueryParameter("is_in_native", "1").build();
            String uri = build.toString();
            n.LIZIZ(uri, "");
            if (0cm.LIZ(IHostAction.class).hostInterceptSpark(uri)) {
                Context context = getContext();
                if (context != null) {
                    n.LIZIZ(context, "");
                    this.LIZJ = 0ZZ.LIZ(0cm.LIZ(IHybridContainerService.class), context, uri, (String) null, false, false, (LsC) null, 60);
                    ((LinearLayout) LIZ(2131369304)).addView(this.LIZJ, -1, -1);
                }
            } else {
                0Ze r2 = this.LIZIZ;
                if (r2 != null) {
                    String uri2 = build.toString();
                    LinearLayout linearLayout3 = (LinearLayout) LIZ(2131369304);
                    n.LIZIZ(linearLayout3, "");
                    0Zc.LIZ(r2, "lynx", uri2, "", linearLayout3, new C2103GSi());
                }
            }
            long currentTimeMillis = System.currentTimeMillis();
            JSONObject jSONObject = new JSONObject();
            jSONObject.put("room_id", String.valueOf(C2402Gbb.LIZ.LJIIIIZZ()));
            C5629HmY.LIZ(new C5627HmW("live_anchor_center_mask_will_appear", currentTimeMillis, new KB8(jSONObject)));
            C3491GtA LIZ2 = C3491GtA.LJFF.LIZ("livesdk_live_center_show");
            LIZ2.LIZ(this.LJI);
            LIZ2.LIZ("enter_type", "click_more");
            LIZ2.LIZLLL();
            this.LJ = SystemClock.elapsedRealtime();
        }
        C5629HmY.LIZ("anchor_center_request_room_info", (C5633Hmc) this);
        C5629HmY.LIZ("anchor_center_receive_flash_card", (C5633Hmc) this);
        MethodCollector.o(10078);
    }
}
