package com.ss.android.ugc.aweme.shortvideo.ui;

import X.0HH;
import X.1iq;
import X.2HN;
import X.2nK;
import X.2y9;
import X.C0072FRu;
import X.C0439Ffx;
import X.DVG;
import X.FTO;
import X.FTP;
import X.M12;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.commerce.tools.tcm.CommerceToolsTcmModel;
import com.ss.android.ugc.aweme.commerce.tools.tcm.service.CommerceToolsTcmServiceImpl;
import com.ss.android.ugc.aweme.shortvideo.ui.viewmodel.VideoPublishViewModel;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;
import kotlin.h.b.n;

public class PublishSettingFullScreenPanel extends Fragment {
    public static final FTP LIZJ = new FTP((byte) 0);
    public 2y9 LIZ;
    public 1iq<Boolean> LIZIZ;
    public View LIZLLL;
    public RecyclerView LJ;
    public C0439Ffx LJFF;
    public TextView LJI;
    public HashMap LJII;

    static {
        Covode.recordClassIndex(112785);
    }

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

    public /* synthetic */ void onDestroyView() {
        PublishSettingFullScreenPanel.super.onDestroyView();
        LIZ();
    }

    private final VideoPublishViewModel LIZIZ() {
        VideoPublishViewModel LIZ2 = DVG.LIZ(requireActivity()).LIZ(VideoPublishViewModel.class);
        n.LIZIZ(LIZ2, "");
        return LIZ2;
    }

    public final void LIZ(boolean z) {
        if (z) {
            C0439Ffx ffx = this.LJFF;
            if (ffx != null) {
                ffx.setSubtitle(2131832847);
                return;
            }
            return;
        }
        C0439Ffx ffx2 = this.LJFF;
        if (ffx2 != null) {
            ffx2.setSubtitle("");
        }
    }

    public void LIZ(View view) {
        TextView textView;
        boolean z;
        boolean z2;
        CommerceToolsTcmModel commerceToolsTcmModel;
        View view2 = view;
        M12.LIZ(view2);
        this.LIZLLL = view2.findViewById(2131366355);
        this.LJ = view2.findViewById(2131362314);
        this.LIZIZ = LIZIZ().LIZLLL;
        View view3 = this.LIZLLL;
        if (view3 != null) {
            view3.setOnClickListener(new FTO(this));
        }
        C0439Ffx ffx = (C0439Ffx) view2.findViewById(2131362894);
        this.LJFF = ffx;
        String str = null;
        if (ffx != null) {
            textView = ffx.getBottomHintTextView();
        } else {
            textView = null;
        }
        this.LJI = textView;
        if (CommerceToolsTcmServiceImpl.LJFF().LIZJ()) {
            TextView textView2 = this.LJI;
            if (textView2 != null) {
                Context context = getContext();
                if (context != null) {
                    str = context.getString(2131827076);
                }
                textView2.setText(str);
            }
        } else {
            TextView textView3 = this.LJI;
            if (textView3 != null) {
                Context context2 = getContext();
                if (context2 != null) {
                    str = context2.getString(2131822047);
                }
                textView3.setText(str);
            }
        }
        C0439Ffx ffx2 = this.LJFF;
        if (ffx2 != null) {
            ffx2.setVisibility(8);
        }
        TextView textView4 = this.LJI;
        if (textView4 != null) {
            textView4.setVisibility(8);
        }
        Bundle arguments = getArguments();
        if (arguments != null) {
            z = arguments.getBoolean("key_enable_sponsor");
        } else {
            z = false;
        }
        Bundle arguments2 = getArguments();
        if (arguments2 != null) {
            z2 = arguments2.getBoolean("key_general_music");
        } else {
            z2 = false;
        }
        Bundle arguments3 = getArguments();
        if (arguments3 == null || (commerceToolsTcmModel = (CommerceToolsTcmModel) arguments3.getParcelable("key_tcm_model")) == null) {
            commerceToolsTcmModel = new CommerceToolsTcmModel(false, (String) null, (String) null, (String) null, (String) null, false, false, (List) null, (String) null, 0, false, 2047, (2HN) null);
        }
        if (z) {
            C0439Ffx ffx3 = this.LJFF;
            if (ffx3 != null) {
                ffx3.setVisibility(0);
            }
            C0439Ffx ffx4 = this.LJFF;
            if (ffx4 != null) {
                ffx4.setLeftTuxIcon(2131232651);
            }
            if (CommerceToolsTcmServiceImpl.LJFF().LIZJ()) {
                C0439Ffx ffx5 = this.LJFF;
                if (ffx5 != null) {
                    ffx5.setTitle(2131822020);
                }
            } else {
                C0439Ffx ffx6 = this.LJFF;
                if (ffx6 != null) {
                    ffx6.setTitle(2131822043);
                }
            }
            String brandedContentSwitch = commerceToolsTcmModel.getBrandedContentSwitch();
            if (TextUtils.equals(brandedContentSwitch, "1") || TextUtils.equals(brandedContentSwitch, "2")) {
                LIZ(true);
            } else {
                LIZ(false);
            }
            TextView textView5 = this.LJI;
            if (textView5 != null) {
                textView5.setVisibility(0);
            }
            2nK.onEventV3("tcm_bctoggle_show");
            C0439Ffx ffx7 = this.LJFF;
            if (ffx7 != null) {
                ffx7.setOnClickListener(new C0072FRu(this, z2, commerceToolsTcmModel));
            }
        }
        List list = LIZIZ().LIZ;
        if (list.isEmpty()) {
            RecyclerView recyclerView = this.LJ;
            if (recyclerView != null) {
                recyclerView.setVisibility(8);
                return;
            }
            return;
        }
        RecyclerView recyclerView2 = this.LJ;
        if (recyclerView2 != null) {
            ViewGroup.LayoutParams layoutParams = recyclerView2.getLayoutParams();
            Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
            recyclerView2.setLayoutParams((ViewGroup.MarginLayoutParams) layoutParams);
        }
        RecyclerView recyclerView3 = this.LJ;
        if (recyclerView3 != null) {
            getContext();
            recyclerView3.setLayoutManager(new LinearLayoutManager());
        }
        2y9 r2 = new 2y9(list);
        this.LIZ = r2;
        RecyclerView recyclerView4 = this.LJ;
        if (recyclerView4 != null) {
            recyclerView4.setAdapter(r2);
        }
    }

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        View LIZ2 = 0HH.LIZ(layoutInflater, 2131560441, viewGroup, false);
        n.LIZIZ(LIZ2, "");
        LIZ(LIZ2);
        return LIZ2;
    }
}
