package com.ss.android.ugc.aweme.search.feedback.single.ui;

import X.0HH;
import X.2Pr;
import X.2uR;
import X.3EX;
import X.3YD;
import X.3cA;
import X.3cC;
import X.3cI;
import X.6iy;
import X.C4105Lea;
import X.C4645LnI;
import X.C4771LpK;
import X.C4773LpM;
import X.C4775LpO;
import X.C4776LpP;
import X.C4777LpQ;
import X.C4787Lpa;
import X.C4949LsC;
import X.C4950LsD;
import X.CbG;
import X.M12;
import X.QHW;
import X.QJt;
import X.QJu;
import X.Qeg;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.SparseArray;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.lighten.loader.SmartImageView;
import com.ss.android.ugc.aweme.base.model.UrlModel;
import com.ss.android.ugc.aweme.discover.model.FeedbackMultipleChoice;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import kotlin.h.b.n;

public final class SearchFeedbackOptionalFragment extends Fragment implements 3YD {
    public static final C4777LpQ LJ = new C4777LpQ((byte) 0);
    public C4787Lpa LIZ;
    public View LIZIZ;
    public C4949LsC<? super Fragment, 2Pr> LIZJ;
    public C4950LsD<? super FeedbackMultipleChoice, ? super Integer, 2Pr> LIZLLL;
    public SparseArray LJFF;

    static {
        Covode.recordClassIndex(104130);
    }

    private 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() {
        SearchFeedbackOptionalFragment.super.onDestroyView();
        SparseArray sparseArray = this.LJFF;
        if (sparseArray != null) {
            sparseArray.clear();
        }
    }

    public final 2uR ch_() {
        String str;
        Resources resources;
        2uR r4 = new 2uR();
        3cC r3 = new 3cC();
        Context context = getContext();
        if (context == null || (resources = context.getResources()) == null || (str = resources.getString(2131820914)) == null) {
            str = "";
        }
        n.LIZIZ(str, "");
        r3.LIZ(str);
        r4.LIZ(r3);
        3cA r1 = new 3cA();
        r1.LIZ(2131755735);
        r1.LIZ(new C4773LpM(this));
        r4.LIZIZ(new 3cI[]{r1});
        return r4;
    }

    public static final /* synthetic */ C4787Lpa LIZ(SearchFeedbackOptionalFragment searchFeedbackOptionalFragment) {
        C4787Lpa lpa = searchFeedbackOptionalFragment.LIZ;
        if (lpa == null) {
            n.LIZ("");
        }
        return lpa;
    }

    public final void onCreate(Bundle bundle) {
        Serializable serializable;
        SearchFeedbackOptionalFragment.super.onCreate(bundle);
        Bundle arguments = getArguments();
        if (arguments != null) {
            serializable = arguments.getSerializable("search_feedback_model");
        } else {
            serializable = null;
        }
        Objects.requireNonNull(serializable, "null cannot be cast to non-null type com.ss.android.ugc.aweme.search.feedback.single.model.SearchFeedbackModel");
        this.LIZ = (C4787Lpa) serializable;
    }

    public final void onViewCreated(View view, Bundle bundle) {
        String str;
        SmartImageView smartImageView;
        M12.LIZ((Object) view);
        SearchFeedbackOptionalFragment.super.onViewCreated(view, bundle);
        C4787Lpa lpa = this.LIZ;
        if (lpa == null) {
            n.LIZ("");
        }
        String feedbackType = lpa.getFeedbackType();
        if (feedbackType != null) {
            if (n.LIZ(feedbackType, C4776LpP.USER.getValue()) || n.LIZ(feedbackType, C4776LpP.CHALLENGE.getValue())) {
                SmartImageView LIZ2 = LIZ(2131369916);
                n.LIZIZ(LIZ2, "");
                LIZ2.setVisibility(8);
                QJu LIZ3 = LIZ(2131369915);
                n.LIZIZ(LIZ3, "");
                LIZ3.setVisibility(0);
                smartImageView = (QJu) LIZ(2131369915);
            } else {
                QJu LIZ4 = LIZ(2131369915);
                n.LIZIZ(LIZ4, "");
                LIZ4.setVisibility(8);
                SmartImageView LIZ5 = LIZ(2131369916);
                n.LIZIZ(LIZ5, "");
                LIZ5.setVisibility(0);
                smartImageView = LIZ(2131369916);
            }
            n.LIZIZ(smartImageView, "");
            ViewGroup.LayoutParams layoutParams = smartImageView.getLayoutParams();
            if (n.LIZ(feedbackType, C4776LpP.VIDEO.getValue()) || n.LIZ(feedbackType, C4776LpP.LIVE.getValue()) || n.LIZ(feedbackType, C4776LpP.HOTSPOT.getValue()) || n.LIZ(feedbackType, C4776LpP.ADS.getValue())) {
                Resources system = Resources.getSystem();
                n.LIZIZ(system, "");
                layoutParams.width = C4645LnI.LIZ(TypedValue.applyDimension(1, 46.0f, system.getDisplayMetrics()));
                Resources system2 = Resources.getSystem();
                n.LIZIZ(system2, "");
                layoutParams.height = C4645LnI.LIZ(TypedValue.applyDimension(1, 56.0f, system2.getDisplayMetrics()));
            } else if (n.LIZ(feedbackType, C4776LpP.USER.getValue()) || n.LIZ(feedbackType, C4776LpP.MUSIC.getValue()) || n.LIZ(feedbackType, C4776LpP.EFFECTS.getValue()) || n.LIZ(feedbackType, C4776LpP.E_COM.getValue())) {
                Resources system3 = Resources.getSystem();
                n.LIZIZ(system3, "");
                layoutParams.width = C4645LnI.LIZ(TypedValue.applyDimension(1, 56.0f, system3.getDisplayMetrics()));
                Resources system4 = Resources.getSystem();
                n.LIZIZ(system4, "");
                layoutParams.height = C4645LnI.LIZ(TypedValue.applyDimension(1, 56.0f, system4.getDisplayMetrics()));
            } else if (n.LIZ(feedbackType, C4776LpP.CHALLENGE.getValue())) {
                Resources system5 = Resources.getSystem();
                n.LIZIZ(system5, "");
                layoutParams.width = C4645LnI.LIZ(TypedValue.applyDimension(1, 32.0f, system5.getDisplayMetrics()));
                Resources system6 = Resources.getSystem();
                n.LIZIZ(system6, "");
                layoutParams.height = C4645LnI.LIZ(TypedValue.applyDimension(1, 32.0f, system6.getDisplayMetrics()));
                QJt LIZ6 = QHW.LIZ(2131233757);
                LIZ6.LJJIIZ = smartImageView;
                View view2 = this.LIZIZ;
                if (view2 == null) {
                    n.LIZ("");
                }
                LIZ6.LJIIZILJ = view2.getResources().getDrawable(2131099659);
                LIZ6.LIZJ();
            }
            C4787Lpa lpa2 = this.LIZ;
            if (lpa2 == null) {
                n.LIZ("");
            }
            UrlModel imgCover = lpa2.getImgCover();
            if (imgCover != null) {
                QJt LIZ7 = QHW.LIZ(3EX.LIZ(imgCover));
                LIZ7.LJJIIZ = smartImageView;
                LIZ7.LIZJ();
            }
        }
        Qeg LIZ8 = LIZ(2131369919);
        n.LIZIZ(LIZ8, "");
        C4787Lpa lpa3 = this.LIZ;
        if (lpa3 == null) {
            n.LIZ("");
        }
        LIZ8.setText(lpa3.getTitle());
        C4787Lpa lpa4 = this.LIZ;
        if (lpa4 == null) {
            n.LIZ("");
        }
        List<FeedbackMultipleChoice> multipleChoices = lpa4.getMultipleChoices();
        if (multipleChoices != null) {
            List<FeedbackMultipleChoice> LJII = C4105Lea.LJII(6iy.LIZ(C4105Lea.LIZLLL(multipleChoices, multipleChoices.size() - 1)));
            LJII.add(C4105Lea.LJIIIZ(multipleChoices));
            for (FeedbackMultipleChoice feedbackMultipleChoice : LJII) {
                View view3 = getView();
                if (view3 == null) {
                    n.LIZIZ();
                }
                n.LIZIZ(view3, "");
                LayoutInflater from = LayoutInflater.from(view3.getContext());
                ConstraintLayout constraintLayout = this.LIZIZ;
                if (constraintLayout == null) {
                    n.LIZ("");
                }
                Objects.requireNonNull(constraintLayout, "null cannot be cast to non-null type androidx.constraintlayout.widget.ConstraintLayout");
                CbG LIZ9 = 0HH.LIZ(from, 2131561126, constraintLayout, false);
                Objects.requireNonNull(LIZ9, "null cannot be cast to non-null type com.bytedance.tux.button.TuxButton");
                CbG cbG = LIZ9;
                cbG.setText(feedbackMultipleChoice.getValue());
                Resources system7 = Resources.getSystem();
                n.LIZIZ(system7, "");
                cbG.setMinWidth(C4645LnI.LIZ(TypedValue.applyDimension(1, 80.0f, system7.getDisplayMetrics())));
                cbG.setMaxWidth(Integer.MAX_VALUE);
                cbG.setOnClickListener(new C4771LpK(feedbackMultipleChoice, LJII, this));
                LIZ(2131369911).addView(cbG);
            }
        }
        String value = C4776LpP.VIDEO.getValue();
        C4787Lpa lpa5 = this.LIZ;
        if (lpa5 == null) {
            n.LIZ("");
        }
        if (!n.LIZ(value, lpa5.getFeedbackType())) {
            String value2 = C4776LpP.USER.getValue();
            C4787Lpa lpa6 = this.LIZ;
            if (lpa6 == null) {
                n.LIZ("");
            }
            if (!n.LIZ(value2, lpa6.getFeedbackType())) {
                ConstraintLayout LIZ10 = LIZ(2131369912);
                n.LIZIZ(LIZ10, "");
                LIZ10.setVisibility(8);
                return;
            }
        }
        ConstraintLayout LIZ11 = LIZ(2131369912);
        n.LIZIZ(LIZ11, "");
        LIZ11.setVisibility(0);
        String value3 = C4776LpP.USER.getValue();
        C4787Lpa lpa7 = this.LIZ;
        if (lpa7 == null) {
            n.LIZ("");
        }
        if (n.LIZ(value3, lpa7.getFeedbackType())) {
            Qeg LIZ12 = LIZ(2131369913);
            n.LIZIZ(LIZ12, "");
            Context context = getContext();
            if (context != null) {
                str = context.getString(2131831965);
            } else {
                str = null;
            }
            LIZ12.setText(str);
        }
        LIZ(2131369912).setOnClickListener(new C4775LpO(this));
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ((Object) layoutInflater);
        if (viewGroup == null) {
            n.LIZIZ();
        }
        View LIZ2 = 0HH.LIZ(layoutInflater.cloneInContext(viewGroup.getContext()), 2131561202, viewGroup, false);
        n.LIZIZ(LIZ2, "");
        this.LIZIZ = LIZ2;
        if (LIZ2 == null) {
            n.LIZ("");
        }
        return LIZ2;
    }
}
