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

import X.05h;
import X.08o;
import X.0AA;
import X.0GZ;
import X.0HH;
import X.0SC;
import X.0Zv;
import X.0Zy;
import X.0Zz;
import X.0b0;
import X.0bM;
import X.0c0;
import X.0cm;
import X.0dA;
import X.0dK;
import X.0eg;
import X.15V;
import X.1IL;
import X.1IN;
import X.1JL;
import X.1hK;
import X.1j7;
import X.1j9;
import X.1sU;
import X.2M2;
import X.C0842Tha;
import X.C0854Thm;
import X.C0862Thu;
import X.C0864Thw;
import X.C0884TiG;
import X.C0888TiK;
import X.C0898TiU;
import X.C0904Tia;
import X.C0905Tib;
import X.C0906Tic;
import X.C0907Tid;
import X.Fbl;
import X.Fz8;
import X.Fzd;
import X.G5d;
import X.GSF;
import X.Gb7;
import X.Gg0;
import X.Gg2;
import X.Gg3;
import X.Ggr;
import X.GhW;
import X.Ght;
import X.GiH;
import X.Gio;
import X.Glh;
import X.H7d;
import X.HeD;
import X.T0N;
import X.T1A;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.ColorStateList;
import android.graphics.drawable.ColorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.SystemClock;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.fragment.app.DialogFragment;
import com.bytedance.android.live.base.model.emoji.EmoteModel;
import com.bytedance.android.livesdk.chatroom.event.ISendCommentEvent;
import com.bytedance.android.livesdk.chatroom.model.InputAttrs;
import com.bytedance.android.livesdk.livesetting.comment.EnableLiveKeyboardWithHeightSetting;
import com.bytedance.android.livesdk.livesetting.comment.LiveCommentInputDialogDismissFixSetting;
import com.bytedance.android.livesdk.livesetting.comment.LiveInputDialogAnimationSetting;
import com.bytedance.android.livesdkapi.host.IHostContext;
import com.bytedance.android.livesdkapi.host.IHostEmoji;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.fresco.nativeheif.BuildConfig;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;

public class LiveEmojiInputDialogFragment extends DialogFragment implements 0Zy, 0Zz, GhW {
    public boolean LIZ;
    public C0884TiG LIZIZ;
    public C0904Tia LIZJ;
    public boolean LIZLLL;
    public boolean LJ;
    public 0eg LJFF = 0eg.Keyboard;
    public InputFilter LJI;
    public boolean LJII;
    public boolean LJIIIIZZ;
    public String LJIIIZ;
    public ImageView LJIIJ;
    public Fbl LJIIJJI;
    public TextView LJIIL;
    public View LJIILIIL;
    public View LJIILJJIL;
    public View LJIILL;
    public T1A LJIILLIIL;
    public 0GZ LJIIZILJ;
    public ViewGroup LJIJ;
    public 1sU LJIJI;
    public 0SC LJIJJ;
    public 1IL LJIJJLI;
    public int LJIL;
    public int LJJ;
    public int LJJI;
    public int LJJIFFI;
    public boolean LJJII;
    public final 1j9 LJJIII = new 1j9() {
        static {
            Covode.recordClassIndex(13954);
        }

        public final void LIZ() {
            LiveEmojiInputDialogFragment.this.LIZIZ();
        }

        public final void LIZLLL() {
            LiveEmojiInputDialogFragment.this.LJII();
        }

        public final void LIZIZ() {
            LiveEmojiInputDialogFragment.this.LJIIJJI.dispatchKeyEvent(new KeyEvent(0, 67));
        }

        public final boolean LIZJ() {
            return TextUtils.isEmpty(LiveEmojiInputDialogFragment.this.LJIIIZ);
        }

        public final void LIZ(0SC r3) {
            if (r3 == LiveEmojiInputDialogFragment.this.LJIJJ) {
                LiveEmojiInputDialogFragment.this.LJIJI.setEnabled(!r3.LIZLLL());
            }
        }

        public final void LIZ(1JL r7) {
            int i;
            String string;
            if (r7 != null && r7.LIZ != null && LiveEmojiInputDialogFragment.this.LJIIJJI != null && LiveEmojiInputDialogFragment.this.LJIIJJI.getText() != null) {
                int length = LiveEmojiInputDialogFragment.this.LJIIJJI.getText().length() + r7.LIZ.length();
                if (LiveEmojiInputDialogFragment.this.LJII) {
                    i = 15;
                } else {
                    i = 100;
                }
                if (length > i) {
                    if (LiveEmojiInputDialogFragment.this.LJII) {
                        string = LiveEmojiInputDialogFragment.this.getString(2131833879);
                    } else {
                        string = LiveEmojiInputDialogFragment.this.getString(2131828455, new Object[]{100});
                    }
                    Fz8.LIZ(0b0.LJ(), string, 0);
                } else if (!TextUtils.isEmpty(r7.LIZ)) {
                    LiveEmojiInputDialogFragment.this.LJIIJJI.getText().insert(LiveEmojiInputDialogFragment.this.LJIIJJI.getSelectionStart(), r7.LIZ);
                }
            }
        }
    };
    public final List<0SC> LJJIIJ = new ArrayList();
    public int LJJIIJZLJL;
    public boolean LJJIIZ;
    public String LJJIIZI;
    public boolean LJJIJ;
    public boolean LJJIJIIJI;
    public boolean LJJIJIIJIL;
    public boolean LJJIJIL;
    public ISendCommentEvent.Sender LJJIJL;
    public boolean LJJIJLIJ;
    public 0Zv LJJIL;
    public ImageView LJJIZ;
    public ValueAnimator LJJJ;
    public T0N LJJJI;
    public LinearLayout LJJJIL;
    public ViewGroup LJJJJ;
    public View LJJJJI;
    public 1IN LJJJJIZL;
    public long LJJJJJ;
    public boolean LJJJJJL;
    public boolean LJJJJL;
    public boolean LJJJJLI;
    public final View.OnClickListener LJJJJLL = new C0862Thu(this);
    public final TextWatcher LJJJJZ = new TextWatcher() {
        static {
            Covode.recordClassIndex(13953);
        }

        public final void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        public final void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        public final void afterTextChanged(Editable editable) {
            String obj;
            int i;
            if (LiveEmojiInputDialogFragment.this.LIZ && LiveEmojiInputDialogFragment.this.LJIIJJI != null) {
                Editable text = LiveEmojiInputDialogFragment.this.LJIIJJI.getText();
                LiveEmojiInputDialogFragment liveEmojiInputDialogFragment = LiveEmojiInputDialogFragment.this;
                if (text == null) {
                    obj = BuildConfig.VERSION_NAME;
                } else {
                    obj = text.toString();
                }
                liveEmojiInputDialogFragment.LJIIIZ = obj;
                boolean isEmpty = TextUtils.isEmpty(LiveEmojiInputDialogFragment.this.LJIIIZ);
                if (isEmpty) {
                    LiveEmojiInputDialogFragment.this.LJIIJ.setClickable(false);
                    LiveEmojiInputDialogFragment.this.LJIIL.setVisibility(0);
                } else {
                    LiveEmojiInputDialogFragment.this.LJIIJ.setClickable(true);
                    LiveEmojiInputDialogFragment.this.LJIIL.setVisibility(8);
                    if (!LiveEmojiInputDialogFragment.this.LJJII && LiveEmojiInputDialogFragment.this.LIZIZ != null) {
                        LiveEmojiInputDialogFragment.this.LJJII = true;
                        LiveEmojiInputDialogFragment.this.LIZIZ.LIZIZ();
                    }
                }
                LiveEmojiInputDialogFragment.this.LIZIZ(isEmpty);
                int trimmedLength = TextUtils.getTrimmedLength(LiveEmojiInputDialogFragment.this.LJIIIZ);
                int i2 = 15;
                if (LiveEmojiInputDialogFragment.this.LJII) {
                    i = 15;
                } else {
                    i = 100;
                }
                if (trimmedLength > i) {
                    LiveEmojiInputDialogFragment liveEmojiInputDialogFragment2 = LiveEmojiInputDialogFragment.this;
                    Fbl fbl = liveEmojiInputDialogFragment2.LJIIJJI;
                    liveEmojiInputDialogFragment2.LJI = new InputFilter.LengthFilter(LiveEmojiInputDialogFragment.this.LJIIIZ.length());
                    fbl.setFilters(new InputFilter[]{liveEmojiInputDialogFragment2.LJI});
                } else {
                    LiveEmojiInputDialogFragment liveEmojiInputDialogFragment3 = LiveEmojiInputDialogFragment.this;
                    Fbl fbl2 = liveEmojiInputDialogFragment3.LJIIJJI;
                    if (liveEmojiInputDialogFragment3.LJI != null) {
                        fbl2.setFilters(new InputFilter[0]);
                        liveEmojiInputDialogFragment3.LJI = null;
                    }
                }
                if (!LiveEmojiInputDialogFragment.this.LJII) {
                    i2 = 100;
                }
                if (trimmedLength > i2) {
                    Fz8.LIZ(0b0.LJ(), LiveEmojiInputDialogFragment.this.getString(2131828455), 0);
                    int offsetByCodePoints = LiveEmojiInputDialogFragment.this.LJIIIZ.offsetByCodePoints(0, LiveEmojiInputDialogFragment.this.LJIIIZ.codePointCount(0, 100));
                    if (offsetByCodePoints >= LiveEmojiInputDialogFragment.this.LJIIIZ.length()) {
                        offsetByCodePoints = LiveEmojiInputDialogFragment.this.LJIIIZ.length() - 1;
                    }
                    LiveEmojiInputDialogFragment.this.LJIIJJI.setText(LiveEmojiInputDialogFragment.this.LJIIIZ.substring(0, offsetByCodePoints));
                    try {
                        LiveEmojiInputDialogFragment.this.LJIIJJI.setSelection(LiveEmojiInputDialogFragment.this.LJIIJJI.getText().length());
                    } catch (Exception e) {
                        HashMap hashMap = new HashMap();
                        hashMap.put("error", e.getMessage());
                        0c0.LIZ("ttlive_emoji_fragment_error", 1, hashMap);
                    }
                }
                LiveEmojiInputDialogFragment.this.LJJIII.LIZ(LiveEmojiInputDialogFragment.this.LJIJJLI);
            }
        }
    };

    static {
        Covode.recordClassIndex(13952);
    }

    public final void LIZ(C0854Thm thm) {
    }

    public final void LIZ(EmoteModel emoteModel) {
    }

    public final void LIZJ() {
        this.LJJIJLIJ = true;
    }

    public final void LIZLLL() {
    }

    public final void LIZ(boolean z, int i) {
        if (z) {
            this.LJJJJJ = SystemClock.uptimeMillis();
            if (this.LJFF != 0eg.Keyboard) {
                this.LJFF = 0eg.Keyboard;
            }
            Ght.LIZ("Open keyboard");
            this.LIZLLL = true;
            this.LJJIZ.setImageResource(2131234678);
            this.LJJJIL.setVisibility(8);
            Gg0.LIZ().LIZ(new C0905Tib(i, LJIIJ(), true));
        } else if (this.LJFF == 0eg.Panel) {
            this.LJJIL.setVisibility(0);
            this.LJJIZ.setImageResource(2131234681);
            if (this.LJJJIL.getVisibility() != 0) {
                this.LJJJIL.setVisibility(0);
                LIZ((ViewGroup) this.LJJJIL);
            }
            Gg0.LIZ().LIZ(new C0905Tib(this.LJJIFFI, LJIIJ(), true));
        } else {
            Ght.LIZ("close keyboard");
            if (!LiveCommentInputDialogDismissFixSetting.getValue().LIZ || SystemClock.uptimeMillis() - this.LJJJJJ >= LiveCommentInputDialogDismissFixSetting.getValue().LIZIZ) {
                LJFF();
            } else {
                Ght.LIZ("Unexpected close keyboard");
            }
        }
    }

    public final void LIZ(boolean z, int i, int i2) {
        int measuredHeight;
        int i3 = i2;
        if (z) {
            int i4 = i;
            if (!this.LIZLLL) {
                Gg0.LIZ().LIZ(new C0905Tib(i4, LJIIJ(), true, (byte) 0));
                this.LJJJJJ = SystemClock.uptimeMillis();
            }
            this.LIZLLL = true;
            if (this.LJFF != 0eg.Keyboard) {
                this.LJFF = 0eg.Keyboard;
            }
            if (this.LJJ != i4) {
                this.LJJ = i4;
            }
            Ght.LIZ("Open keyboard");
            this.LJJIZ.setImageResource(2131234678);
            if (this.LJJJIL.getVisibility() != 0) {
                LIZ((-i3) - this.LJIILJJIL.getMeasuredHeight());
                Gg0 LIZ2 = Gg0.LIZ();
                int i5 = this.LJJ;
                LIZ2.LIZ(new C0906Tic(i3, i5, i5, (byte) 0));
            } else if (!this.LJJJJL) {
                final float translationY = this.LJIILIIL.getTranslationY();
                ValueAnimator valueAnimator = this.LJJJ;
                if (valueAnimator != null) {
                    valueAnimator.cancel();
                }
                ValueAnimator duration = ValueAnimator.ofFloat(new float[]{0.0f, 1.0f}).setDuration(100);
                this.LJJJ = duration;
                this.LJJJJL = true;
                duration.setInterpolator(new DecelerateInterpolator());
                final int i6 = i4 - this.LJJIFFI;
                Gg0.LIZ().LIZ(new C0905Tib(i6, LJIIJ(), true, (byte) 0));
                this.LJJJ.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
                    static {
                        Covode.recordClassIndex(13955);
                    }

                    public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                        int animatedFraction = (int) (translationY - (valueAnimator.getAnimatedFraction() * ((float) i6)));
                        LiveEmojiInputDialogFragment.this.LIZ(animatedFraction);
                        Gg0.LIZ().LIZ(new C0906Tic(-(animatedFraction + LiveEmojiInputDialogFragment.this.LJIILJJIL.getMeasuredHeight()), LiveEmojiInputDialogFragment.this.LJJ, LiveEmojiInputDialogFragment.this.LJJ));
                    }
                });
                this.LJJJ.start();
            }
            if (i3 == i4) {
                this.LJJJJL = false;
                this.LJJJIL.setVisibility(8);
            }
        } else if (this.LJFF == 0eg.Panel) {
            this.LJJIZ.setImageResource(2131234681);
            if (this.LJJJIL.getVisibility() != 0) {
                this.LJJJIL.setVisibility(0);
                LIZ((ViewGroup) this.LJJJIL);
                int LIZLLL2 = ((this.LJJ - 0b0.LIZLLL(2131166127)) - 0b0.LIZLLL(2131166130)) - 0b0.LIZ(1.0f);
                ValueAnimator valueAnimator2 = this.LJJJ;
                if (valueAnimator2 != null) {
                    valueAnimator2.cancel();
                }
                Gg0.LIZ().LIZ(new C0905Tib(LIZLLL2, LJIIJ(), true, (byte) 0));
                ValueAnimator duration2 = ValueAnimator.ofFloat(new float[]{0.0f, 1.0f}).setDuration(100);
                this.LJJJ = duration2;
                duration2.setInterpolator(new DecelerateInterpolator());
                this.LJJJ.addUpdateListener(new C0888TiK(this, LIZLLL2));
                this.LJJJ.start();
            }
        } else if (!LiveCommentInputDialogDismissFixSetting.getValue().LIZ || SystemClock.uptimeMillis() - this.LJJJJJ >= LiveCommentInputDialogDismissFixSetting.getValue().LIZIZ) {
            if (this.LJJ < i3) {
                this.LJJ = i3;
            }
            if (this.LIZLLL) {
                Gg0 LIZ3 = Gg0.LIZ();
                int i7 = this.LJJ;
                LIZ3.LIZ(new C0906Tic(i7, i7, 0, false, true));
            } else {
                Gg0.LIZ().LIZ(new C0906Tic(i3, this.LJJ, 0, (byte) 0));
            }
            this.LIZLLL = false;
            float f = (float) i3;
            float f2 = f / (((float) this.LJJ) * 1.0f);
            if (f2 < 0.3f) {
                measuredHeight = (int) (((float) (-(i3 + this.LJIILJJIL.getMeasuredHeight()))) * f2);
            } else {
                measuredHeight = (-i3) - this.LJIILJJIL.getMeasuredHeight();
            }
            if (f == 1.0f) {
                this.LJJJJLI = true;
                this.LJJIL.setVisibility(8);
                if (!(getDialog() == null || getDialog().getWindow() == null)) {
                    getDialog().getWindow().setNavigationBarColor(-16777216);
                }
                C0905Tib tib = new C0905Tib(0, LJIIJ(), false, (byte) 0);
                tib.LIZLLL = true;
                Gg0.LIZ().LIZ(tib);
            }
            LIZ(measuredHeight);
            if (f == 0.0f) {
                Ght.LIZ("close keyboard");
                try {
                    dismiss();
                } catch (IllegalStateException unused) {
                }
            }
        } else {
            Ght.LIZ("Unexpected close keyboard");
        }
    }

    public final void LIZ(boolean z) {
        if (isAdded() && !this.LJIIIIZZ) {
            if (this.LJII) {
                if (z) {
                    return;
                }
            } else if (!z) {
                return;
            }
            this.LJII = z;
            if (z) {
                this.LJIILLIIL.LIZ(true);
            } else {
                this.LJIILLIIL.LIZ();
            }
            LJI();
        }
    }

    public final void LIZ(String str) {
        if (isAdded() && !this.LJIIIIZZ) {
            this.LJIIIZ = str;
            LJI();
        }
    }

    public final void LIZ(Activity activity, String str) {
        show(((1hK) activity).getSupportFragmentManager(), str);
    }

    public final void LIZIZ() {
        LJIIIZ();
        dismissAllowingStateLoss();
    }

    public void onDestroy() {
        LiveEmojiInputDialogFragment.super.onDestroy();
        this.LIZ = false;
    }

    public final void LJIIIZ() {
        if (this.LJIIJJI != null) {
            2M2.LIZIZ(getContext(), this.LJIIJJI);
        }
    }

    public void onPause() {
        LiveEmojiInputDialogFragment.super.onPause();
        this.LJJIL.getKeyBoardObservable().LIZIZ(this);
    }

    private int LJIIJ() {
        View view = this.LJIILJJIL;
        if (view == null || view.getMeasuredHeight() == 0) {
            return 0b0.LIZ(60.0f);
        }
        return this.LJIILJJIL.getMeasuredHeight();
    }

    private InputAttrs LJIIJJI() {
        Bundle arguments = getArguments();
        if (arguments != null) {
            return arguments.getParcelable("live.intent.extra.INPUT_ATTRS");
        }
        return null;
    }

    private void LJIIL() {
        for (0SC LIZJ2 : this.LJJIIJ) {
            LIZJ2.LIZJ(this.LJIIIIZZ);
        }
    }

    public final boolean LJ() {
        if (!0cm.LIZ(IHostEmoji.class).LIZIZ() || this.LJJIIJZLJL == 2) {
            return false;
        }
        return true;
    }

    public final void LJFF() {
        if (this.LIZLLL) {
            this.LIZLLL = false;
            this.LJJIL.setVisibility(8);
            try {
                dismiss();
            } catch (IllegalStateException unused) {
            }
        }
    }

    public void onDestroyView() {
        LiveEmojiInputDialogFragment.super.onDestroyView();
        this.LJJIIZ = false;
        T1A t1a = this.LJIILLIIL;
        if (t1a != null) {
            t1a.clearAnimation();
            this.LJIILLIIL = null;
        }
        ValueAnimator valueAnimator = this.LJJJ;
        if (valueAnimator != null) {
            valueAnimator.cancel();
        }
    }

    public final void LIZ() {
        1IN r1;
        if (isAdded() && !this.LJIIIIZZ && (r1 = this.LJJJJIZL) != null) {
            r1.LIZ((List) null);
        }
    }

    public void onResume() {
        LiveEmojiInputDialogFragment.super.onResume();
        this.LJJJJLI = false;
        this.LJJIL.getKeyBoardObservable().LIZ(this);
        if (this.LJJIIZ && this.LJFF == 0eg.Keyboard) {
            this.LJJIIZ = false;
            LIZ(200, 1, 5);
        } else if (this.LJFF == 0eg.Keyboard) {
            this.LJIIJJI.post(new Runnable() {
                static {
                    Covode.recordClassIndex(13958);
                }

                public final void run() {
                    try {
                        LiveEmojiInputDialogFragment.this.LJIIJJI.requestFocus();
                    } catch (Exception e) {
                        0HH.LIZ(e);
                    }
                }
            });
            this.LJIIJJI.setOnFocusChangeListener(new View.OnFocusChangeListener() {
                static {
                    Covode.recordClassIndex(13959);
                }

                public final void onFocusChange(View view, boolean z) {
                    view.postDelayed(new Runnable() {
                        static {
                            Covode.recordClassIndex(13960);
                        }

                        public final void run() {
                            if (LiveEmojiInputDialogFragment.this.isAdded() && LiveEmojiInputDialogFragment.this.getContext() != null) {
                                if (LiveEmojiInputDialogFragment.this.getActivity() != null) {
                                    LiveEmojiInputDialogFragment.this.getActivity().getWindow().setSoftInputMode(48);
                                }
                                if (!LiveEmojiInputDialogFragment.this.LIZLLL) {
                                    Ght.LIZ("Keyboard will open");
                                    2M2.LIZ(LiveEmojiInputDialogFragment.this.getContext(), LiveEmojiInputDialogFragment.this.LJIIJJI);
                                }
                            }
                        }
                    }, 100);
                    LiveEmojiInputDialogFragment.this.LJIIJJI.setOnFocusChangeListener((View.OnFocusChangeListener) null);
                }
            });
        }
    }

    public final void LJI() {
        if (isAdded()) {
            if (this.LJIIIIZZ) {
                this.LJIIJJI.setText(BuildConfig.VERSION_NAME);
                this.LJIIL.setText(2131829410);
                this.LJIIJJI.setEnabled(false);
                return;
            }
            this.LJIIJJI.setText(this.LJIIIZ);
            if (!TextUtils.isEmpty(this.LJIIIZ) && !15V.LIZ(getContext())) {
                this.LJIIJJI.setSelection(this.LJIIIZ.length());
            }
            this.LJIIJJI.setTextSize(1, 17.0f);
            if (this.LJII) {
                this.LJIIL.setText(2131833769);
            } else if (!TextUtils.isEmpty(this.LJJIIZI)) {
                this.LJIIL.setText(this.LJJIIZI);
            } else {
                this.LJIIL.setText(2131829245);
            }
            this.LJIIJJI.setEnabled(true);
        }
    }

    public final void LJIIIIZZ() {
        0SC r1;
        MethodCollector.i(4280);
        this.LJJJJ.removeAllViews();
        if (this.LJFF != 0eg.Panel || (r1 = this.LJIJJ) == null) {
            this.LJJJJ.setVisibility(8);
            this.LJJJJI.setVisibility(0);
            this.LJIIJJI.requestFocus();
            MethodCollector.o(4280);
            return;
        }
        View LJ2 = r1.LJ(this.LJJJJ);
        if (LJ2 != null) {
            this.LJJJJ.addView(LJ2, -1, -1);
            this.LJJJJ.setVisibility(0);
            this.LJJJJI.setVisibility(8);
            MethodCollector.o(4280);
            return;
        }
        this.LJJJJ.setVisibility(8);
        this.LJJJJI.setVisibility(0);
        this.LJIIJJI.requestFocus();
        MethodCollector.o(4280);
    }

    public final void LJII() {
        C0884TiG tiG = this.LIZIZ;
        if (tiG != null) {
            tiG.LIZ();
        }
        if (!H7d.LIZ().LIZIZ().LJ()) {
            if (getActivity() == null) {
                Fz8.LIZ(0b0.LJ(), 2131833745);
                return;
            }
            Glh LIZIZ2 = H7d.LIZ().LIZIZ();
            1hK activity = getActivity();
            Gg2 LIZ2 = Gg3.LIZ();
            LIZ2.LIZ = 0b0.LIZ(2131834112);
            LIZ2.LIZLLL = "comment_live";
            LIZ2.LIZJ = 1000;
            LIZIZ2.LIZ(activity, LIZ2.LIZ()).LIZIZ(new Gb7());
        } else if (!H7d.LIZ().LIZIZ().LIZ(Gio.COMMENT)) {
            if (this.LJII && 0cm.LIZ(IHostContext.class).isNeedProtectMinor()) {
                Fz8.LIZ(0b0.LJ(), 2131834017);
            } else if (this.LIZIZ != null && this.LJIIJJI.getText() != null) {
                String obj = this.LJIIJJI.getText().toString();
                int i = 0;
                while (i < obj.length()) {
                    if (!(!Character.isWhitespace(obj.charAt(i)))) {
                        i++;
                    } else if (obj.length() > 0) {
                        this.LIZIZ.LIZ(obj, this.LJII, this.LJIL, new GiH(BuildConfig.VERSION_NAME, new ArrayList()));
                        this.LJIL = 0;
                        return;
                    } else {
                        return;
                    }
                }
            }
        }
    }

    public final void LIZ(0eg r1) {
        this.LJFF = r1;
    }

    public void onSaveInstanceState(Bundle bundle) {
        LiveEmojiInputDialogFragment.super.onSaveInstanceState(bundle);
        this.LJJIIZ = this.LIZLLL;
    }

    private void LIZ(ViewGroup viewGroup) {
        viewGroup.post(new C0842Tha(this));
    }

    public final void LIZIZ(String str) {
        this.LJJIIZI = str;
        LJI();
    }

    public final void LIZJ(boolean z) {
        DataChannel LIZ2 = GSF.LIZ(this);
        if (LIZ2 != null) {
            Ggr.LIZ.LIZ(LIZ2, z, LJIIJJI());
        }
    }

    public void onActivityCreated(Bundle bundle) {
        Window window;
        LiveEmojiInputDialogFragment.super.onActivityCreated(bundle);
        Dialog dialog = getDialog();
        if (!(dialog == null || (window = dialog.getWindow()) == null)) {
            window.setLayout(-1, -1);
        }
        if (this.LJJJJJL) {
            this.LJJIL.setWindowInsetsEnable(true);
        }
    }

    public final void LIZIZ(boolean z) {
        if (z) {
            this.LJIIJ.setImageResource(2131234995);
            08o.LIZ(this.LJIIJ, (ColorStateList) null);
            return;
        }
        this.LJIIJ.setImageResource(2131234993);
        ImageView imageView = this.LJIIJ;
        08o.LIZ(imageView, ColorStateList.valueOf(0dA.LIZ(imageView, 2130971317)));
    }

    public final void LIZ(int i) {
        this.LJIILIIL.setTranslationY((float) i);
        ViewGroup.LayoutParams layoutParams = this.LJIILL.getLayoutParams();
        layoutParams.height = Math.abs(i);
        this.LJIILL.setLayoutParams(layoutParams);
    }

    public final void LIZIZ(int i) {
        0SC r4 = this.LJJIIJ.get(i);
        this.LJIJJ = r4;
        if (!(r4 instanceof 1IN)) {
            boolean isEmpty = TextUtils.isEmpty(this.LJIIIZ);
            if (isEmpty) {
                this.LJIIJ.setClickable(false);
            } else {
                this.LJIIJ.setClickable(true);
            }
            LIZIZ(isEmpty);
        } else if (this.LJJJJ.getChildCount() == 0) {
            this.LJIIJ.setClickable(false);
            LIZIZ(true);
        } else {
            this.LJIIJ.setClickable(true);
            LIZIZ(false);
        }
        for (int i2 = 0; i2 < this.LJJIIJ.size(); i2++) {
            if (i2 != i) {
                this.LJJIIJ.get(i2).LIZLLL(false);
            }
        }
        r4.LIZLLL(true);
        LIZ(r4);
        LJIIIIZZ();
    }

    public void onCreate(Bundle bundle) {
        String str;
        LiveEmojiInputDialogFragment.super.onCreate(bundle);
        this.LIZ = true;
        setCancelable(true);
        InputAttrs LJIIJJI2 = LJIIJJI();
        if (LJIIJJI2 != null) {
            this.LJII = LJIIJJI2.LIZ;
            this.LJJIJ = LJIIJJI2.LIZIZ;
            this.LJIIIIZZ = LJIIJJI2.LIZJ;
            this.LJJIJIIJI = LJIIJJI2.LIZLLL;
            if (LJIIJJI2.LJ == null) {
                str = BuildConfig.VERSION_NAME;
            } else {
                str = LJIIJJI2.LJ;
            }
            this.LJIIIZ = str;
            this.LJJIJIIJIL = LJIIJJI2.LJII;
            this.LJJIJIL = LJIIJJI2.LJIIIIZZ;
            this.LJJIIJZLJL = LJIIJJI2.LJIIIZ ^ true ? 1 : 0;
            this.LJJIIZI = LJIIJJI2.LJIILIIL;
            this.LJJIJL = LJIIJJI2.LJIIL;
        }
        LiveInputDialogAnimationSetting.INSTANCE.setDisable(this.LJJIJ);
        if (this.LJJIIJZLJL == 2) {
            this.LJFF = 0eg.Panel;
        }
        boolean windowInsetsAnimationEnable = LiveInputDialogAnimationSetting.windowInsetsAnimationEnable();
        this.LJJJJJL = windowInsetsAnimationEnable;
        if (windowInsetsAnimationEnable) {
            setStyle(1, 2131887262);
        } else {
            setStyle(1, 2131887261);
        }
    }

    public Dialog onCreateDialog(Bundle bundle) {
        Dialog onCreateDialog = LiveEmojiInputDialogFragment.super.onCreateDialog(bundle);
        onCreateDialog.setCanceledOnTouchOutside(this.LJJIJLIJ);
        Window window = onCreateDialog.getWindow();
        if (window != null) {
            window.setGravity(80);
            window.setLayout(-1, -2);
            window.setBackgroundDrawable(new ColorDrawable(0));
            Ght.LIZ("Input Dialog Setting is" + this.LJJJJJL);
            window.addFlags(32);
            if ((!LiveInputDialogAnimationSetting.enableOpt() || Build.VERSION.SDK_INT < 30) && !this.LJJJJJL) {
                window.setSoftInputMode(3);
            } else {
                window.setSoftInputMode(19);
            }
            if (!this.LJJJJJL && ((getActivity() != null && getActivity().getRequestedOrientation() == 0) || (!this.LJJIJ && !0bM.LIZ(getActivity())))) {
                window.addFlags(1024);
            }
            window.clearFlags(2);
        }
        return onCreateDialog;
    }

    public void onDismiss(DialogInterface dialogInterface) {
        Ght.LIZ("Dialog onDismiss");
        Fzd.LIZ().LIZJ();
        if (!this.LJJJJLI) {
            Gg0.LIZ().LIZ(new C0905Tib(0, LJIIJ(), false));
        }
        LiveEmojiInputDialogFragment.super.onDismiss(dialogInterface);
        if (this.LIZIZ != null) {
            InputAttrs inputAttrs = new InputAttrs();
            inputAttrs.LIZIZ = this.LJJIJ;
            inputAttrs.LIZJ = this.LJIIIIZZ;
            inputAttrs.LIZLLL = this.LJJIJIIJI;
            inputAttrs.LIZ = this.LJII;
            inputAttrs.LJ = this.LJIIIZ;
            inputAttrs.LJII = this.LJJIJIIJIL;
            1IN r0 = this.LJJJJIZL;
            if (r0 != null) {
                inputAttrs.LIZ(r0.LIZJ);
            }
            this.LIZIZ.LIZ(inputAttrs);
            this.LIZIZ = null;
            this.LIZLLL = false;
        }
        this.LJJII = false;
    }

    public final void LIZ(0SC r3) {
        this.LJIJI.setText(r3.LIZIZ());
        this.LJIJI.setEnabled(!r3.LIZLLL());
        ViewGroup.LayoutParams layoutParams = this.LJIJI.getLayoutParams();
        if (layoutParams != null) {
            layoutParams.width = r3.LJIIJJI;
            this.LJIJI.setLayoutParams(layoutParams);
        }
        LIZIZ(r3.LIZLLL());
    }

    public final void LIZ(G5d g5d) {
        if (isAdded()) {
            if (this.LJIIIIZZ && g5d.LIZ) {
                return;
            }
            if (this.LJIIIIZZ || g5d.LIZ) {
                this.LJIIIIZZ = g5d.LIZ;
                this.LJJIJIIJI = g5d.LIZIZ;
                LJI();
                LJIIL();
            }
        }
    }

    public final void LIZ(C0884TiG tiG) {
        this.LIZIZ = tiG;
    }

    public void show(0AA r2, String str) {
        Fzd.LIZ().LIZIZ();
        LiveEmojiInputDialogFragment.super.show(r2, str);
    }

    public void showNow(0AA r2, String str) {
        Fzd.LIZ().LIZIZ();
        LiveEmojiInputDialogFragment.super.showNow(r2, str);
    }

    public static LiveEmojiInputDialogFragment LIZ(InputAttrs inputAttrs, C0904Tia tia) {
        LiveEmojiInputDialogFragment liveEmojiInputDialogFragment = new LiveEmojiInputDialogFragment();
        Bundle bundle = new Bundle();
        bundle.putParcelable("live.intent.extra.INPUT_ATTRS", inputAttrs);
        liveEmojiInputDialogFragment.setArguments(bundle);
        liveEmojiInputDialogFragment.LIZJ = tia;
        return liveEmojiInputDialogFragment;
    }

    public void onViewCreated(View view, Bundle bundle) {
        boolean z;
        InputAttrs LJIIJJI2;
        LiveEmojiInputDialogFragment.super.onViewCreated(view, bundle);
        if (this.LJJJJJL) {
            Window window = getDialog().getWindow();
            0dK.LIZ(window);
            window.addFlags(Integer.MIN_VALUE);
            window.setStatusBarColor(0);
            window.setNavigationBarColor(-1);
        }
        this.LJIIJJI.addTextChangedListener(this.LJJJJZ);
        this.LJIILLIIL.setOnClickListener(this.LJJJJLL);
        this.LJJIZ.setOnClickListener(this.LJJJJLL);
        if (this.LJJIJIL) {
            HeD.LIZ(this.LJIILLIIL, 8);
        }
        this.LJJI = (int) HeD.LIZIZ(getContext(), 8.0f);
        this.LJJIFFI = 0b0.LIZLLL(2131166127) + 0b0.LIZLLL(2131166130) + 0b0.LIZ(1.0f);
        LIZJ(LJ());
        Context context = view.getContext();
        1IL r1 = new 1IL(context);
        this.LJIJJLI = r1;
        r1.LJII = GSF.LIZ(this);
        1IL r12 = this.LJIJJLI;
        C0904Tia tia = this.LIZJ;
        boolean z2 = true;
        if (tia == null || tia.LIZIZ()) {
            z = true;
        } else {
            z = false;
        }
        r12.LJIIIZ = z;
        this.LJIJJLI.LIZ(this.LJJIII);
        if (this.LJJIIJZLJL != 2) {
            this.LJJIIJ.add(this.LJIJJLI);
            this.LJJIZ.setVisibility(0);
        } else {
            this.LJJIZ.setVisibility(8);
        }
        if (this.LJJIIJZLJL != 1) {
            1IN r13 = new 1IN(context, false);
            this.LJJJJIZL = r13;
            r13.LJII = GSF.LIZ(this);
            1IN r14 = this.LJJJJIZL;
            C0904Tia tia2 = this.LIZJ;
            if (tia2 != null && !tia2.LIZIZ()) {
                z2 = false;
            }
            r14.LJIIIZ = z2;
            this.LJJJJIZL.LIZ(new 1j7() {
                static {
                    Covode.recordClassIndex(13957);
                }

                public final void LIZ(1JL r1) {
                }

                public final void LIZIZ() {
                }

                public final void LIZ() {
                    LiveEmojiInputDialogFragment.this.LIZIZ();
                }

                public final void LIZ(0SC r2) {
                    if (r2 == LiveEmojiInputDialogFragment.this.LJIJJ) {
                        LiveEmojiInputDialogFragment.this.LIZ(r2);
                    }
                }

                public final void LIZ(List<? extends EmoteModel> list) {
                    if (LiveEmojiInputDialogFragment.this.LIZIZ != null) {
                        LiveEmojiInputDialogFragment.this.LIZIZ.LIZ(list);
                    }
                }
            });
            this.LJJIIJ.add(this.LJJJJIZL);
        }
        LJIIL();
        LJI();
        if (!this.LJIIIIZZ && this.LJII) {
            this.LJIILLIIL.LIZ(false);
        }
        this.LJIILLIIL.setVisibility(8);
        if (this.LJJJJIZL != null && (LJIIJJI2 = LJIIJJI()) != null) {
            this.LJJJJIZL.LIZ(Collections.unmodifiableList(LJIIJJI2.LJIIJJI));
        }
    }

    /*  JADX ERROR: JadxRuntimeException in pass: CodeShrinkVisitor
        jadx.core.utils.exceptions.JadxRuntimeException: Don't wrap MOVE or CONST insns: 0x0005: MOVE  (r6v0 int) = (r11v0 int)
        	at jadx.core.dex.instructions.args.InsnArg.wrapArg(InsnArg.java:164)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.assignInline(CodeShrinkVisitor.java:133)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.checkInline(CodeShrinkVisitor.java:118)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.shrinkBlock(CodeShrinkVisitor.java:65)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.shrinkMethod(CodeShrinkVisitor.java:43)
        	at jadx.core.dex.visitors.shrink.CodeShrinkVisitor.visit(CodeShrinkVisitor.java:35)
        */
    public final void LIZ(long r8, int r10, int r11) {
        /*
            r7 = this;
            X.Fbl r0 = r7.LJIIJJI
            if (r0 == 0) goto L_0x0008
            r5 = r10
            r6 = r11
            if (r5 <= r6) goto L_0x0009
        L_0x0008:
            return
        L_0x0009:
            X.Ti3 r1 = new X.Ti3
            r2 = r7
            r3 = r8
            r1.<init>(r2, r3, r5, r6)
            r0.postDelayed(r1, r3)
            goto L_0x0008
        */
        throw new UnsupportedOperationException("Method not decompiled: com.bytedance.android.livesdk.chatroom.ui.LiveEmojiInputDialogFragment.LIZ(long, int, int):void");
    }

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        int i;
        0Zv LIZ2 = 0HH.LIZ(LayoutInflater.from(getContext()), 2131561756, viewGroup, false);
        this.LJJIL = LIZ2;
        boolean z = true;
        if (EnableLiveKeyboardWithHeightSetting.INSTANCE.getValue() && getActivity() != null && getActivity().getRequestedOrientation() == 1) {
            this.LJJIL.LIZ();
        }
        T0N findViewById = this.LJJIL.findViewById(2131372956);
        this.LJJJI = findViewById;
        if (!this.LJJIJLIJ) {
            findViewById.setActivity(getActivity());
        }
        this.LJJIZ = (ImageView) LIZ2.findViewById(2131368242);
        ImageView imageView = (ImageView) LIZ2.findViewById(2131370099);
        this.LJIIJ = imageView;
        imageView.setOnClickListener(new C0864Thw(this));
        this.LJIILLIIL = LIZ2.findViewById(2131362620);
        this.LJIILIIL = LIZ2.findViewById(2131366019);
        this.LJIILL = LIZ2.findViewById(2131366020);
        this.LJIILJJIL = LIZ2.findViewById(2131366067);
        Fbl findViewById2 = LIZ2.findViewById(2131364420);
        this.LJIIJJI = findViewById2;
        findViewById2.LIZ(new C0907Tid(this));
        this.LJIIJJI.addTextChangedListener(this.LJJJJZ);
        this.LJIIJJI.setOnKeyListener(new C0898TiU(this));
        if (this.LJJJJJL) {
            this.LJJIL.setKeyboardAnimatorObserver(this);
            this.LJJJI.LIZ = false;
            05h layoutParams = this.LJIILIIL.getLayoutParams();
            layoutParams.topToBottom = 2131366021;
            layoutParams.bottomToBottom = -1;
            this.LJIILIIL.setLayoutParams(layoutParams);
        } else {
            T0N t0n = this.LJJJI;
            if (!this.LJJIJ || (getActivity() != null && getActivity().getRequestedOrientation() == 0)) {
                z = false;
            }
            t0n.setShowStatusBar(z);
        }
        this.LJIIL = (TextView) LIZ2.findViewById(2131364421);
        T1A t1a = this.LJIILLIIL;
        if (this.LJJIJIIJIL) {
            i = 0;
        } else {
            i = 8;
        }
        HeD.LIZ(t1a, i);
        if (!this.LJJIJIIJIL) {
            this.LJII = false;
        }
        this.LJJJIL = (LinearLayout) LIZ2.findViewById(2131364512);
        this.LJIIZILJ = LIZ2.findViewById(2131366075);
        this.LJIJ = (ViewGroup) LIZ2.findViewById(2131366073);
        this.LJIJI = LIZ2.findViewById(2131366074);
        this.LJJJJ = (ViewGroup) LIZ2.findViewById(2131366072);
        this.LJJJJI = LIZ2.findViewById(2131366068);
        if (getDialog() != null) {
            this.LJJJI.setOnClickListener(new View.OnClickListener() {
                static {
                    Covode.recordClassIndex(13956);
                }

                public final void onClick(View view) {
                    LiveEmojiInputDialogFragment.this.LJFF = 0eg.Close;
                    LiveEmojiInputDialogFragment.this.LJIIIZ();
                    if (LiveEmojiInputDialogFragment.this.LIZJ != null) {
                        LiveEmojiInputDialogFragment.this.LIZJ.LIZJ();
                        try {
                            LiveEmojiInputDialogFragment.this.LJFF();
                            LiveEmojiInputDialogFragment.this.dismiss();
                        } catch (Exception e) {
                            0HH.LIZ(e);
                        }
                    }
                }
            });
        }
        return LIZ2;
    }
}
