package com.ss.android.ugc.aweme.compliance.privacy.settings.video.items.permission.page;

import X.0EB;
import X.0HH;
import X.1Cn;
import X.6iy;
import X.7he;
import X.AnonymousClass3YD;
import X.C03012Pr;
import X.C16832uR;
import X.C30983cA;
import X.C31003cC;
import X.C38983p4;
import X.C39953qd;
import X.C40053qn;
import X.C40113qt;
import X.C40123qu;
import X.C40133qv;
import X.C40143qw;
import X.C40153qx;
import X.C40163qy;
import X.C40173qz;
import X.C40183r0;
import X.C42523um;
import X.Crj;
import X.Ls2;
import X.M12;
import X.Qeg;
import X.Tpu;
import android.content.Context;
import android.os.Bundle;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.compliance.privacy.settings.video.items.permission.VideoVisibilityViewModel;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.views.WrapLinearLayoutManager;
import kotlin.h.b.n;

public final class VideoVisibilitySelectFragment extends Fragment implements AnonymousClass3YD {
    public final Crj LIZ = 7he.LIZ(new C40113qt(this));
    public C39953qd LIZIZ;
    public final Crj LIZJ = 7he.LIZ(new C40173qz(this));
    public final Crj LIZLLL = 7he.LIZ(new C40183r0(this));
    public final Crj LJ = 7he.LIZ(new C40163qy(this));
    public SparseArray LJFF;

    static {
        Covode.recordClassIndex(61931);
    }

    private final VideoVisibilityViewModel LIZ() {
        return (VideoVisibilityViewModel) this.LIZ.getValue();
    }

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

    public final /* synthetic */ void onDestroyView() {
        VideoVisibilitySelectFragment.super.onDestroyView();
        SparseArray sparseArray = this.LJFF;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    public final C16832uR ch_() {
        String string;
        if (C40123qu.LIZIZ(LIZ().LIZ())) {
            string = getString(2131830811);
            n.LIZIZ(string, "");
        } else {
            string = getString(2131833598);
            n.LIZIZ(string, "");
        }
        C16832uR r5 = new C16832uR();
        C30983cA r1 = new C30983cA();
        r1.LIZ(2131755740);
        r1.LIZ((Ls2<C03012Pr>) new C40143qw(this));
        r5.LIZIZ(r1);
        C31003cC r0 = new C31003cC();
        r0.LIZ(string);
        r5.LIZ(r0);
        r5.LIZLLL = true;
        C30983cA r12 = new C30983cA();
        r12.LIZ(2131755248);
        r12.LIZ((Ls2<C03012Pr>) new C40153qx(this));
        r5.LIZ(r12);
        return r5;
    }

    public final void onViewCreated(View view, Bundle bundle) {
        String str;
        Tpu commerceVideoAuthInfo;
        M12.LIZ(view);
        VideoVisibilitySelectFragment.super.onViewCreated(view, bundle);
        getContext();
        boolean z = true;
        WrapLinearLayoutManager wrapLinearLayoutManager = new WrapLinearLayoutManager(1);
        String str2 = (String) this.LJ.getValue();
        n.LIZIZ(str2, "");
        String str3 = (String) this.LIZJ.getValue();
        n.LIZIZ(str3, "");
        String str4 = (String) this.LIZLLL.getValue();
        n.LIZIZ(str4, "");
        this.LIZIZ = new C39953qd(LIZ(), this, str2, str3, str4);
        RecyclerView LIZ2 = LIZ(2131367123);
        n.LIZIZ(LIZ2, "");
        LIZ2.setLayoutManager(wrapLinearLayoutManager);
        RecyclerView LIZ3 = LIZ(2131367123);
        n.LIZIZ(LIZ3, "");
        LIZ3.setItemAnimator((0EB) null);
        RecyclerView LIZ4 = LIZ(2131367123);
        n.LIZIZ(LIZ4, "");
        C39953qd r0 = this.LIZIZ;
        if (r0 == null) {
            n.LIZ("");
        }
        LIZ4.setAdapter(new 1Cn(6iy.LIZ(r0)));
        boolean LJII = C40123qu.LJII(LIZ().LIZ());
        Aweme LIZ5 = LIZ().LIZ();
        if (LIZ5 == null || (commerceVideoAuthInfo = LIZ5.getCommerceVideoAuthInfo()) == null || (str = commerceVideoAuthInfo.getPreventPrivacyReason()) == null) {
            str = "";
        }
        if (LJII) {
            if (str.length() <= 0) {
                z = false;
            }
            if (z) {
                Qeg LIZ6 = LIZ(2131372755);
                n.LIZIZ(LIZ6, "");
                LIZ6.setText(str);
            }
            Qeg LIZ7 = LIZ(2131372755);
            n.LIZIZ(LIZ7, "");
            LIZ7.setVisibility(0);
        }
        Context context = getContext();
        if (context == null) {
            n.LIZIZ();
        }
        n.LIZIZ(context, "");
        int LJFF2 = C40123qu.LJFF(LIZ().LIZ());
        String valueOf = String.valueOf(C40123qu.LJI(LIZ().LIZ()));
        C40133qv r1 = new C40133qv(this);
        M12.LIZ(context, r1);
        C40053qn.LIZ.refreshMissionState(context, LJFF2, valueOf, r1);
        if (!C42523um.LIZJ.LIZIZ() || !C38983p4.LIZ.LIZIZ()) {
            Qeg LIZ8 = LIZ(2131368829);
            n.LIZIZ(LIZ8, "");
            LIZ8.setVisibility(8);
            return;
        }
        Qeg LIZ9 = LIZ(2131368829);
        n.LIZIZ(LIZ9, "");
        LIZ9.setVisibility(0);
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        return 0HH.LIZ(layoutInflater, 2131559448, viewGroup, false);
    }
}
