package com.bytedance.android.livesdk.chatroom.widget;

import X.0CB;
import X.0CH;
import X.0aP;
import X.0b0;
import X.0c0;
import X.1hK;
import X.1jk;
import X.3bY;
import X.6Is;
import X.8n2;
import X.9EH;
import X.C1185Fx4;
import X.C1271FyS;
import X.C1274FyV;
import X.C1305Fz0;
import X.C1306Fz1;
import X.C1430G2l;
import X.C1832GHx;
import X.G06;
import X.LeS;
import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
import com.bytedance.android.livesdk.livesetting.broadcast.BroadcastInteractionLibraSetting;
import com.bytedance.android.livesdk.livesetting.broadcast.LiveEnableGiftRecordFilter;
import com.bytedance.android.livesdk.model.GameTag;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.widgets.LiveRecyclableWidget;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import kotlin.h.b.n;

public final class ScreenRecordStatusWidget extends LiveRecyclableWidget implements 6Is {
    public static final C1306Fz1 LIZIZ = new C1306Fz1((byte) 0);
    public boolean LIZ;
    public 1jk LIZJ;
    public 1jk LIZLLL;
    public TextView LJ;
    public ArrayList<String> LJFF = new ArrayList<>();
    public boolean LJI = true;

    static {
        Covode.recordClassIndex(14696);
    }

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

    public final void onUnload() {
    }

    public final int getLayoutId() {
        if (BroadcastInteractionLibraSetting.INSTANCE.isExperimentGroup()) {
            return 2131561543;
        }
        return 2131561542;
    }

    public final void show() {
        View view;
        if (!this.LIZ && this.LJI) {
            super.show();
            if (BroadcastInteractionLibraSetting.INSTANCE.isExperimentGroup() && (view = this.contentView) != null) {
                view.post(new C1305Fz0(this));
            }
        }
    }

    public final void LIZ() {
        1jk r2 = this.LIZLLL;
        if (r2 == null) {
            n.LIZ("");
        }
        r2.setText(0b0.LIZ(2131829639));
        1jk r0 = this.LIZLLL;
        if (r0 == null) {
            n.LIZ("");
        }
        3bY.LIZJ(r0);
        1jk r02 = this.LIZJ;
        if (r02 == null) {
            n.LIZ("");
        }
        3bY.LIZ(r02);
        TextView textView = this.LJ;
        if (textView == null) {
            n.LIZ("");
        }
        3bY.LIZ(textView);
    }

    public final void LIZ(boolean z) {
        this.LJI = z;
        if (z) {
            show();
        } else {
            hide();
        }
    }

    public final void onInit(Object[] objArr) {
        String str;
        Resources resources;
        String[] strArr = new String[1];
        View view = getView();
        if (view == null || (resources = view.getResources()) == null || (str = resources.getString(2131830217)) == null) {
            str = "";
        }
        n.LIZIZ(str, "");
        strArr[0] = str;
        this.LJFF = LeS.LIZLLL(strArr);
        1jk findViewById = findViewById(2131371301);
        n.LIZIZ(findViewById, "");
        this.LIZJ = findViewById;
        1jk findViewById2 = findViewById(2131363731);
        n.LIZIZ(findViewById2, "");
        this.LIZLLL = findViewById2;
        View findViewById3 = findViewById(2131370577);
        n.LIZIZ(findViewById3, "");
        this.LJ = (TextView) findViewById3;
        this.dataChannel.LIZ((0CH) this, C1185Fx4.class, new C1274FyV(this));
    }

    public final boolean LIZ(String str) {
        PackageInfo packageInfo;
        try {
            Context LJ2 = 0b0.LJ();
            n.LIZIZ(LJ2, "");
            PackageManager packageManager = LJ2.getPackageManager();
            Context LIZ2 = 9EH.LJJIFFI.LIZ();
            if (8n2.LJIIIZ) {
                TextUtils.equals(str, LIZ2.getPackageName());
            }
            if (!8n2.LJIIIZ || !TextUtils.equals(str, LIZ2.getPackageName())) {
                if (8n2.LJIIIZ) {
                    TextUtils.equals(str, LIZ2.getPackageName());
                }
                if (8n2.LJIIIZ) {
                    TextUtils.equals(str, LIZ2.getPackageName());
                }
                packageInfo = packageManager.getPackageInfo(str, 0);
            } else {
                if (8n2.LIZLLL == null) {
                    8n2.LIZLLL = packageManager.getPackageInfo(str, 0);
                }
                packageInfo = 8n2.LIZLLL;
            }
            if (packageInfo != null) {
                return true;
            }
            return false;
        } catch (PackageManager.NameNotFoundException unused) {
        }
    }

    public final void onLoad(Object[] objArr) {
        TextView textView = this.LJ;
        if (textView == null) {
            n.LIZ("");
        }
        textView.setVisibility(8);
        boolean z = false;
        if (BroadcastInteractionLibraSetting.INSTANCE.isExperimentGroup()) {
            1jk r1 = this.LIZJ;
            if (r1 == null) {
                n.LIZ("");
            }
            r1.setText(0b0.LIZ(2131828835));
            1jk r12 = this.LIZLLL;
            if (r12 == null) {
                n.LIZ("");
            }
            r12.setText(0b0.LIZ(2131828834));
            GameTag LIZIZ2 = G06.LIZJ.LIZIZ();
            if (LIZIZ2 != null) {
                String str = LIZIZ2.packageName;
                if (str == null) {
                    str = "";
                }
                String str2 = LIZIZ2.showName;
                if (str2 == null) {
                    str2 = "";
                }
                if (str.length() > 0 && str2.length() > 0) {
                    TextView textView2 = this.LJ;
                    if (textView2 == null) {
                        n.LIZ("");
                    }
                    textView2.setText(this.context.getString(2131828838, new Object[]{str2}));
                    TextView textView3 = this.LJ;
                    if (textView3 == null) {
                        n.LIZ("");
                    }
                    textView3.setOnClickListener(new C1271FyS(str, str2, this));
                    TextView textView4 = this.LJ;
                    if (textView4 == null) {
                        n.LIZ("");
                    }
                    textView4.setVisibility(0);
                }
            }
        } else {
            1jk r13 = this.LIZJ;
            if (r13 == null) {
                n.LIZ("");
            }
            r13.setText(0b0.LIZ(2131830235));
            1jk r14 = this.LIZLLL;
            if (r14 == null) {
                n.LIZ("");
            }
            r14.setText(0b0.LIZ(2131830234));
        }
        if (LiveEnableGiftRecordFilter.INSTANCE.isEnable()) {
            1hK LIZ2 = C1430G2l.LIZ(this.context);
            if (LIZ2 != null) {
                z = LIZ2.getIntent().getBooleanExtra("live.intent.extra.IS_CONTINUE_LIVE", false);
            }
            0aP.LIZ(4, "ScreenRecordStatusWidget", "isContinueLive = ".concat(String.valueOf(z)));
            if (z) {
                LIZ();
            } else {
                this.lifecycleRegistry.LIZ(new ScreenRecordStatusWidget$onLoad$3(this));
            }
        }
    }

    public final void LIZ(int i, String str) {
        int i2;
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        if (str != null) {
            linkedHashMap.put("pack_name", str);
        }
        if (i != 0) {
            linkedHashMap.put("error_type", Integer.valueOf(i));
        }
        String LIZ2 = C1832GHx.LIZ("livesdk_screen_record_open_game");
        if (i == 0) {
            i2 = 0;
        } else {
            i2 = 1;
        }
        0c0.LIZ(LIZ2, i2, linkedHashMap);
    }
}
