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

import X.070;
import X.0AA;
import X.0AP;
import X.0Bs;
import X.0Bv;
import X.0Bx;
import X.0By;
import X.0HB;
import X.1Bn;
import X.1hK;
import X.2GD;
import X.2GO;
import X.2HV;
import X.2HZ;
import X.2J6;
import X.2Sa;
import X.2UX;
import X.2nK;
import X.3BB;
import X.3Fl;
import X.3Of;
import X.3af;
import X.3hl;
import X.3qV;
import X.41j;
import X.42a;
import X.43W;
import X.46i;
import X.4AY;
import X.4At;
import X.4CF;
import X.4EV;
import X.4Ev;
import X.4FQ;
import X.4ZZ;
import X.4lv;
import X.4vl;
import X.4wQ;
import X.4wW;
import X.4we;
import X.8q8;
import X.8q9;
import X.8qY;
import X.A05;
import X.A6U;
import X.AnonymousClass9nD;
import X.AnonymousClass9nH;
import X.AnonymousClass9q6;
import X.AnonymousClass9r7;
import X.AnonymousClass9rD;
import X.AnonymousClass9tE;
import X.AnonymousClass9tR;
import X.AnonymousClass9tS;
import X.AnonymousClass9tT;
import X.AnonymousClass9tV;
import X.AnonymousClass9tW;
import X.AnonymousClass9tY;
import X.AnonymousClass9tZ;
import X.AnonymousClass9wU;
import X.AnonymousClass9xV;
import X.C00309ne;
import X.C00919pn;
import X.C00969ps;
import X.C01009pw;
import X.C01029py;
import X.C01509ru;
import X.C01829ta;
import X.C02079tz;
import X.C02219un;
import X.C02229uo;
import X.C1810AiE;
import X.C6519Cbz;
import X.Cl7;
import X.CqM;
import X.DSZ;
import X.DyE;
import X.Etp;
import X.HeD;
import X.Hns;
import X.ISm;
import X.J96;
import X.K0c;
import X.KGj;
import X.Ksx;
import X.LFp;
import X.Lea;
import X.M12;
import X.Qeg;
import X.Rc9;
import X.TnV;
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Bundle;
import android.text.Editable;
import android.text.SpannableStringBuilder;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.text.style.ForegroundColorSpan;
import android.text.style.StyleSpan;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.uikit.base.AbsFragment;
import com.ss.android.ugc.aweme.base.livedata.SlideData;
import com.ss.android.ugc.aweme.comment.CommentServiceImpl;
import com.ss.android.ugc.aweme.comment.model.Comment;
import com.ss.android.ugc.aweme.commercialize.depend.AdCommentDependImpl;
import com.ss.android.ugc.aweme.compliance.api.a;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.setting.services.IVideoGiftService;
import com.ss.android.ugc.aweme.setting.services.VideoGiftService;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import kotlin.h.b.n;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.ThreadMode;

public class CommentInputFragment extends AbsFragment implements 4At, C01009pw, 2HZ, 2GO {
    public static String LJJIIZI;
    public static String LJJIJ;
    public ViewGroup LIZ;
    public ViewGroup LIZIZ;
    public Qeg LIZJ;
    public View LIZLLL;
    public C1810AiE LJ;
    public 4ZZ LJIIIZ;
    public 4ZZ LJIIJ;
    public 4ZZ LJIIJJI;
    public J96 LJIIL;
    public Qeg LJIILIIL;
    public ViewGroup LJIILJJIL;
    public ViewGroup LJIILL;
    public View LJIILLIIL;
    public View LJIIZILJ;
    public 43W LJIJ;
    public AnonymousClass9tT LJIJI;
    public C00969ps LJIJJ;
    public AnonymousClass9tY LJIJJLI;
    public C01829ta LJIL;
    public String LJJ = "";
    public String LJJI = "";
    public View LJJIFFI;
    public C02229uo LJJII;
    public IVideoGiftService LJJIII;
    public boolean LJJIIJ;
    public boolean LJJIIJZLJL;
    public boolean LJJIIZ;
    public boolean LJJIJIIJI;
    public boolean LJJIJIIJIL = true;
    public ObjectAnimator LJJIJIL;
    public boolean LJJIJL = true;

    static {
        Covode.recordClassIndex(57313);
    }

    public Comment getCommentInputReplyComment() {
        return null;
    }

    public int getCommentInputViewType() {
        return 1;
    }

    public String getEnterMethod() {
        return "";
    }

    public Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(79, new Rc9(CommentInputFragment.class, "onDislikeAwemeEvent", 3hl.class, ThreadMode.POSTING, 0, false));
        hashMap.put(9, new Rc9(CommentInputFragment.class, "onCommentEvent", 4CF.class, ThreadMode.POSTING, 0, false));
        hashMap.put(193, new Rc9(CommentInputFragment.class, "onEvent", DyE.class, ThreadMode.POSTING, 0, false));
        hashMap.put(194, new Rc9(CommentInputFragment.class, "onAfterLoginInEvent", 3Of.class, ThreadMode.POSTING, 0, false));
        return hashMap;
    }

    public void onCommentInputClick() {
    }

    public void onEvent(AnonymousClass9nH r1) {
    }

    public void onUpvotePublishProcessChanged(boolean z) {
    }

    public final void LIZ(boolean z) {
        if (aq_() && this.LJIILLIIL != null && this.LIZ != null) {
            Aweme commentInputAweme = getCommentInputAweme();
            if (AnonymousClass9tE.LIZ() && commentInputAweme != null && commentInputAweme.isProhibitedAndShouldTell()) {
                z = false;
            }
            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) this.LJIILLIIL.getLayoutParams();
            if (z) {
                if (this.LIZ.getVisibility() == 8) {
                    if (Cl7.LJIILIIL(LJIIJJI())) {
                        AnonymousClass9tT r0 = this.LJIJI;
                        if (r0 == null || !r0.LJIIJ()) {
                            this.LIZ.setVisibility(0);
                            C6519Cbz.LIZ(this.LJIIZILJ, 0);
                            marginLayoutParams.height = getContext().getResources().getDimensionPixelOffset(2131165344);
                            if (3Fl.LIZLLL) {
                                marginLayoutParams.height += 3Fl.LJ;
                            }
                            this.LJIILLIIL.setLayoutParams(marginLayoutParams);
                            M12.LIZ("CommentInputFragment", " first bind  show " + this.LJJIJIIJIL);
                            if (this.LJJIJIIJIL || !AnonymousClass9tE.LIZ()) {
                                this.LJJIJIIJIL = false;
                            } else {
                                LJI(z);
                            }
                        } else {
                            return;
                        }
                    } else {
                        return;
                    }
                }
                LJIIZILJ();
            } else if (this.LIZ.getVisibility() == 0) {
                M12.LIZ("CommentInputFragment", " first bind  hide " + this.LJJIJIIJIL);
                if (this.LJJIJIIJIL || !AnonymousClass9tE.LIZ()) {
                    this.LJJIJIIJIL = false;
                    LJIIJ();
                } else {
                    LJI(z);
                }
                LJFF();
            }
            LJIIL();
        }
    }

    public final void LIZJ() {
        LJJIJ = null;
        LJJIIZI = null;
    }

    public final void LJFF() {
        boolean aq_ = aq_();
    }

    public Aweme getCommentInputAweme() {
        return LJIIJJI();
    }

    public void onPause() {
        CommentInputFragment.super.onPause();
        this.LJFF = false;
    }

    private String LJIILJJIL() {
        Aweme LJIIJJI2 = LJIIJJI();
        if (LJIIJJI2 != null) {
            return LJIIJJI2.getAid();
        }
        return "";
    }

    public final Aweme LJIIJJI() {
        AnonymousClass9tT r0 = this.LJIJI;
        if (r0 != null) {
            return r0.LJII();
        }
        return null;
    }

    public final boolean aq_() {
        if (!CommentInputFragment.super.aq_() || getContext() == null) {
            return false;
        }
        return true;
    }

    public String getEventType() {
        AnonymousClass9tT r0 = this.LJIJI;
        if (r0 != null) {
            return r0.LJIIIZ();
        }
        return "";
    }

    public void onDestroyView() {
        CommentInputFragment.super.onDestroyView();
        this.LJIJI = null;
        this.LJIL = null;
        EventBus.LIZ().LIZIZ(this);
    }

    private CommentListPageFragment LJIILIIL() {
        if (getActivity() == null) {
            return null;
        }
        return getActivity().getSupportFragmentManager().LIZ("comment_page");
    }

    private String LJIILL() {
        AnonymousClass9tT r0 = this.LJIJI;
        if (r0 == null || r0.LJII() == null) {
            return "";
        }
        return this.LJIJI.LJII().getAid();
    }

    public final void LIZLLL() {
        this.LJJIIJ = true;
        View view = this.LJIILLIIL;
        if (view != null) {
            view.setVisibility(4);
            this.LJIILLIIL.setEnabled(false);
        }
    }

    public final void LJ() {
        int i = 0;
        this.LJJIIJ = false;
        View view = this.LJIILLIIL;
        if (view != null) {
            if (this.LJJIIJZLJL) {
                i = 4;
            }
            view.setVisibility(i);
            this.LJIILLIIL.setEnabled(true);
        }
    }

    public final void LJII() {
        Fragment LIZ2;
        0AA fragmentManager = getFragmentManager();
        if (fragmentManager != null && (LIZ2 = fragmentManager.LIZ("comment_input_tag")) != null) {
            0AP LIZ3 = fragmentManager.LIZ();
            LIZ3.LIZIZ(LIZ2);
            LIZ3.LIZJ();
        }
    }

    public final void LJIIIIZZ() {
        boolean LIZ2 = a.LIZJ().LIZ(3);
        if (this.LJJIJIIJI != LIZ2 && this.LJIJJ != null) {
            this.LJJIJIIJI = LIZ2;
            if (LIZ2) {
                LJIILLIIL();
            }
            this.LJIJJ.LIZIZ(this.LJJIJIIJI);
        }
    }

    public final void LJIIIZ() {
        M12.LIZ("xjccccc", "input fragment updateWhenPageSelected");
        if (aq_()) {
            LJIIL();
        }
    }

    public void onResume() {
        CommentInputFragment.super.onResume();
        if (this.LJJIJIIJI) {
            LJIILLIIL();
        }
        LIZIZ();
        LIZ(LJJIIZI, LJJIJ);
        LIZ(9);
    }

    public boolean upvoteWhenComment() {
        if (!hasUpvoteOption() || !A05.LIZ.LIZLLL().LIZIZ()) {
            return false;
        }
        return true;
    }

    private void LJIILLIIL() {
        Qeg qeg = this.LIZJ;
        if (qeg != null) {
            qeg.setVisibility(0);
            if (AnonymousClass9tE.LIZ()) {
                ((FrameLayout.LayoutParams) this.LIZJ.getLayoutParams()).setMarginStart(4Ev.LIZIZ(16));
                this.LIZJ.setGravity(8388627);
            }
        }
        ViewGroup viewGroup = this.LJIILJJIL;
        if (viewGroup != null) {
            viewGroup.setVisibility(8);
        }
    }

    public final void LJI() {
        View view = this.LJJIFFI;
        if (view != null && this.LJ != null && view.getVisibility() == 0) {
            this.LJJIFFI.setVisibility(8);
            this.LJ.setEnabled(true);
            this.LJ.setFocusable(true);
        }
    }

    public final void LJIIJ() {
        View view = this.LJIILLIIL;
        if (view != null && this.LIZ != null && this.LJIIZILJ != null) {
            ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) view.getLayoutParams();
            this.LIZ.setVisibility(8);
            this.LJIIZILJ.setVisibility(8);
            marginLayoutParams.height = 1;
            this.LJIILLIIL.setLayoutParams(marginLayoutParams);
        }
    }

    public boolean hasUpvoteOption() {
        if (A05.LIZ.LJFF().LIZJ(this.LJJ) && A05.LIZ.LIZLLL().LIZ(getCommentInputAweme())) {
            return true;
        }
        return false;
    }

    private void LJIIL() {
        C01829ta r0;
        if (this.LJIJJ != null && (r0 = this.LJIL) != null && r0.LIZJ()) {
            if (this.LJIL.LIZLLL()) {
                ViewGroup viewGroup = this.LJIILL;
                if (viewGroup != null) {
                    viewGroup.setVisibility(8);
                }
                ViewGroup viewGroup2 = this.LIZ;
                if (viewGroup2 != null) {
                    ViewGroup viewGroup3 = (ViewGroup) viewGroup2.findViewById(2131364688);
                    if (viewGroup3 != null) {
                        int i = 3Fl.LJIILIIL;
                        int LIZ2 = 2HV.LIZ.LIZ();
                        if (i == 0) {
                            i = LIZ2;
                        }
                        ViewGroup.LayoutParams layoutParams = viewGroup3.getLayoutParams();
                        layoutParams.height = i;
                        viewGroup3.setLayoutParams(layoutParams);
                    }
                    this.LJIL.LIZ(viewGroup3);
                }
            } else if (this.LJIL.LJFF()) {
                ViewGroup viewGroup4 = this.LJIILL;
                if (viewGroup4 != null) {
                    viewGroup4.setVisibility(0);
                }
                this.LJIL.LJ();
                this.LJIJJ.LIZ(new C01029py(this.LIZLLL, this.LJ, this.LJIIIZ, this.LJIIJJI, this.LJIIJ, this.LIZJ, LJIILJJIL(), this.LJJ, true));
            }
        }
    }

    private void LJIIZILJ() {
        ViewGroup viewGroup = this.LIZ;
        if (viewGroup == null || viewGroup.getVisibility() != 0) {
            A6U.LIZIZ("comment_input_tag", "CommentInput  bindVideoViewerEntrance but view is not Valid !");
            return;
        }
        TnV tnV = null;
        AnonymousClass9tT r0 = this.LJIJI;
        if (r0 != null) {
            tnV = r0.LJIIIIZZ();
        }
        boolean LIZ2 = CommentServiceImpl.LJI().LIZ((ViewGroup) this.LIZ.findViewById(2131364688), getCommentInputAweme(), tnV);
        ViewGroup viewGroup2 = this.LJIILL;
        if (viewGroup2 == null) {
            return;
        }
        if (LIZ2) {
            viewGroup2.setVisibility(8);
        } else {
            viewGroup2.setVisibility(0);
        }
    }

    public final void LIZIZ() {
        if (aq_()) {
            boolean z = true;
            if (!46i.LJFF().isLogin()) {
                this.LJ.setFocusable(false);
            } else {
                this.LJ.setFocusable(true);
                this.LJ.setFocusableInTouchMode(true);
                this.LJ.requestFocus();
            }
            Aweme LJIIJJI2 = LJIIJJI();
            if (LJIIJJI2 == null || !LJIIJJI2.isProhibited()) {
                this.LJ.setEnabled(true);
                C00969ps r0 = this.LJIJJ;
                if (r0 != null) {
                    r0.LIZ();
                    Editable text = this.LJ.getText();
                    boolean LIZ2 = C00969ps.LIZ(LJIIJJI2);
                    if (text == null || text.length() <= 0) {
                        z = false;
                    }
                    LIZ(LIZ2, false, z);
                }
            } else {
                this.LJ.setEnabled(false);
                this.LJ.setHint(2131822872);
            }
            C01829ta r02 = this.LJIL;
            if (r02 != null && r02.LIZLLL()) {
                this.LJIL.LJI();
            }
        }
    }

    public boolean checkCommentInputable() {
        Aweme LJII;
        if (!aq_() || getActivity() == null || !46i.LJFF().isLogin()) {
            return false;
        }
        Aweme LJIIJJI2 = LJIIJJI();
        if (2J6.LIZ(LJIIJJI2)) {
            String LIZ2 = 2J6.LIZ(LJIIJJI2, 2131834754);
            3BB r1 = new 3BB(getContext());
            r1.LIZ(LIZ2);
            r1.LIZIZ();
            return false;
        }
        if (LJIIJJI2 != null) {
            if (!LJIIJJI2.isCanPlay()) {
                if (LJIIJJI2.isImage()) {
                    3af r12 = new 3af(this);
                    r12.LJ(2131826042);
                    3af.LIZ(r12);
                } else {
                    3af r0 = new 3af(this);
                    r0.LJ(2131834754);
                    3af.LIZ(r0);
                }
                return false;
            } else if (LJIIJJI2.getStatus() != null && LJIIJJI2.getStatus().isDelete()) {
                3af r13 = new 3af(this);
                r13.LJ(2131834692);
                3af.LIZ(r13);
                return false;
            } else if (LJIIJJI2.getStatus() != null && !LJIIJJI2.getStatus().isAllowComment()) {
                3af r14 = new 3af(this);
                r14.LJ(2131822310);
                3af.LIZ(r14);
                return false;
            }
        }
        if (!4lv.LIZ.LIZJ(LJIIJJI2) || 4lv.LIZ.LJ(LJIIJJI2) || (LJIIJJI2.getAuthor() != null && TextUtils.equals(LJIIJJI2.getAuthor().getUid(), 46i.LJFF().getCurUser().getUid()))) {
            AnonymousClass9tT r02 = this.LJIJI;
            if (r02 != null && r02.LJII() != null && (LJII = this.LJIJI.LJII()) != null && LJII.getStatus() != null && LJII.getStatus().getPrivateStatus() == 1 && LJII.getAuthor() != null && TextUtils.equals(LJII.getAuthor().getUid(), 46i.LJFF().getCurUser().getUid())) {
                if (LJIIJJI2 != null) {
                    this.LJIJ.LIZ(LJIIJJI2, 0);
                    4vl LIZ3 = 4EV.LIZ(getContext());
                    LIZ3.LIZLLL(2131830928);
                    LIZ3.LIZ(2131822315, false, new 4(this, LJIIJJI2));
                    LIZ3.LIZ(2131826522, new 3(this, LJIIJJI2));
                    4FQ.LIZ(LIZ3.LIZ().LIZJ());
                }
                return false;
            } else if (LJIIJJI2 == null || !LJIIJJI2.isAwemeFromXiGua()) {
                return true;
            } else {
                return false;
            }
        } else {
            3af r15 = new 3af(this);
            r15.LJ(2131825310);
            3af.LIZ(r15);
            return false;
        }
    }

    public final void LIZ() {
        boolean z;
        C00969ps r0;
        Aweme LJII;
        if (this.LJ != null && !this.LJJIIZ) {
            LJFF();
            Aweme LJIIJJI2 = LJIIJJI();
            boolean z2 = true;
            if (LJIIJJI2 == null || !LJIIJJI2.isProhibited()) {
                this.LJ.setEnabled(true);
                C00969ps r02 = this.LJIJJ;
                if (r02 != null) {
                    r02.LIZ();
                    Editable text = this.LJ.getText();
                    boolean LIZ2 = C00969ps.LIZ(LJIIJJI2);
                    if (text == null || text.length() <= 0) {
                        z = false;
                    } else {
                        z = true;
                    }
                    LIZ(LIZ2, z, false);
                    this.LJIJJ.LJIIJ();
                }
            } else {
                this.LJ.setEnabled(false);
                this.LJ.setHint(2131822872);
            }
            C01829ta r03 = this.LJIL;
            if (r03 != null && r03.LIZLLL()) {
                C01829ta r1 = this.LJIL;
                AnonymousClass9tT r04 = r1.LIZJ;
                if (r04 == null || (LJII = r04.LJII()) == null || !LJII.isProhibited()) {
                    z2 = false;
                }
                AnonymousClass9xV r05 = r1.LIZ;
                if (r05 != null) {
                    r05.setEditStatus(z2);
                }
                if (!z2 && (r0 = r1.LIZIZ) != null) {
                    r0.LJIIJ();
                }
            }
        }
    }

    @ISm
    public void onAfterLoginInEvent(3Of r2) {
        ViewGroup viewGroup = this.LIZ;
    }

    public final /* synthetic */ void LJ(boolean z) {
        LIZ(!z);
    }

    @ISm
    public void onEvent(DyE dyE) {
        ViewGroup viewGroup = this.LIZ;
    }

    public static 0Bx LIZ(1hK r2) {
        0Bx LIZ2 = 0By.LIZ(r2, (0Bv) null);
        if (2GD.LIZ) {
            0Bs.LIZ(LIZ2, r2);
        }
        return LIZ2;
    }

    public final /* synthetic */ void LJFF(boolean z) {
        LIZ(!z);
    }

    public static 8q9 LIZ(Context context) {
        if (8qY.LIZLLL != 8q9.UNKNOWN && !8qY.LIZIZ()) {
            return 8qY.LIZLLL;
        }
        8q9 LIZIZ2 = 8q8.LIZIZ(context);
        8qY.LIZLLL = LIZIZ2;
        return LIZIZ2;
    }

    public void onCommentInputPublishOnlyGiftSuccess(Comment comment) {
        LIZ();
        if (comment != null && comment.getFakeGiftId() != 0) {
            LIZ(true, comment, 0);
        }
    }

    public void onCreate(Bundle bundle) {
        CommentInputFragment.super.onCreate(bundle);
        this.LJIJJ = new C00969ps(this, hashCode(), this);
        this.LJJIII = VideoGiftService.LJIIJ();
    }

    public void onEmojiToKeyboard(String str) {
        String aid;
        Aweme LJIIJJI2 = LJIIJJI();
        String str2 = this.LJJ;
        String str3 = "";
        if (LJIIJJI2 == null) {
            aid = str3;
        } else {
            aid = LJIIJJI2.getAid();
            str3 = LJIIJJI2.getAuthorUid();
        }
        C00309ne.LIZ(str, str2, aid, str3);
    }

    private void LIZ(int i) {
        AnonymousClass9tT r1 = this.LJIJI;
        if (r1 != null) {
            r1.LIZ(new Etp(i));
        }
    }

    public final void LIZIZ(boolean z) {
        float f;
        View view = this.LJIILLIIL;
        if (view == null) {
            this.LJJIIJZLJL = z;
            return;
        }
        if (z) {
            f = 0.0f;
        } else {
            f = 1.0f;
        }
        view.setAlpha(f);
        if (z) {
            this.LJIILLIIL.setVisibility(4);
        }
        this.LJIILLIIL.post(new AnonymousClass9tV(this, z));
    }

    public final void LIZJ(boolean z) {
        int i;
        View view = this.LJJIFFI;
        if (view != null && this.LJ != null) {
            if (z) {
                i = 0;
            } else {
                i = 8;
            }
            view.setVisibility(i);
            this.LJ.setEnabled(!z);
            this.LJ.setFocusable(!z);
            Aweme LJIIJJI2 = LJIIJJI();
            if (LJIIJJI2 != null && this.LJJIFFI.getVisibility() == 0) {
                this.LJJIFFI.setOnClickListener(new AnonymousClass9tZ(this, LJIIJJI2));
            }
        }
    }

    public final void LIZLLL(boolean z) {
        View view = this.LJIILLIIL;
        if (view != null && z != this.LJJIJL) {
            this.LJJIJL = z;
            view.post(new AnonymousClass9tW(this, z));
        }
    }

    public void onConfigurationChanged(Configuration configuration) {
        CommentInputFragment.super.onConfigurationChanged(configuration);
        View view = getView();
        if (view != null) {
            ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
            int LIZIZ2 = (int) HeD.LIZIZ(view.getContext(), (float) configuration.screenWidthDp);
            if (layoutParams.width != LIZIZ2) {
                layoutParams.width = LIZIZ2;
            }
            view.setLayoutParams(layoutParams);
        }
    }

    @ISm
    public void onDislikeAwemeEvent(3hl r4) {
        float f;
        if (getActivity() != null && r4.LJ == getActivity().hashCode() && r4.LIZIZ == 2) {
            if (r4.LIZ) {
                f = 0.0f;
            } else {
                f = 1.0f;
            }
            ViewGroup viewGroup = this.LIZ;
            AnonymousClass9tR.LIZ(viewGroup, viewGroup.getAlpha(), f);
            View view = this.LJIIZILJ;
            AnonymousClass9tR.LIZ(view, view.getAlpha(), f);
        }
    }

    private void LJI(final boolean z) {
        float f;
        M12.LIZ("CommentInputFragment", "addShowAndHideAnimation ".concat(String.valueOf(z)));
        if (AnonymousClass9tE.LIZ()) {
            if (z) {
                f = 1.0f;
            } else {
                f = 0.0f;
            }
            ObjectAnimator objectAnimator = this.LJJIJIL;
            if (objectAnimator != null && objectAnimator.isRunning()) {
                this.LJJIJIL.cancel();
            }
            ViewGroup viewGroup = this.LIZ;
            ObjectAnimator ofFloat = ObjectAnimator.ofFloat(viewGroup, "alpha", new float[]{viewGroup.getAlpha(), f});
            this.LJJIJIL = ofFloat;
            ofFloat.setDuration(300);
            this.LJJIJIL.addListener(new Animator.AnimatorListener() {
                static {
                    Covode.recordClassIndex(57315);
                }

                public final void onAnimationCancel(Animator animator) {
                }

                public final void onAnimationRepeat(Animator animator) {
                }

                public final void onAnimationStart(Animator animator) {
                }

                public final void onAnimationEnd(Animator animator) {
                    if (z) {
                        CommentInputFragment.this.LIZ.setVisibility(0);
                    } else {
                        CommentInputFragment.this.LJIIJ();
                    }
                }
            });
            this.LJJIJIL.setInterpolator(new LinearInterpolator());
            this.LJJIJIL.start();
        }
    }

    @ISm
    public void onCommentEvent(4CF r4) {
        C00969ps r0;
        AnonymousClass9xV r02;
        if (r4.LIZ == 8) {
            Object obj = r4.LIZIZ;
            Aweme LJIIJJI2 = LJIIJJI();
            if (LJIIJJI2 != null && LJIIJJI2.getAid() != null && LJIIJJI2.getAid().equals(obj) && (r0 = this.LJIJJ) != null) {
                r0.LIZ();
                LIZ(C00969ps.LIZ(LJIIJJI2), false, false);
                C01829ta r03 = this.LJIL;
                if (r03 != null && r03.LIZLLL() && (r02 = this.LJIL.LIZ) != null) {
                    r02.LIZ();
                }
            }
        }
    }

    public void onCommentInputPublishStart(Comment comment) {
        String awemeId;
        int i;
        if (comment == null) {
            return;
        }
        if (AnonymousClass9nD.LIZ(comment.getGiftEffectPath()) || comment.getFakeGiftId() == 0) {
            CommentListPageFragment LJIILIIL2 = LJIILIIL();
            if (LJIILIIL2 != null) {
                LJIILIIL2.LIZ(comment);
            }
            boolean z = true;
            if (2Sa.LIZ.LIZIZ()) {
                CqM.LIZ(new C01509ru(1, comment));
            }
            if (AnonymousClass9rD.LIZ.LIZIZ()) {
                String awemeId2 = comment.getAwemeId();
                if (TextUtils.isEmpty(awemeId2)) {
                    awemeId2 = LJIILL();
                }
                C02079tz r0 = new C02079tz(0);
                r0.LIZ(awemeId2);
                CqM.LIZ(r0);
            }
            C01829ta r02 = this.LJIL;
            if (r02 != null && r02.LIZLLL()) {
                C01829ta r7 = this.LJIL;
                M12.LIZ(comment);
                AnonymousClass9tT r03 = r7.LIZJ;
                Aweme aweme = null;
                if (r03 != null) {
                    aweme = r03.LJII();
                }
                String awemeId3 = comment.getAwemeId();
                if (!(awemeId3 == null || awemeId3.length() == 0)) {
                    z = false;
                }
                if (!z) {
                    awemeId = comment.getAwemeId();
                } else if (aweme == null || (awemeId = aweme.getAid()) == null) {
                    awemeId = "";
                }
                String text = comment.getText();
                if (text != null) {
                    String text2 = comment.getText();
                    if (text2 != null) {
                        i = text2.length();
                    } else {
                        i = 0;
                    }
                    Objects.requireNonNull(text, "null cannot be cast to non-null type java.lang.String");
                    String substring = text.substring(0, i / 3);
                    n.LIZIZ(substring, "");
                    if (substring != null) {
                        AnonymousClass9wU LIZ2 = r7.LIZIZ().LIZ(awemeId);
                        Set LJIILLIIL2 = Lea.LJIILLIIL(LIZ2.LIZJ);
                        LJIILLIIL2.add(substring);
                        r7.LIZIZ().LIZ(awemeId, AnonymousClass9wU.LIZ(LIZ2, false, false, LJIILLIIL2, 3));
                        return;
                    }
                    return;
                }
                return;
            }
            return;
        }
        GiftAnimationFragment.LIZIZ.LIZ(comment).show(getActivity().getSupportFragmentManager().LIZ(), "GiftAnimationFragment");
    }

    public void onCommentInputPublishSuccess(Comment comment) {
        if (aq_() && getActivity() != null) {
            String awemeId = comment.getAwemeId();
            if (TextUtils.isEmpty(awemeId)) {
                awemeId = LJIILL();
            }
            if (comment.getPublishScenario() != 1) {
                3af r1 = new 3af(this);
                r1.LJ(2131822891);
                3af.LIZ(r1);
            }
            LIZ();
            Aweme LJIIJJI2 = LJIIJJI();
            if (LJIIJJI2 != null && LJIIJJI2.isAd() && TextUtils.equals(awemeId, LJIIJJI2.getAid())) {
                AdCommentDependImpl.LIZIZ().LIZ(getContext(), LJIIJJI2, "comment_sign");
                KGj LIZ2 = K0c.LIZ("draw_ad", "comment", LJIIJJI2.getAwemeRawAd());
                LIZ2.LIZIZ("refer", "comment_sign");
                LIZ2.LIZ("anchor_id", Hns.LIZ(LJIIJJI2));
                LIZ2.LIZ("room_id", Hns.LIZIZ(LJIIJJI2));
                LIZ2.LIZJ();
            }
            4wW.LIZ(requireContext(), comment, this.LJIJJ.LIZLLL, LJIILL());
            CqM.LIZ(new 4CF(3, new Object[]{awemeId, comment.clone()}));
            CommentListPageFragment LJIILIIL2 = LJIILIIL();
            if (LJIILIIL2 != null) {
                comment.setIgnoreToast(true);
                LJIILIIL2.LIZ(comment, false);
            }
            if (comment.getGift() != null) {
                LIZ(true, comment, 0);
            }
        }
    }

    public final void LIZ(float f) {
        int i;
        View view = this.LJIILLIIL;
        if (view != null) {
            view.setAlpha(f);
            View view2 = this.LJIILLIIL;
            boolean z = false;
            int i2 = (f > 0.0f ? 1 : (f == 0.0f ? 0 : -1));
            if (i2 > 0) {
                i = 0;
            } else {
                i = 4;
            }
            view2.setVisibility(i);
            if (i2 > 0) {
                z = true;
            }
            LIZ(z);
        }
    }

    public void onCommentInputKeyboardDismiss(boolean z, 4we r6) {
        C1810AiE aiE;
        C1810AiE aiE2;
        this.LJIILLIIL.setVisibility(0);
        LIZ(false, false, !TextUtils.isEmpty(this.LJ.getText()));
        LIZ(9);
        AnonymousClass9tY r0 = this.LJIJJLI;
        if (r0 != null) {
            r0.LIZLLL();
        }
        C00969ps r1 = this.LJIJJ;
        if (!(r1 == null || (aiE2 = this.LJ) == null)) {
            r1.LIZ(aiE2, 2131099685);
        }
        C01829ta r02 = this.LJIL;
        if (r02 != null && r02.LIZLLL()) {
            C01829ta r2 = this.LJIL;
            C00969ps r12 = r2.LIZIZ;
            if (r12 != null) {
                AnonymousClass9xV r03 = r2.LIZ;
                if (r03 != null) {
                    aiE = r03.getEditText();
                } else {
                    aiE = null;
                }
                r12.LIZ(aiE, 2131099685);
            }
            AnonymousClass9xV r04 = r2.LIZ;
            if (r04 != null) {
                r04.LIZ();
            }
        }
    }

    public void onViewCreated(View view, Bundle bundle) {
        CommentInputFragment.super.onViewCreated(view, bundle);
        this.LIZJ.setTextColor(070.LIZJ(getContext(), 2131099689));
        Qeg qeg = this.LIZJ;
        String str = getString(2131822816) + " ";
        SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder(str + getString(2131834850));
        spannableStringBuilder.setSpan(new 1(this), str.length(), spannableStringBuilder.length(), 18);
        spannableStringBuilder.setSpan(new ForegroundColorSpan(070.LIZJ(getContext(), 2131099685)), str.length(), spannableStringBuilder.length(), 18);
        spannableStringBuilder.setSpan(new StyleSpan(1), str.length(), spannableStringBuilder.length(), 18);
        qeg.setText(spannableStringBuilder);
        this.LIZJ.setMovementMethod(new LinkMovementMethod());
        if (this.LJIJJ != null) {
            this.LJIJJ.LIZ(new C01029py(this.LIZLLL, this.LJ, this.LJIIIZ, this.LJIIJJI, this.LJIIJ, this.LIZJ, LJIILJJIL(), this.LJJ, true));
        }
        boolean LIZ2 = a.LIZJ().LIZ(3);
        this.LJJIJIIJI = LIZ2;
        this.LJIJJ.LIZIZ(LIZ2);
        if (this.LJJIJIIJI) {
            LJIILLIIL();
        }
        this.LJ.setCursorVisible(false);
        this.LJIILIIL.setVisibility(8);
        this.LJIIL.setOnClickListener(new AnonymousClass9q6(this));
        this.LIZ.setBackgroundResource(2131233326);
        C1810AiE aiE = this.LJ;
        aiE.setTextColor(aiE.getResources().getColor(2131099686));
        C1810AiE aiE2 = this.LJ;
        aiE2.setHintTextColor(aiE2.getResources().getColor(2131100199));
        this.LJ.setTextAlignment(5);
        2HV.LIZ.LIZ(2, this.LIZ, this.LJIIZILJ, this.LJJIFFI);
        LIZ(C00969ps.LIZ(getCommentInputAweme()), false, false);
        if (this.LJJIIJ) {
            LIZLLL();
        }
        LIZIZ(this.LJJIIJZLJL);
        1hK activity = getActivity();
        if (activity != null) {
            SlideData LIZ3 = LIZ(activity).LIZ(SlideData.class);
            if (LIZ3.LIZ == null) {
                LIZ3.LIZ = new 1Bn<>();
            }
            LIZ3.LIZ.observe(this, new C02219un(this));
            if (LIZ3.LIZIZ == null) {
                LIZ3.LIZIZ = new 1Bn<>();
            }
            LIZ3.LIZIZ.observe(this, new AnonymousClass9tS(this));
        }
        if (!Cl7.LJIILIIL(LJIIJJI())) {
            LIZ(false);
        }
        AnonymousClass9tT r0 = this.LJIJI;
        if (r0 != null && r0.LJIIJ()) {
            LIZ(false);
        }
        LJIIZILJ();
        C01829ta r3 = new C01829ta(requireContext());
        this.LJIL = r3;
        C00969ps r2 = this.LJIJJ;
        AnonymousClass9tT r1 = this.LJIJI;
        String str2 = this.LJJ;
        r3.LIZIZ = r2;
        r3.LIZJ = r1;
        r3.LIZLLL = str2;
        LJIIL();
    }

    public final void LIZ(String str, String str2) {
        if (!TextUtils.isEmpty(str) && !TextUtils.isEmpty(str2)) {
            this.LJ.setText(str);
            this.LJ.setEnabled(false);
            this.LJJIIZ = true;
            this.LJIIIZ.setVisibility(8);
            this.LJIIJJI.setVisibility(8);
            this.LJIILIIL.setVisibility(0);
            LJJIIZI = str;
            LJJIJ = str2;
            Aweme LJIIJJI2 = LJIIJJI();
            if (!LFp.LJJJI(LJIIJJI2)) {
                this.LJIILIIL.setOnClickListener((View.OnClickListener) null);
                return;
            }
            this.LJIILIIL.setOnClickListener(new Ksx(this, str2, LJIIJJI2, LJIIJJI2.getCommerceVideoAuthInfo()));
        }
    }

    public void onCommentInputKeyboardShow(boolean z, String str, 4we r5) {
        this.LJIILLIIL.setVisibility(4);
        LIZ(8);
        AnonymousClass9tY r0 = this.LJIJJLI;
        if (r0 != null) {
            r0.LIZJ();
        }
        LIZ(false, false, false);
    }

    public void onEmojiClick(String str, int i, int i2) {
        String authorUid;
        Aweme LJIIJJI2 = LJIIJJI();
        String str2 = this.LJJ;
        String str3 = "";
        if (LJIIJJI2 == null) {
            authorUid = str3;
        } else {
            str3 = LJIIJJI2.getAid();
            authorUid = LJIIJJI2.getAuthorUid();
        }
        C00309ne.LIZ(str, i, str2, str3, authorUid, false, i2);
    }

    private void LIZ(int i, String str, Bundle bundle) {
        if (this.LJIJI != null) {
            Etp etp = new Etp(i, str);
            etp.LIZJ = bundle;
            this.LJIJI.LIZ(etp);
        }
    }

    public void onCommentInputPublishFailed(Exception exc, int i, Comment comment) {
        int i2;
        Context context = getContext();
        if (comment != null && context != null) {
            if (C00919pn.LIZ(comment)) {
                String awemeId = comment.getAwemeId();
                if (TextUtils.isEmpty(awemeId)) {
                    awemeId = LJIILL();
                }
                if (A05.LIZ.LJ().LIZ((Throwable) exc)) {
                    A05.LIZ.LJ().LIZ(awemeId, AnonymousClass9r7.PERMISSION_DENIED);
                } else if (DSZ.LIZ(getContext(), exc, 2131822843)) {
                    A05.LIZ.LJ().LIZ(awemeId, AnonymousClass9r7.DEFAULT);
                }
            } else if (comment.getPublishScenario() != 1) {
                DSZ.LIZ(context, exc, 2131822843);
            }
            CommentListPageFragment LJIILIIL2 = LJIILIIL();
            if (LJIILIIL2 != null) {
                comment.setIgnoreToast(true);
                LJIILIIL2.LIZ(exc, i, comment);
            }
            if (comment.getFakeGiftId() != 0) {
                try {
                    i2 = ((3qV) exc).getErrorCode();
                } catch (Exception unused) {
                    i2 = 0;
                }
                LIZ(false, comment, i2);
            }
        }
    }

    private void LIZ(boolean z, Comment comment, int i) {
        long id;
        if (LJIIJJI() != null && comment != null) {
            2UX r2 = new 2UX();
            r2.LIZ("enter_from", this.LJJ);
            r2.LIZ("group_id", 4wQ.LJ(LJIIJJI()));
            r2.LIZ("author_id", 4wQ.LIZ(LJIIJJI()));
            r2.LIZ("is_success", z ? 1 : 0);
            if (comment.getGift() == null) {
                id = comment.getFakeGiftId();
            } else {
                id = comment.getGift().getId();
            }
            r2.LIZ("gift_id", id);
            r2.LIZ("is_follow", 4AY.LIZIZ(LJIIJJI()));
            r2.LIZ("is_like", 4AY.LIZ(LJIIJJI()));
            r2.LIZ("is_comment", AnonymousClass9nD.LIZ(comment.getText()) ^ true ? 1 : 0);
            if (i != 0) {
                r2.LIZ("error_code", i);
                r2.LIZ("newtork_condition", LIZ(getContext()));
            }
            if (!this.LJJI.isEmpty()) {
                r2.LIZ("enter_method", this.LJJI);
            } else if (!this.LJIJJ.LJIILLIIL.isEmpty()) {
                r2.LIZ("enter_method", this.LJIJJ.LJIILLIIL);
            } else {
                r2.LIZ("enter_method", "send_button");
            }
            this.LJJI = "";
            if (!(this.LJIJJ.LJJIFFI == -1 || this.LJIJJ.LJJII == -1)) {
                r2.LIZ("gift_value", this.LJIJJ.LJJIFFI);
                r2.LIZ("gift_position", this.LJIJJ.LJJII);
            }
            2nK.LIZ("send_gift", r2.LIZ);
            this.LJIJJ.LJJIFFI = -1;
            this.LJIJJ.LJJII = -1;
        }
    }

    private void LIZ(boolean z, boolean z2, boolean z3) {
        C00969ps r0;
        this.LJIIIZ.setTintColorRes(2130968626);
        this.LJIIJJI.setTintColorRes(2130968626);
        if (this.LJIIJ != null) {
            if (this.LJJIII.LIZ(LJIIJJI())) {
                this.LJIIJ.setTintColorRes(2130968626);
                this.LJIIJ.setVisibility(0);
            } else {
                this.LJIIJ.setVisibility(8);
            }
        }
        if (z) {
            this.LJIIIZ.setVisibility(8);
            this.LJIIJJI.setVisibility(8);
            this.LJIIJ.setVisibility(8);
            this.LJJII.LIZ(false, false, false);
            return;
        }
        this.LJIIIZ.setVisibility(0);
        this.LJIIJJI.setVisibility(0);
        this.LJJII.LIZ(z3, z2, false);
        if (!(z3 || this.LJ == null || (r0 = this.LJIJJ) == null)) {
            r0.LIZ();
        }
        C1810AiE aiE = this.LJ;
        if (aiE != null) {
            aiE.setFocusable(true);
            this.LJ.setFocusableInTouchMode(true);
            this.LJ.requestFocus();
        }
    }

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View LIZ2 = 0HB.LIZ(getActivity(), 2131558787, viewGroup, false);
        if (viewGroup instanceof RelativeLayout) {
            RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(HeD.LIZ(getActivity()), -2);
            layoutParams.addRule(12);
            LIZ2.setLayoutParams(layoutParams);
        } else if (viewGroup instanceof FrameLayout) {
            FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(HeD.LIZ(getActivity()), -2);
            layoutParams2.gravity = 80;
            LIZ2.setLayoutParams(layoutParams2);
        } else {
            LIZ2.setLayoutParams(new ViewGroup.LayoutParams(HeD.LIZ(getActivity()), -2));
        }
        EventBus.LIZ(EventBus.LIZ(), this);
        this.LIZ = (ViewGroup) LIZ2.findViewById(2131364387);
        this.LIZIZ = (ViewGroup) LIZ2.findViewById(2131363495);
        this.LIZJ = LIZ2.findViewById(2131363484);
        this.LIZLLL = LIZ2.findViewById(2131366834);
        this.LJ = (C1810AiE) LIZ2.findViewById(2131363496);
        this.LJIIIZ = LIZ2.findViewById(2131366290);
        this.LJIIJ = LIZ2.findViewById(2131366449);
        this.LJIIJJI = LIZ2.findViewById(2131366408);
        this.LJIIL = LIZ2.findViewById(2131363526);
        this.LJIILIIL = LIZ2.findViewById(2131363525);
        this.LJIILJJIL = (ViewGroup) LIZ2.findViewById(2131363494);
        this.LJIILL = (ViewGroup) LIZ2.findViewById(2131366022);
        this.LJJII = new C02229uo(this.LJIILJJIL);
        this.LJJIFFI = LIZ2.findViewById(2131362060);
        this.LJIILLIIL = LIZ2.findViewById(2131363673);
        this.LJIIZILJ = LIZ2.findViewById(2131370982);
        41j r1 = new 41j(getActivity());
        this.LJIJ = r1;
        r1.LIZ(new 42a());
        this.LJJII.LIZ(false, 0);
        return LIZ2;
    }

    public void onCommentInputPublishClick(int i, int i2, String str, String str2, String str3, boolean z, 4we r47) {
        Aweme LJII;
        String str4 = str;
        AnonymousClass9tT r1 = this.LJIJI;
        if (r1 != null) {
            r1.LIZ(i2);
        }
        4we r12 = r47;
        if (r12 != null) {
            r12.LIZIZ = upvoteWhenComment();
        }
        C01829ta r2 = this.LJIL;
        if (r2 == null || !r2.LIZLLL()) {
            Bundle bundle = new Bundle();
            bundle.putBoolean("is_recommendation", upvoteWhenComment());
            if (TextUtils.equals(str2, "button_send")) {
                LIZ(57, str4, bundle);
            } else {
                LIZ(11, str4, bundle);
            }
        } else {
            C01829ta r3 = this.LJIL;
            AnonymousClass9tT r22 = r3.LIZJ;
            if (!(r22 == null || (LJII = r22.LJII()) == null)) {
                String str5 = "";
                if (str4 == null) {
                    str4 = str5;
                }
                String str6 = r3.LIZLLL;
                if (str6 != null) {
                    str5 = str6;
                }
                4wW.LIZ(LJII, str4, str5, "", (String) null, (Comment) null, (String) null, "", "click_quick_panel", (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, i, (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, (String) null, r12, -67109632, 127);
            }
        }
        LIZ(false, true, false);
    }
}
