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

import X.070;
import X.0HB;
import X.0HH;
import X.1hK;
import X.2GO;
import X.2HZ;
import X.2Pr;
import X.2UX;
import X.2nK;
import X.3EX;
import X.3MK;
import X.3MM;
import X.3MN;
import X.3af;
import X.3jJ;
import X.46i;
import X.4EI;
import X.4EQ;
import X.4EW;
import X.4FQ;
import X.4Qu;
import X.4Ra;
import X.4ZZ;
import X.4wQ;
import X.4we;
import X.9EH;
import X.9Il;
import X.A56;
import X.AGI;
import X.AGV;
import X.AH0;
import X.AH1;
import X.AH2;
import X.AH3;
import X.AH4;
import X.AH5;
import X.AH7;
import X.AH8;
import X.AH9;
import X.AHD;
import X.AN6;
import X.AnonymousClass9o6;
import X.AnonymousClass9q8;
import X.AnonymousClass9qJ;
import X.AnonymousClass9qK;
import X.AnonymousClass9qM;
import X.AnonymousClass9rL;
import X.AnonymousClass9rM;
import X.AnonymousClass9rN;
import X.AnonymousClass9rO;
import X.AnonymousClass9rP;
import X.AnonymousClass9tP;
import X.C00309ne;
import X.C00409no;
import X.C00969ps;
import X.C01099qf;
import X.C01129qi;
import X.C01489rs;
import X.C01909ti;
import X.C02209um;
import X.C02229uo;
import X.C02279ut;
import X.C0784AGe;
import X.C0795AGp;
import X.C0797AGr;
import X.C0798AGs;
import X.C0799AGt;
import X.C0800AGu;
import X.C0801AGv;
import X.C0802AGw;
import X.C0803AGx;
import X.C0804AGy;
import X.C0805AGz;
import X.C1810AiE;
import X.C1814AiI;
import X.C1815AiJ;
import X.C1818AiM;
import X.C2784Axw;
import X.C2878AzS;
import X.C2883AzX;
import X.DAj;
import X.Dn1;
import X.ESC;
import X.ESN;
import X.HeD;
import X.ISm;
import X.J0e;
import X.J96;
import X.M12;
import X.MNS;
import X.OCa;
import X.OD6;
import X.Otb;
import X.QHW;
import X.QJt;
import X.QJu;
import X.Qeg;
import X.Rc9;
import X.Rwm;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Configuration;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
import android.text.InputFilter;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;
import android.widget.EditText;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.bytedance.ies.abmock.SettingsManager;
import com.bytedance.lighten.loader.SmartImageView;
import com.ss.android.ugc.aweme.base.model.UrlModel;
import com.ss.android.ugc.aweme.base.utils.KeyboardUtils;
import com.ss.android.ugc.aweme.comment.gift.model.GiftStruct;
import com.ss.android.ugc.aweme.comment.gift.model.GiftViewModel;
import com.ss.android.ugc.aweme.comment.model.CommentVideoModel$Type;
import com.ss.android.ugc.aweme.comment.widgets.BaseSearchGifWidget;
import com.ss.android.ugc.aweme.comment.widgets.SearchGifWidget;
import com.ss.android.ugc.aweme.comment.widgets.SearchGifWidgetV2;
import com.ss.android.ugc.aweme.common.ui.BaseDialogFragment;
import com.ss.android.ugc.aweme.feed.model.Aweme;
import com.ss.android.ugc.aweme.feed.model.LogPbBean;
import com.ss.android.ugc.aweme.profile.model.User;
import com.ss.android.ugc.aweme.setting.services.IVideoGiftService;
import com.ss.android.ugc.aweme.setting.services.VideoGiftService;
import com.ss.android.ugc.aweme.views.mention.MentionEditText$MentionSpan;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CancellationException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import kotlin.h.b.n;
import org.greenrobot.eventbus.ThreadMode;

public class KeyboardDialogFragment extends BaseDialogFragment implements DialogInterface.OnShowListener, TextWatcher, C1815AiJ, 3MM, 2HZ, 2GO {
    public static final String[] LJJJLIIL = {"😁", "🥰", "😂", "😳", "😏", "😅", "🥺", "😌", "😬", "😊", "😎"};
    public ViewGroup LIZ;
    public J96 LIZIZ;
    public QJu LIZJ;
    public C1810AiE LIZLLL;
    public 4ZZ LJ;
    public 4ZZ LJFF;
    public J96 LJI;
    public 4ZZ LJII;
    public View LJIIIIZZ;
    public View LJIIIZ;
    public View LJIIJ;
    public View LJIIJJI;
    public OD6 LJIIL;
    public View LJIILIIL;
    public LinearLayout LJIILJJIL;
    public FrameLayout LJIILL;
    public 3MN LJIILLIIL;
    public ImageView LJIIZILJ;
    public View LJIJ;
    public ViewGroup LJIJI;
    public TextView LJIJJ;
    public LinearLayout LJIJJLI;
    public View LJIL;
    public ImageView LJJ;
    public SmartImageView LJJI;
    public Qeg LJJIFFI;
    public FrameLayout LJJII;
    public J0e LJJIII;
    public AnonymousClass9rL LJJIIJ;
    public AnonymousClass9qM LJJIIJZLJL;
    public C01129qi LJJIIZ;
    public boolean LJJIIZI;
    public boolean LJJIJ;
    public int LJJIJIIJI;
    public boolean LJJIJIIJIL;
    public boolean LJJIJIL;
    public int LJJIJL;
    public boolean LJJIJLIJ = false;
    public boolean LJJIL = false;
    public Aweme LJJIZ;
    public BaseSearchGifWidget LJJJ;
    public boolean LJJJI = false;
    public C00969ps LJJJIL;
    public CommentVideoModel$Type LJJJJ = CommentVideoModel$Type.NONE;
    public Otb LJJJJI;
    public GiftViewModel LJJJJIZL = null;
    public long LJJJJJ;
    public Otb LJJJJJL;
    public IVideoGiftService LJJJJL = VideoGiftService.LJIIJ();
    public 1hK LJJJJLI;
    public C0801AGv LJJJLL;
    public AHD LJJJLZIJ;
    public C1814AiI LJJJZ;
    public String LJJL;
    public Pattern LJJLI = Pattern.compile("^\\s*$");
    public boolean LJJLIIIIJ = false;
    public String LJJLIIIJ = "";
    public ValueAnimator LJJLIIIJILLIZJL;
    public 4Qu LJJLIIIJJI;
    public int[] LJJLIIIJJIZ = null;
    public boolean LJJLIIIJL = false;
    public CharSequence LJJLIIIJLJLI = null;
    public Set<String> LJJLIIIJLLLLLLLZ = new HashSet();
    public List<String> LJJLIIJ = new ArrayList();
    public 4Ra LJJLIL = new 4Ra();
    public AGV LJJLJ = new AGV() {
        static {
            Covode.recordClassIndex(57363);
        }

        public final void LIZ() {
            KeyboardDialogFragment.this.LIZJ();
        }
    };
    public CharSequence LJJLJLI;
    public boolean LJJLL = true;
    public C02229uo LJJZ;
    public int LJJZZI = 0;
    public View LJJZZIII = null;
    public View LJL = null;
    public boolean LJLI = false;
    public boolean LJLIIIL = true;

    private String LIZJ(int i) {
        return i == 2 ? "favorite" : i == 3 ? "recent" : "recommend";
    }

    public final boolean LJI() {
        return true;
    }

    public final boolean LJJIJIL() {
        return false;
    }

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

    public Map<Integer, Object> getSubscriberEventTypes() {
        HashMap hashMap = new HashMap();
        hashMap.put(106, new Rc9(KeyboardDialogFragment.class, "onMentionPanelEvent", AH9.class, ThreadMode.MAIN, 0, false));
        return hashMap;
    }

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

    public final boolean LIZ() {
        return this.LJJIJLIJ || this.LJJIL;
    }

    public final boolean LIZ(String str, String str2, String str3) {
        return this.LIZLLL.LIZ(str, str2, str3);
    }

    /* JADX WARNING: Removed duplicated region for block: B:16:0x0061  */
    /* JADX WARNING: Removed duplicated region for block: B:22:0x0072  */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0080  */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x009d  */
    /* JADX WARNING: Removed duplicated region for block: B:36:0x00c8  */
    /* JADX WARNING: Removed duplicated region for block: B:63:0x0164  */
    /* JADX WARNING: Removed duplicated region for block: B:66:0x0179  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public final void LIZ(boolean r9, int r10) {
        /*
            r8 = this;
            r7 = 8703(0x21ff, float:1.2196E-41)
            com.bytedance.frameworks.apm.trace.MethodCollector.i(r7)
            boolean r0 = X.AnonymousClass9o6.LIZ()
            if (r0 == 0) goto L_0x0021
            X.1hK r3 = r8.getActivity()
            if (r3 == 0) goto L_0x0021
            r0 = 16908290(0x1020002, float:2.3877235E-38)
            android.view.View r2 = r3.findViewById(r0)
            android.view.ViewGroup r2 = (android.view.ViewGroup) r2
            if (r9 != 0) goto L_0x01c3
            android.view.View r0 = r8.LJJZZIII
            r2.removeView(r0)
        L_0x0021:
            android.view.View r0 = r8.LJIIIIZZ
            r3 = 0
            r0.setVisibility(r3)
            android.content.Context r1 = r8.getContext()
            r0 = 1130102784(0x435c0000, float:220.0)
            float r1 = X.HeD.LIZIZ(r1, r0)
            X.9rL r0 = r8.LJJIIJ
            int r0 = r0.LJIIIZ()
            if (r0 <= 0) goto L_0x01c0
            X.9rL r0 = r8.LJJIIJ
            int r0 = r0.LJIIIZ()
            int r0 = r0 - r10
            float r2 = (float) r0
            android.content.Context r0 = r8.getContext()
            r4 = 1112539136(0x42500000, float:52.0)
            float r0 = X.HeD.LIZIZ(r0, r4)
            float r2 = r2 - r0
            int r0 = (r2 > r1 ? 1 : (r2 == r1 ? 0 : -1))
            if (r0 <= 0) goto L_0x0197
            int r1 = (int) r2
        L_0x0051:
            X.AzS r0 = X.C2878AzS.LIZ
            r0.LIZ((int) r1)
            boolean r0 = X.C00409no.LIZJ()
            r4 = 1
            if (r0 == 0) goto L_0x0179
            boolean r0 = r8.LJLIIIL
            if (r0 != 0) goto L_0x0179
            if (r9 == 0) goto L_0x0172
            boolean r0 = r8.LJJLIIIJL
            if (r0 == 0) goto L_0x016b
            X.AHD r0 = r8.LJJJLZIJ
            r0.LIZIZ(r4)
        L_0x006c:
            boolean r2 = r8.LJJLIIIJL
            r0 = 300(0x12c, double:1.48E-321)
            if (r2 == 0) goto L_0x007e
            X.AiE r5 = r8.LIZLLL
            X.AGq r2 = new X.AGq
            r2.<init>(r8)
            r5.postDelayed(r2, r0)
            r8.LJJLIIIJL = r3
        L_0x007e:
            if (r9 == 0) goto L_0x0164
            boolean r2 = r8.LJLI
            if (r2 != 0) goto L_0x0099
            boolean r2 = r8.LJLIIIL
            if (r2 != 0) goto L_0x0099
            X.A56 r6 = X.A56.LIZ
            X.AiE r2 = r8.LIZLLL
            int r5 = r2.getSelectionStart()
            X.AiE r2 = r8.LIZLLL
            android.text.Editable r2 = r2.getText()
            r6.LIZ(r5, r2)
        L_0x0099:
            r5 = 8
            if (r9 == 0) goto L_0x00c8
            X.4ZZ r4 = r8.LJFF
            r2 = 2131755383(0x7f100177, float:1.9141644E38)
            r4.setIconRes(r2)
            android.widget.LinearLayout r2 = r8.LJIILJJIL
            r2.setVisibility(r5)
            r8.LIZ((boolean) r3)
            r8.LIZIZ((boolean) r3)
            com.ss.android.ugc.aweme.comment.model.CommentVideoModel$Type r4 = r8.LJJJJ
            com.ss.android.ugc.aweme.comment.model.CommentVideoModel$Type r2 = com.ss.android.ugc.aweme.comment.model.CommentVideoModel$Type.COMMENT
            if (r4 != r2) goto L_0x00c0
            X.J96 r4 = r8.LIZIZ
            X.9so r2 = new X.9so
            r2.<init>(r8)
            r4.postDelayed(r2, r0)
        L_0x00c0:
            r8.LJLI = r9
            r8.LJLIIIL = r3
            com.bytedance.frameworks.apm.trace.MethodCollector.o(r7)
            return
        L_0x00c8:
            X.4ZZ r1 = r8.LJFF
            r0 = 2131755453(0x7f1001bd, float:1.9141786E38)
            r1.setIconRes(r0)
            android.widget.LinearLayout r1 = r8.LJIILJJIL
            boolean r0 = r8.LJJIJLIJ
            if (r0 == 0) goto L_0x00d7
            r5 = 0
        L_0x00d7:
            r1.setVisibility(r5)
            boolean r0 = r8.LJJIJLIJ
            r8.LIZ((boolean) r0)
            boolean r0 = r8.LJJIL
            r8.LIZIZ((boolean) r0)
            boolean r0 = r8.LJJIJIL
            if (r0 == 0) goto L_0x00fa
            boolean r1 = r8.LIZ()
            r0 = 300(0x12c, float:4.2E-43)
            if (r1 == 0) goto L_0x00f6
            r8.LIZIZ((int) r0)
        L_0x00f3:
            r8.LJJIJIL = r3
            goto L_0x00c0
        L_0x00f6:
            r8.LIZ((int) r0)
            goto L_0x00f3
        L_0x00fa:
            boolean r0 = r8.LIZ()
            if (r0 == 0) goto L_0x0108
            com.ss.android.ugc.aweme.comment.widgets.BaseSearchGifWidget r0 = r8.LJJJ
            boolean r0 = r0.LJIILL()
            if (r0 == 0) goto L_0x00c0
        L_0x0108:
            java.lang.StringBuilder r1 = new java.lang.StringBuilder
            java.lang.String r0 = "updateSoftKeyboardState  visible:"
            r1.<init>(r0)
            r1.append(r9)
            java.lang.String r0 = "keyBoardHeight: "
            r1.append(r0)
            r1.append(r10)
            java.lang.String r1 = r1.toString()
            java.lang.String r0 = "xjcccccc"
            X.M12.LIZ(r0, r1)
            boolean r0 = X.C0795AGp.LIZIZ()
            if (r0 == 0) goto L_0x00c0
            boolean r0 = X.C0795AGp.LIZ
            if (r0 != 0) goto L_0x0159
            long r5 = java.lang.System.currentTimeMillis()
            long r0 = X.C0795AGp.LIZLLL
            long r5 = r5 - r0
            r1 = 240(0xf0, double:1.186E-321)
            int r0 = (r5 > r1 ? 1 : (r5 == r1 ? 0 : -1))
            if (r0 >= 0) goto L_0x013f
            int r0 = X.C0795AGp.LJ
            int r0 = r0 + r4
            X.C0795AGp.LJ = r0
        L_0x013f:
            int r1 = X.C0795AGp.LJ
            r0 = 2
            if (r1 < r0) goto L_0x0159
            com.bytedance.keva.Keva r1 = X.C0795AGp.LIZJ
            java.lang.String r0 = "keyboard_can_dismiss"
            r1.storeBoolean(r0, r3)
            com.bytedance.keva.Keva r6 = X.C0795AGp.LIZJ
            long r1 = java.lang.System.currentTimeMillis()
            long r4 = X.C0795AGp.LIZIZ
            long r1 = r1 + r4
            java.lang.String r0 = "keyboard_can_dismiss_expire_time"
            r6.storeLong(r0, r1)
        L_0x0159:
            boolean r0 = X.C0795AGp.LIZ()
            if (r0 == 0) goto L_0x00c0
            r8.dismiss()
            goto L_0x00c0
        L_0x0164:
            X.AzS r2 = X.C2878AzS.LIZ
            r2.LIZ((boolean) r3)
            goto L_0x0099
        L_0x016b:
            X.AHD r0 = r8.LJJJLZIJ
            r0.LIZ((boolean) r4)
            goto L_0x006c
        L_0x0172:
            X.AHD r0 = r8.LJJJLZIJ
            r0.LIZIZ(r4)
            goto L_0x006c
        L_0x0179:
            boolean r0 = X.C00409no.LIZJ()
            if (r0 != 0) goto L_0x006c
            if (r9 == 0) goto L_0x0188
            X.AHD r0 = r8.LJJJLZIJ
            r0.LIZ((boolean) r3)
            goto L_0x006c
        L_0x0188:
            boolean r0 = r8.LJJIJLIJ
            if (r0 != 0) goto L_0x0190
            boolean r0 = r8.LJJIL
            if (r0 == 0) goto L_0x006c
        L_0x0190:
            X.AHD r0 = r8.LJJJLZIJ
            r0.LIZIZ(r3)
            goto L_0x006c
        L_0x0197:
            android.content.Context r0 = r8.getContext()
            int r0 = X.HeD.LIZ(r0)
            float r2 = (float) r0
            android.content.Context r0 = r8.getContext()
            float r0 = X.HeD.LIZIZ(r0, r4)
            float r2 = r2 - r0
            int r0 = (r2 > r1 ? 1 : (r2 == r1 ? 0 : -1))
            if (r0 >= 0) goto L_0x01c0
            android.content.Context r0 = r8.getContext()
            int r0 = X.HeD.LIZ(r0)
            int r0 = r0 - r10
            float r1 = (float) r0
            android.content.Context r0 = r8.getContext()
            float r0 = X.HeD.LIZIZ(r0, r4)
            float r1 = r1 - r0
        L_0x01c0:
            int r1 = (int) r1
            goto L_0x0051
        L_0x01c3:
            android.view.View r0 = r8.LJJZZIII
            if (r0 == 0) goto L_0x01ca
            r2.removeView(r0)
        L_0x01ca:
            android.widget.FrameLayout r1 = new android.widget.FrameLayout
            r1.<init>(r3)
            r8.LJJZZIII = r1
            r0 = 2131099659(0x7f06000b, float:1.7811677E38)
            int r0 = X.070.LIZJ(r3, r0)
            r1.setBackgroundColor(r0)
            android.widget.FrameLayout$LayoutParams r1 = new android.widget.FrameLayout$LayoutParams
            r0 = -1
            r1.<init>(r0, r10)
            r0 = 80
            r1.gravity = r0
            android.view.View r0 = r8.LJJZZIII
            r2.addView(r0, r1)
            goto L_0x0021
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.comment.ui.KeyboardDialogFragment.LIZ(boolean, int):void");
    }

    public final void LIZ(boolean z, boolean z2) {
        Editable text = this.LIZLLL.getText();
        if (!TextUtils.isEmpty(this.LIZLLL.getHint())) {
            this.LJJLJLI = this.LIZLLL.getHint();
        }
        boolean z3 = false;
        boolean z4 = true;
        if ((text == null || text.toString().trim().length() <= 0) && this.LJJLIIIJJI == null) {
            C02229uo r2 = this.LJJZ;
            if (this.LJJJJ == CommentVideoModel$Type.NONE) {
                z4 = false;
            }
            r2.LIZ(false, z2, z4);
            if (TextUtils.isEmpty(this.LJJLJLI)) {
                this.LJJJIL.LIZ();
                this.LIZLLL.setHint(this.LJJJIL.LJIIIIZZ);
                return;
            }
            this.LIZLLL.setHint(this.LJJLJLI);
            return;
        }
        C02229uo r22 = this.LJJZ;
        if (this.LJJJJ != CommentVideoModel$Type.NONE) {
            z3 = true;
        }
        r22.LIZ(true, z, z3);
    }

    public final void LIZ(String str, String str2, int i, LogPbBean logPbBean) {
        AnonymousClass9qM r1 = this.LJJIIJZLJL;
        if (r1 != null) {
            r1.LIZ(str, this.LJJJ.LJIILJJIL(), str2, i, logPbBean);
        }
    }

    public final void LIZ(Aweme aweme, String str, String str2, String str3) {
        2UX r2 = new 2UX();
        r2.LIZ("enter_from", str2);
        r2.LIZ("group_id", 4wQ.LJ(aweme));
        r2.LIZ("author_id", 4wQ.LIZ(aweme));
        if (str3.equals("show_gift_tooltip")) {
            2nK.LIZ("show_gift_tooltip", r2.LIZ);
            return;
        }
        r2.LIZ("enter_method", str);
        2nK.LIZ("dismiss_gift_tooltip", r2.LIZ);
    }

    public final void LIZIZ() {
        this.LJJIJLIJ = false;
        this.LJJIL = false;
    }

    public final MentionEditText$MentionSpan[] LIZLLL() {
        C1810AiE aiE = this.LIZLLL;
        if (aiE != null) {
            return aiE.getMentionText();
        }
        return null;
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [android.view.View, X.AiE] */
    public final void LJ() {
        KeyboardUtils.LIZJ(this.LIZLLL);
        dismiss();
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [X.AiE, android.widget.EditText] */
    public final void LJIIIIZZ() {
        C00969ps r1 = this.LJJJIL;
        if (r1 != null) {
            r1.LIZ((EditText) this.LIZLLL);
        }
    }

    public final boolean LJJIJLIJ() {
        if (this.LJJIJLIJ || this.LJJIL || !this.LJJJJLL) {
            return true;
        }
        return false;
    }

    public final 4we LJFF() {
        String str;
        int i = getArguments().getInt("argIsInvokedFromFakeEditText", -1);
        if (i == 0) {
            str = "comment_button";
        } else if (i != 1) {
            str = "";
        } else {
            str = "input_box";
        }
        return new 4we(str, "graphic_detail");
    }

    public final boolean LJII() {
        if (this.LIZLLL.getTextExtraStructList() == null || this.LIZLLL.getTextExtraStructList().size() < 5) {
            return false;
        }
        return true;
    }

    public final /* synthetic */ void LJIIL() {
        AnonymousClass9rL r1;
        if (LIZ() && (r1 = this.LJJIIJ) != null) {
            r1.LIZJ("box");
        }
        LIZ(0);
        LIZIZ();
    }

    static {
        Covode.recordClassIndex(57362);
    }

    private void LJIILL() {
        if (this.LJJLIIIJJIZ == null) {
            int[] iArr = new int[2];
            this.LIZLLL.getLocationInWindow(iArr);
            int[] iArr2 = new int[2];
            this.LJJLIIIJJIZ = iArr2;
            iArr2[0] = iArr[0];
            iArr2[1] = (int) (((float) iArr[1]) + HeD.LIZIZ(9EH.LJJIFFI.LIZ(), -15.0f));
        }
    }

    private boolean LJIILLIIL() {
        if (getArguments() == null) {
            return false;
        }
        if (getArguments().getInt("viewType") == 1 || getArguments().getInt("viewType") == 2) {
            return true;
        }
        return false;
    }

    public final boolean LJIIIZ() {
        if (!46i.LJFF().isLogin() || !this.LJJIJ) {
            return false;
        }
        if (this.LIZLLL.getTextExtraStructList() == null || this.LIZLLL.getTextExtraStructList().size() < 5) {
            return true;
        }
        return false;
    }

    public final /* synthetic */ void LJIIJJI() {
        if (!this.LJJIL) {
            if (this.LJJIJLIJ) {
                this.LJJIJLIJ = false;
                LIZ(false);
                LIZIZ(true);
            } else {
                LIZIZ(0);
            }
            this.LJJIL = true;
            C00969ps r1 = this.LJJJIL;
            if (r1 != null) {
                r1.LIZ("click_gift_icon");
                return;
            }
            return;
        }
        LIZ(0);
        LIZIZ();
    }

    public final /* synthetic */ void LJIILIIL() {
        AnonymousClass9rL r1 = this.LJJIIJ;
        if (r1 != null) {
            if (this.LJJIJLIJ) {
                r1.LIZJ("icon");
            } else {
                r1.LJIIIIZZ();
            }
        }
        if (!this.LJJIJLIJ) {
            if (this.LJJIL) {
                this.LJJIL = false;
                LIZIZ(false);
                LIZ(true);
            } else {
                LIZIZ(0);
            }
            this.LJJIJLIJ = true;
            return;
        }
        LIZ(0);
        LIZIZ();
    }

    public final /* synthetic */ void LJIILJJIL() {
        if (this.LJJIIJ != null) {
            this.LJJJI = true;
            if (!LIZ()) {
                int selectionStart = this.LIZLLL.getSelectionStart();
                Editable text = this.LIZLLL.getText();
                if (LJII()) {
                    3af r1 = new 3af(this);
                    r1.LJ(2131826910);
                    3af.LIZ(r1);
                } else if (text != null) {
                    text.insert(selectionStart, "@");
                }
            } else {
                this.LJJLIIIJL = true;
                LIZ(0);
                LIZIZ();
            }
        }
    }

    public void onDestroy() {
        C1810AiE aiE;
        KeyboardDialogFragment.super.onDestroy();
        C00969ps r2 = this.LJJJIL;
        if (!(r2 == null || (aiE = this.LIZLLL) == null || !r2.LJIIZILJ.contains(aiE))) {
            r2.LJIIZILJ.remove(aiE);
        }
        A56.LIZ.LIZ(C2883AzX.ON_DESTROY);
        J0e j0e = this.LJJIII;
        if (j0e != null) {
            DAj.LIZ(j0e.LJIIIIZZ, (CancellationException) null);
            if (j0e.LJIIIZ.LIZJ) {
                M12.LIZ(j0e);
            }
        }
    }

    public void onPause() {
        1hK activity;
        ViewGroup viewGroup;
        MethodCollector.i(8316);
        KeyboardDialogFragment.super.onPause();
        this.LJIILLIIL.getKeyBoardObservable().LIZIZ(this);
        if (!(!AnonymousClass9o6.LIZ() || (activity = getActivity()) == null || this.LJJZZIII == null || (viewGroup = (ViewGroup) activity.findViewById(16908290)) == null)) {
            viewGroup.removeView(this.LJJZZIII);
        }
        MethodCollector.o(8316);
    }

    public void onResume() {
        KeyboardDialogFragment.super.onResume();
        this.LJIILLIIL.getKeyBoardObservable().LIZ(this);
        this.LIZLLL.requestFocus();
        if (LIZ()) {
            LIZIZ(200);
        } else if (!AnonymousClass9o6.LIZ()) {
            LIZ(200);
        } else if (this.LJJLL) {
            this.LJJLL = false;
        } else {
            LIZ(0);
        }
    }

    public void onStart() {
        try {
            Window window = getDialog().getWindow();
            WindowManager.LayoutParams attributes = window.getAttributes();
            if (attributes != null) {
                if (AnonymousClass9o6.LIZ()) {
                    attributes.dimAmount = 0.0f;
                    attributes.windowAnimations = 0;
                } else {
                    attributes.dimAmount = 0.15f;
                }
                window.setAttributes(attributes);
            }
        } catch (Exception unused) {
        }
        KeyboardDialogFragment.super.onStart();
    }

    public final void LJIIJ() {
        this.LJJJ.LJIIL();
        int height = this.LJIIIZ.getHeight();
        int height2 = this.LJIIJ.getHeight();
        TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f, (float) height, 0.0f);
        translateAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        translateAnimation.setDuration(300);
        AnimationSet animationSet = new AnimationSet(true);
        animationSet.addAnimation(new TranslateAnimation(0.0f, 0.0f, 0.0f, (float) height2));
        animationSet.addAnimation(new AlphaAnimation(1.0f, 0.0f));
        animationSet.setInterpolator(new AccelerateDecelerateInterpolator());
        animationSet.setDuration(300);
        translateAnimation.setAnimationListener(new Animation.AnimationListener() {
            static {
                Covode.recordClassIndex(57368);
            }

            public final void onAnimationEnd(Animation animation) {
            }

            public final void onAnimationRepeat(Animation animation) {
            }

            public final void onAnimationStart(Animation animation) {
                KeyboardDialogFragment.this.LJIIIZ.setVisibility(0);
            }
        });
        animationSet.setAnimationListener(new Animation.AnimationListener() {
            static {
                Covode.recordClassIndex(57369);
            }

            public final void onAnimationRepeat(Animation animation) {
            }

            public final void onAnimationStart(Animation animation) {
            }

            /* JADX WARNING: type inference failed for: r0v12, types: [android.view.View, X.AiE] */
            /* JADX WARNING: type inference failed for: r0v21, types: [android.view.View, X.AiE] */
            public final void onAnimationEnd(Animation animation) {
                KeyboardDialogFragment.this.LJIIJ.setAlpha(0.0f);
                KeyboardDialogFragment.this.LJIIJ.setVisibility(8);
                KeyboardDialogFragment.this.LIZLLL.requestFocus();
                if (!KeyboardDialogFragment.this.LIZ()) {
                    A56.LIZ.LIZ(KeyboardDialogFragment.this.LIZLLL.getSelectionStart(), KeyboardDialogFragment.this.LIZLLL.getText());
                    KeyboardDialogFragment.this.LJFF.setIconRes(2131755383);
                    KeyboardUtils.LIZIZ(KeyboardDialogFragment.this.LIZLLL);
                    return;
                }
                C2878AzS.LIZ.LIZ(false);
                KeyboardDialogFragment.this.LJFF.setIconRes(2131755453);
                KeyboardUtils.LIZJ(KeyboardDialogFragment.this.LIZLLL);
            }
        });
        this.LJIIIZ.startAnimation(translateAnimation);
        this.LJIIJ.startAnimation(animationSet);
    }

    public final void LJJIJL() {
        LJIILL();
        int height = this.LJIIIZ.getHeight();
        int height2 = this.LJIIJ.getHeight();
        TranslateAnimation translateAnimation = new TranslateAnimation(0.0f, 0.0f, 0.0f, (float) height);
        translateAnimation.setInterpolator(new AccelerateDecelerateInterpolator());
        translateAnimation.setDuration(300);
        TranslateAnimation translateAnimation2 = new TranslateAnimation(0.0f, 0.0f, (float) height2, 0.0f);
        translateAnimation2.setInterpolator(new AccelerateDecelerateInterpolator());
        translateAnimation2.setDuration(300);
        translateAnimation.setAnimationListener(new Animation.AnimationListener() {
            static {
                Covode.recordClassIndex(57366);
            }

            public final void onAnimationRepeat(Animation animation) {
            }

            public final void onAnimationStart(Animation animation) {
            }

            public final void onAnimationEnd(Animation animation) {
                KeyboardDialogFragment.this.LJIIIZ.setVisibility(8);
            }
        });
        translateAnimation2.setAnimationListener(new Animation.AnimationListener() {
            static {
                Covode.recordClassIndex(57367);
            }

            public final void onAnimationEnd(Animation animation) {
            }

            public final void onAnimationRepeat(Animation animation) {
            }

            public final void onAnimationStart(Animation animation) {
                KeyboardDialogFragment.this.LJIIJ.setAlpha(1.0f);
                KeyboardDialogFragment.this.LJIIJ.setVisibility(0);
                KeyboardDialogFragment.this.LJJJ.LJIIJJI();
            }
        });
        this.LJIIIZ.startAnimation(translateAnimation);
        this.LJIIJ.startAnimation(translateAnimation2);
    }

    public void dismiss() {
        this.LJJJZ = null;
        ValueAnimator valueAnimator = this.LJJLIIIJILLIZJL;
        if (valueAnimator != null && valueAnimator.isRunning()) {
            this.LJJLIIIJILLIZJL.cancel();
            this.LJIIZILJ.setVisibility(8);
        }
        this.LJJJ.LJIILIIL();
        try {
            KeyboardDialogFragment.super.dismiss();
        } catch (IllegalStateException unused) {
            KeyboardDialogFragment.super.dismissAllowingStateLoss();
        }
        C01129qi r2 = this.LJJIIZ;
        if (r2 != null) {
            r2.LIZ(this.LJJLIIIJJI, LJFF());
        }
        this.LJJLIIIJJI = null;
        if (this.LJJJJ != CommentVideoModel$Type.NONE) {
            this.LIZIZ.setVisibility(8);
            if (this.LJJIIZI) {
                this.LJFF.setVisibility(0);
                this.LJJIIZI = false;
            }
            Otb otb = this.LJJJJI;
            if (otb != null) {
                otb.dismiss();
            }
        }
        if (this.LIZLLL != null && Build.VERSION.SDK_INT < 23) {
            this.LIZLLL.setCursorVisible(false);
        }
    }

    public final void LIZJ() {
        int i;
        4we LJFF2 = LJFF();
        getArguments().putInt("argIsInvokedFromFakeEditText", -1);
        AnonymousClass9rL r1 = this.LJJIIJ;
        if (r1 != null) {
            r1.LIZ(this.LIZLLL.getText(), this.LIZLLL.getTextExtraStructList(), this.LJJLIIIJJI, this.LJJIJIIJIL, this.LJJZZI, LJFF2);
            this.LJJLIL.LIZIZ();
            4Ra r6 = this.LJJLIL;
            Editable text = this.LIZLLL.getText();
            LinkedHashMap linkedHashMap = new LinkedHashMap();
            if (!(text == null || text.length() == 0)) {
                Matcher matcher = C1818AiM.LIZ.matcher(text);
                while (matcher.find()) {
                    String group = matcher.group();
                    if (r6.LIZ(group)) {
                        Integer num = (Integer) linkedHashMap.get(group);
                        if (num == null || num.intValue() <= 0) {
                            i = 1;
                        } else {
                            i = Integer.valueOf(num.intValue() + 1);
                        }
                        n.LIZIZ(group, "");
                        linkedHashMap.put(group, i);
                    }
                }
            }
            C00309ne.LIZ((LinkedHashMap<String, Integer>) linkedHashMap);
        }
    }

    public final void LIZ(4Qu r2) {
        this.LJJLIIIJJI = r2;
        this.LJJJIL.LIZ(r2);
    }

    public void onAttach(Context context) {
        KeyboardDialogFragment.super.onAttach(context);
        if (context instanceof 1hK) {
            this.LJJJJLI = 3jJ.LIZIZ(context);
        }
    }

    public void onShow(DialogInterface dialogInterface) {
        C01129qi r1 = this.LJJIIZ;
        if (r1 != null) {
            r1.LIZ(LJFF());
        }
    }

    public final String LIZIZ(4Qu r2) {
        if (r2 == null || r2.getAnimateUrl() == null) {
            return "";
        }
        return r2.getAnimateUrl().getUri();
    }

    @ISm(LIZ = ThreadMode.MAIN)
    public void onMentionPanelEvent(AH9 ah9) {
        if (ah9 == null || !C00409no.LIZJ()) {
            return;
        }
        if (ah9.LIZ) {
            this.LJJJLZIJ.LIZIZ(true);
        } else {
            this.LJJJLZIJ.LIZ(true);
        }
    }

    private void LIZ(boolean z) {
        int i;
        int i2;
        4ZZ r1 = this.LJFF;
        if (z) {
            i = 2131755453;
        } else {
            i = 2131755383;
        }
        r1.setIconRes(i);
        C0801AGv aGv = this.LJJJLL;
        if (z) {
            i2 = 0;
        } else {
            i2 = 8;
        }
        aGv.LIZ(i2);
        LIZJ(!z);
    }

    private void LIZIZ(boolean z) {
        float f;
        int i;
        if (z) {
            this.LJII.setIconRes(2131755292);
            this.LJII.LIZ();
        } else {
            this.LJII.setIconRes(2131755423);
            this.LJII.setTintColorRes(2130968666);
            4ZZ r1 = this.LJII;
            if (LJIILLIIL()) {
                f = 1.0f;
            } else {
                f = 0.5f;
            }
            r1.setAlpha(f);
        }
        LinearLayout linearLayout = this.LJIJJLI;
        if (z) {
            i = 0;
        } else {
            i = 8;
        }
        linearLayout.setVisibility(i);
    }

    private void LIZJ(boolean z) {
        String str;
        if (getArguments() != null) {
            str = getArguments().getString("enterFrom");
        } else {
            str = "";
        }
        2UX r2 = new 2UX();
        r2.LIZ("enter_from", str);
        r2.LIZ("position", "comment");
        r2.LIZ("is_fast_panel", z ? 1 : 0);
        2nK.LIZ("show_emoji_board", r2.LIZ);
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [android.widget.TextView, X.AiE] */
    public void afterTextChanged(Editable editable) {
        boolean z;
        C1818AiM.LIZ((TextView) this.LIZLLL);
        LJIIIIZZ();
        if (this.LJI != null) {
            boolean z2 = false;
            if (editable == null || editable.toString().trim().length() == 0) {
                z = true;
            } else {
                z = false;
            }
            if (this.LJI.getVisibility() == 0) {
                z2 = true;
            }
            if (z) {
                if (!z2) {
                    return;
                }
            } else if (z2) {
                return;
            }
            LIZ(!z2, true);
        }
    }

    public void onConfigurationChanged(Configuration configuration) {
        KeyboardDialogFragment.super.onConfigurationChanged(configuration);
        3MN r2 = this.LJIILLIIL;
        if (r2 != null) {
            r2.LIZ(configuration.orientation, MNS.LIZ.LIZ().LJII());
        }
        Otb otb = this.LJJJJJL;
        if (otb != null && otb.isShowing()) {
            this.LJJJJJL.dismiss();
        }
        AHD ahd = this.LJJJLZIJ;
        if (ahd != null) {
            ahd.LIZ();
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:6:0x0020  */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public android.app.Dialog onCreateDialog(android.os.Bundle r8) {
        /*
            r7 = this;
            android.app.Dialog r6 = com.ss.android.ugc.aweme.comment.ui.KeyboardDialogFragment.super.onCreateDialog(r8)
            android.view.Window r5 = r6.getWindow()
            android.os.Bundle r4 = r7.getArguments()
            r3 = 19
            r2 = 0
            r1 = 1
            if (r4 == 0) goto L_0x003c
            java.lang.String r0 = "showEmojiPanel"
            boolean r0 = r4.getBoolean(r0)
            if (r0 == 0) goto L_0x002f
            r7.LJJIJLIJ = r1
            r7.LJLIIIL = r2
        L_0x001e:
            if (r5 == 0) goto L_0x0028
            r5.setSoftInputMode(r3)
            r0 = 80
            r5.setGravity(r0)
        L_0x0028:
            r6.setCanceledOnTouchOutside(r2)
            r6.setCancelable(r1)
            return r6
        L_0x002f:
            java.lang.String r0 = "showGiftPanel"
            boolean r0 = r4.getBoolean(r0)
            if (r0 == 0) goto L_0x003c
            r7.LJJIL = r1
            r7.LJLIIIL = r2
            goto L_0x001e
        L_0x003c:
            r3 = 20
            goto L_0x001e
        */
        throw new UnsupportedOperationException("Method not decompiled: com.ss.android.ugc.aweme.comment.ui.KeyboardDialogFragment.onCreateDialog(android.os.Bundle):android.app.Dialog");
    }

    public final void LIZIZ(int i) {
        C0798AGs aGs = new C0798AGs(this);
        if (i == 0) {
            aGs.run();
        } else {
            this.LIZLLL.postDelayed(aGs, (long) i);
        }
    }

    public void onCreate(Bundle bundle) {
        KeyboardDialogFragment.super.onCreate(bundle);
        if (AnonymousClass9o6.LIZ()) {
            setStyle(1, 2131886936);
        } else {
            setStyle(1, 2131886935);
        }
        GiftViewModel giftViewModel = this.LJJJJIZL;
        if (giftViewModel != null) {
            giftViewModel.LIZLLL().removeObservers(getActivity());
            this.LJJJJIZL.LIZIZ().removeObservers(getActivity());
            this.LJJJJIZL.LIZJ().removeObservers(getActivity());
            this.LJJJJIZL.LIZLLL().setValue(Long.MIN_VALUE);
        }
    }

    public final void LIZ(int i) {
        AnonymousClass9tP r3 = new AnonymousClass9tP(this);
        if (i == 0) {
            r3.run();
        } else {
            this.LIZLLL.postDelayed(r3, (long) i);
        }
    }

    /* JADX WARNING: type inference failed for: r0v0, types: [X.AiE, android.widget.EditText] */
    public final void LIZ(C00969ps r2) {
        this.LJJJIL = r2;
        ? r0 = this.LIZLLL;
        if (r0 != 0) {
            r2.LIZIZ((EditText) r0);
        }
    }

    /* JADX WARNING: type inference failed for: r2v1, types: [com.ss.android.ugc.aweme.comment.ui.KeyboardDialogFragment$3, android.text.TextWatcher] */
    /* JADX WARNING: type inference failed for: r5v3, types: [X.AiE, android.widget.EditText] */
    /* JADX WARNING: type inference failed for: r4v28, types: [X.AiE, android.widget.EditText] */
    public void onActivityCreated(Bundle bundle) {
        int i;
        boolean z;
        int i2;
        int i3;
        int i4;
        UrlModel animateUrl;
        int[] iArr;
        int i5;
        String str;
        String str2;
        String str3;
        int i6;
        KeyboardDialogFragment keyboardDialogFragment = this;
        MethodCollector.i(8306);
        Bundle bundle2 = bundle;
        KeyboardDialogFragment.super.onActivityCreated(bundle2);
        Context context = keyboardDialogFragment.getContext();
        if (context == null) {
            context = 9EH.LJJIFFI.LIZ();
        }
        A56.LIZ.LIZ(context, keyboardDialogFragment, new C01489rs(keyboardDialogFragment), new AnonymousClass9rN(keyboardDialogFragment), new AnonymousClass9rM(keyboardDialogFragment), new AnonymousClass9rO(keyboardDialogFragment));
        keyboardDialogFragment.LIZLLL.addTextChangedListener(new Rwm() {
            static {
                Covode.recordClassIndex(57365);
            }

            public final void afterTextChanged(Editable editable) {
                if (KeyboardDialogFragment.this.LJIIIZ() && !KeyboardDialogFragment.this.LIZ()) {
                    A56.LIZ.LIZ(KeyboardDialogFragment.this.LIZLLL.getSelectionStart(), editable);
                }
                KeyboardDialogFragment.this.LJIIIIZZ();
            }

            public final void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
                if (!KeyboardDialogFragment.this.LJII()) {
                    KeyboardDialogFragment.this.LJ.setAlpha(1.0f);
                }
                if (!TextUtils.isEmpty(charSequence) && i3 > 0) {
                    if ('@' == charSequence.toString().charAt((i + i3) - 1) && KeyboardDialogFragment.this.LJIIIZ()) {
                        C2878AzS.LIZ.LIZ(true);
                        if (KeyboardDialogFragment.this.LJJIIJ != null) {
                            if (KeyboardDialogFragment.this.LJJJI) {
                                KeyboardDialogFragment.this.LJJIIJ.LIZLLL("button");
                            } else {
                                KeyboardDialogFragment.this.LJJIIJ.LIZLLL("input");
                            }
                            if (KeyboardDialogFragment.this.LIZ()) {
                                KeyboardDialogFragment.this.LJJIIJ.LIZJ("icon");
                                KeyboardDialogFragment.this.LIZ(0);
                                KeyboardDialogFragment.this.LIZIZ();
                            }
                        }
                        KeyboardDialogFragment.this.LJJJI = false;
                    } else if (KeyboardDialogFragment.this.LJII()) {
                        KeyboardDialogFragment.this.LJ.setAlpha(0.5f);
                    }
                }
            }
        });
        keyboardDialogFragment.LIZLLL.setHighlightColor(070.LIZJ(keyboardDialogFragment.getContext(), 2131099653));
        keyboardDialogFragment.getDialog().getWindow().setLayout(-1, -1);
        keyboardDialogFragment.getDialog().setOnShowListener(keyboardDialogFragment);
        if (AnonymousClass9o6.LIZ()) {
            keyboardDialogFragment.LIZ(0);
        }
        if (keyboardDialogFragment.getArguments() != null) {
            keyboardDialogFragment.getArguments().getBoolean("isCommentDesc", false);
        }
        keyboardDialogFragment.LJI.setOnClickListener(new C0805AGz(keyboardDialogFragment));
        keyboardDialogFragment.LJ.setOnClickListener(new AH0(keyboardDialogFragment));
        keyboardDialogFragment.LIZIZ.setOnClickListener(new C01099qf(keyboardDialogFragment));
        keyboardDialogFragment.LJFF.setOnClickListener(new AH1(keyboardDialogFragment));
        4ZZ r4 = keyboardDialogFragment.LJFF;
        if (keyboardDialogFragment.LJJIJLIJ) {
            i = 2131755453;
        } else {
            i = 2131755383;
        }
        r4.setIconRes(i);
        C0801AGv aGv = new C0801AGv(keyboardDialogFragment.LJIILJJIL);
        keyboardDialogFragment.LJJJLL = aGv;
        C0803AGx aGx = new C0803AGx(keyboardDialogFragment);
        M12.LIZ(aGx);
        aGv.LIZ = aGx;
        keyboardDialogFragment.LIZLLL.setMentionTextColor(070.LIZJ(9EH.LJJIFFI.LIZ(), 2131099750));
        boolean z2 = true;
        keyboardDialogFragment.LIZLLL.setMentionTextTypeface(1);
        keyboardDialogFragment.LIZLLL.setOnMentionInputListener(new AH4(keyboardDialogFragment));
        keyboardDialogFragment.LIZLLL.setOnClickListener(new AH2(keyboardDialogFragment));
        keyboardDialogFragment.LJIILLIIL.setOnClickListener(new AnonymousClass9rP(keyboardDialogFragment));
        keyboardDialogFragment.LJIILLIIL.findViewById(2131363673).setOnClickListener(AH7.LIZ);
        keyboardDialogFragment.LJIILIIL.setOnClickListener(new C0797AGr(keyboardDialogFragment));
        if (keyboardDialogFragment.getArguments() == null || !keyboardDialogFragment.getArguments().getBoolean("hideGiftIcon", false)) {
            z = false;
        } else {
            z = true;
        }
        if (!z) {
            4ZZ r9 = keyboardDialogFragment.LJII;
            if (keyboardDialogFragment.LJJJJL.LIZ(keyboardDialogFragment.LJJIZ)) {
                i5 = 0;
            } else {
                i5 = 8;
            }
            r9.setVisibility(i5);
            if (!keyboardDialogFragment.LJJJJL.LIZ(keyboardDialogFragment.LJJIZ) || !keyboardDialogFragment.LJIILLIIL() || keyboardDialogFragment.LJJJJIZL == null) {
                GiftViewModel giftViewModel = keyboardDialogFragment.LJJJJIZL;
                if (!(giftViewModel == null || giftViewModel.LIZIZ().getValue() == null)) {
                    keyboardDialogFragment.LJJJJIZL.LIZIZ().setValue((Object) null);
                }
            } else {
                if (keyboardDialogFragment.LJIJJLI != null) {
                    Aweme aweme = keyboardDialogFragment.LJJIZ;
                    if (aweme != null) {
                        str = aweme.getGroupId();
                    } else {
                        str = "";
                    }
                    Aweme aweme2 = keyboardDialogFragment.LJJIZ;
                    if (aweme2 != null) {
                        str2 = aweme2.getAuthorUid();
                    } else {
                        str2 = "";
                    }
                    if (keyboardDialogFragment.getArguments() != null) {
                        str3 = keyboardDialogFragment.getArguments().getString("enterFrom");
                    } else {
                        str3 = "";
                    }
                    if (!(keyboardDialogFragment.getActivity() == null || keyboardDialogFragment.LJJIZ == null || keyboardDialogFragment.LJJJJIZL == null)) {
                        keyboardDialogFragment.LJIJJLI.addView(new AGI(keyboardDialogFragment, keyboardDialogFragment.LJIJJLI, keyboardDialogFragment.getActivity(), keyboardDialogFragment.LJJJJIZL, keyboardDialogFragment.LJJLJ, str3, str, str2).LIZIZ);
                        LinearLayout linearLayout = keyboardDialogFragment.LJIJJLI;
                        if (keyboardDialogFragment.LJJIL) {
                            i6 = 0;
                        } else {
                            i6 = 8;
                        }
                        linearLayout.setVisibility(i6);
                    }
                }
                keyboardDialogFragment.LJJJJIZL.LIZ(keyboardDialogFragment.LJJIZ.getAid(), keyboardDialogFragment.LJJIZ.getAuthorUid());
                keyboardDialogFragment.LJJJJIZL.LIZIZ().observe(keyboardDialogFragment.getActivity(), new C02209um(keyboardDialogFragment));
                keyboardDialogFragment.LJJJJIZL.LIZLLL().observe(keyboardDialogFragment.getActivity(), AH8.LIZ);
                keyboardDialogFragment.LJJI.setOnClickListener(new AnonymousClass9qJ(keyboardDialogFragment));
                keyboardDialogFragment.LJJ.setOnClickListener(new AnonymousClass9qK(keyboardDialogFragment));
            }
            keyboardDialogFragment.LIZIZ(keyboardDialogFragment.LJJIL);
            if (keyboardDialogFragment.LJIILLIIL()) {
                keyboardDialogFragment.LJII.setOnClickListener(new C0804AGy(keyboardDialogFragment));
            } else {
                keyboardDialogFragment.LJII.setOnClickListener(new C01909ti(keyboardDialogFragment));
            }
        }
        QJt LIZ2 = QHW.LIZ(3EX.LIZ(46i.LJFF().getCurUser().getAvatarThumb()));
        LIZ2.LJJIIZ = keyboardDialogFragment.LIZJ;
        LIZ2.LIZJ();
        keyboardDialogFragment.LIZJ.setVisibility(0);
        if (AnonymousClass9o6.LIZ()) {
            if (keyboardDialogFragment.getArguments().getBoolean("arg_require_gray_background")) {
                keyboardDialogFragment.LJL.setVisibility(0);
                ObjectAnimator.ofFloat(keyboardDialogFragment.LJL, "alpha", new float[]{0.0f, 1.0f}).start();
            }
            WindowManager.LayoutParams attributes = keyboardDialogFragment.getDialog().getWindow().getAttributes();
            if (!(attributes == null || (attributes.softInputMode & 3) == 0)) {
                int LIZIZ2 = HeD.LIZIZ(keyboardDialogFragment.LJIILLIIL.getContext());
                ObjectAnimator.ofFloat(keyboardDialogFragment.LJIILLIIL, "translationY", new float[]{(float) LIZIZ2, 0.0f}).start();
            }
        } else {
            keyboardDialogFragment.LIZ(false, true);
        }
        Bundle arguments = keyboardDialogFragment.getArguments();
        if (arguments != null) {
            keyboardDialogFragment.LJJLIIIJ = arguments.getString("enterFrom", "");
            keyboardDialogFragment.LJJLIIIJL = arguments.getBoolean("clickAt");
            int i7 = arguments.getInt("maxLength");
            keyboardDialogFragment.LJJIJL = i7;
            if (i7 > 0) {
                keyboardDialogFragment.LIZLLL.setFilters(new InputFilter[]{new AN6(keyboardDialogFragment.LJJIJL)});
            }
            4Qu r12 = keyboardDialogFragment.LJJLIIIJJI;
            if (!(r12 == null || (animateUrl = r12.getAnimateUrl()) == null)) {
                keyboardDialogFragment.LJIIJJI.setVisibility(0);
                keyboardDialogFragment.LJIILIIL.setVisibility(0);
                M12.LIZ(r12);
                int LIZIZ3 = (int) HeD.LIZIZ(9EH.LJJIFFI.LIZ(), 60.0f);
                if (r12.getWidth() == 0 || r12.getHeight() == 0) {
                    iArr = new int[]{LIZIZ3, LIZIZ3};
                } else {
                    iArr = new int[]{Math.min((r12.getWidth() / r12.getHeight()) * LIZIZ3, (int) HeD.LIZIZ(9EH.LJJIFFI.LIZ(), 107.0f)), LIZIZ3};
                }
                keyboardDialogFragment.LJIIJJI.getLayoutParams().width = iArr[0];
                keyboardDialogFragment.LJIIJJI.requestLayout();
                OCa.LIZ(keyboardDialogFragment.LJIIL, animateUrl, iArr[0], iArr[1]);
            }
            CharSequence charSequence = arguments.getCharSequence("hint");
            if (charSequence != null) {
                keyboardDialogFragment.LIZLLL.setHint(charSequence);
                keyboardDialogFragment.LIZLLL.setMaxLines(1);
                keyboardDialogFragment.LIZLLL.setEllipsize(TextUtils.TruncateAt.END);
            }
            CharSequence charSequence2 = arguments.getCharSequence("defaultContent");
            if (!TextUtils.isEmpty(charSequence2)) {
                keyboardDialogFragment.LIZLLL.setText(charSequence2);
            }
            User serializable = arguments.getSerializable("user");
            if (serializable != null) {
                keyboardDialogFragment.LIZLLL.setHint(9EH.LJJIFFI.LIZ().getString(2131831699, new Object[]{C02279ut.LIZ(serializable, keyboardDialogFragment.LJJL)}));
                AnonymousClass9rL r42 = keyboardDialogFragment.LJJIIJ;
                if (r42 != null) {
                    r42.LIZIZ(keyboardDialogFragment.LIZLLL.getHint());
                }
            }
            keyboardDialogFragment.LIZLLL.addTextChangedListener(keyboardDialogFragment);
            HashSet hashSet = (HashSet) arguments.getSerializable("atUserSet");
            if (hashSet != null) {
                Iterator it = hashSet.iterator();
                while (it.hasNext()) {
                    User user = (User) it.next();
                    keyboardDialogFragment.LIZ(ESC.LIZJ(user), user.getUid(), user.getSecUid());
                }
            }
            User serializable2 = arguments.getSerializable("atUser");
            if (serializable2 != null) {
                keyboardDialogFragment.LIZ(ESC.LIZJ(serializable2), serializable2.getUid(), serializable2.getSecUid());
            }
            if (AnonymousClass9o6.LIZ()) {
                keyboardDialogFragment.LIZ(false, false);
            } else {
                keyboardDialogFragment.LIZ(true, true);
            }
            boolean z3 = arguments.getBoolean("showAt");
            4ZZ r43 = keyboardDialogFragment.LJ;
            if (z3) {
                i3 = 0;
            } else {
                i3 = 8;
            }
            r43.setVisibility(i3);
            keyboardDialogFragment.LJJIJ = z3;
            keyboardDialogFragment.LJJIJIIJI = arguments.getInt("viewType");
            keyboardDialogFragment.LJJL = arguments.getString("arg_event_type");
            keyboardDialogFragment.LJJIJIIJIL = false;
            if (keyboardDialogFragment.LJIILJJIL != null) {
                if (keyboardDialogFragment.LJJJZ == null) {
                    keyboardDialogFragment.LJJJZ = new C1814AiI(keyboardDialogFragment.LIZLLL, keyboardDialogFragment.LJJIJL, keyboardDialogFragment);
                }
                9Il.LIZJ();
                C0799AGt aGt = new C0799AGt(keyboardDialogFragment.LJJJZ, keyboardDialogFragment.LJIILJJIL);
                C2784Axw.LIZIZ.LIZ();
                if (9Il.LJ.LIZIZ(2)) {
                    aGt.LIZ.LJ = true;
                    aGt.LIZ.LJIIIIZZ.add(5);
                } else {
                    aGt.LIZ.LIZ = true;
                    aGt.LIZ.LJIIIIZZ.add(1);
                }
                aGt.LIZ.LJII = 2;
                J0e j0e = new J0e(aGt.LIZIZ, aGt.LIZ, aGt.LIZJ, (byte) 0);
                keyboardDialogFragment.LJJIII = j0e;
                keyboardDialogFragment.LJIILJJIL.addView(j0e.LIZIZ);
            }
            C0801AGv aGv2 = keyboardDialogFragment.LJJJLL;
            if (keyboardDialogFragment.LJJIJLIJ) {
                i4 = 0;
            } else {
                i4 = 8;
            }
            aGv2.LIZ(i4);
            if (keyboardDialogFragment.LJJIJLIJ) {
                keyboardDialogFragment.LIZJ(false);
            }
            if (keyboardDialogFragment.LJJJJ != CommentVideoModel$Type.NONE) {
                keyboardDialogFragment.LIZJ.setVisibility(8);
                keyboardDialogFragment.LIZIZ.setVisibility(0);
                keyboardDialogFragment.LJJZ.LIZ(false, 1);
                if (keyboardDialogFragment.LJFF.getVisibility() != 0) {
                    z2 = false;
                }
                keyboardDialogFragment.LJJIIZI = z2;
                if (z2) {
                    keyboardDialogFragment.LJFF.setVisibility(8);
                }
            } else {
                keyboardDialogFragment.LIZIZ.setVisibility(8);
            }
            keyboardDialogFragment.LJJZZI = arguments.getInt("publishScenario");
            if (keyboardDialogFragment.LJJJLZIJ != null) {
                boolean z4 = arguments.getBoolean("hasUpvoteCheckBox", false);
                keyboardDialogFragment.LJJLIIIIJ = z4;
                keyboardDialogFragment.LJJJLZIJ.LIZ(keyboardDialogFragment.LJIILL, keyboardDialogFragment.LIZLLL, keyboardDialogFragment.LJJIJL, z4, keyboardDialogFragment);
                keyboardDialogFragment.LJJJLZIJ.setMEnterFrom(keyboardDialogFragment.LJJLIIIJ);
                if (keyboardDialogFragment.LJJIL || keyboardDialogFragment.LJJIJLIJ || keyboardDialogFragment.LJJLIIIJL) {
                    keyboardDialogFragment.LJJJLZIJ.LIZIZ(false);
                } else {
                    keyboardDialogFragment.LJJJLZIJ.LIZ(false);
                }
            }
        }
        if (bundle2 != null) {
            try {
                KeyboardDialogFragment.super.dismiss();
                MethodCollector.o(8306);
            } catch (IllegalStateException unused) {
                i2 = 8306;
                KeyboardDialogFragment.super.dismissAllowingStateLoss();
            }
        } else {
            i2 = 8306;
            MethodCollector.o(i2);
        }
    }

    public final /* synthetic */ void LIZ(View view) {
        String str;
        GiftStruct giftStruct = (GiftStruct) this.LJJJJIZL.LIZIZ().getValue();
        if (!VideoGiftService.LJIIJ().LJIIIZ() || giftStruct == null) {
            C00969ps r0 = this.LJJJIL;
            if (r0 != null) {
                r0.LJIILLIIL = "keyboard_enter";
                this.LJJJIL.LJFF("keyboard_dialog");
            }
            LIZJ();
        } else if (giftStruct.isFromGiftBag() || ((Long) this.LJJJJIZL.LIZLLL().getValue()).longValue() == Long.MIN_VALUE || ((long) giftStruct.getDiamondCount()) <= ((Long) this.LJJJJIZL.LIZLLL().getValue()).longValue()) {
            C00969ps r02 = this.LJJJIL;
            if (r02 != null) {
                r02.LJIILLIIL = "keyboard_enter";
                this.LJJJIL.LJFF("keyboard_dialog");
            }
            LIZJ();
        } else {
            4EI r2 = new 4EI(getActivity());
            r2.LIZ(2131834821, new C0800AGu(this, giftStruct));
            r2.LIZIZ(2131822315, new AnonymousClass9q8(this, view));
            4EW r1 = new 4EW(this.LJJJJLI);
            r1.LIZJ(2131834794);
            r1.LIZ(r2);
            4FQ.LIZ(r1.LIZ().LIZJ());
            Aweme aweme = this.LJJIZ;
            if (getArguments() != null) {
                str = getArguments().getString("enterFrom");
            } else {
                str = "";
            }
            2UX r3 = new 2UX();
            r3.LIZ("enter_from", str);
            r3.LIZ("enter_method", this.LJJJIL.LJIILLIIL);
            r3.LIZ("group_id", 4wQ.LJ(aweme));
            r3.LIZ("gift_id", ((GiftStruct) this.LJJJJIZL.LIZIZ().getValue()).getId());
            r3.LIZ("author_id", 4wQ.LIZ(aweme));
            2nK.LIZ("show_comment_recharge_popup", r3.LIZ);
        }
    }

    public final /* synthetic */ 2Pr LIZ(GiftStruct giftStruct, 4EQ r9) {
        String str;
        r9.LIZIZ = true;
        new C0784AGe().LIZ(this.LJJJJLI, (long) giftStruct.getDiamondCount(), this.LJJJJIZL, this.LJJJJLI.getSupportFragmentManager());
        Aweme aweme = this.LJJIZ;
        if (getArguments() != null) {
            str = getArguments().getString("enterFrom");
        } else {
            str = "";
        }
        2UX r3 = new 2UX();
        r3.LIZ("enter_from", str);
        r3.LIZ("enter_method", this.LJJJIL.LJIILLIIL);
        r3.LIZ("group_id", 4wQ.LJ(aweme));
        r3.LIZ("gift_id", ((GiftStruct) this.LJJJJIZL.LIZIZ().getValue()).getId());
        r3.LIZ("author_id", 4wQ.LIZ(aweme));
        2nK.LIZ("click_comment_recharge_popup", r3.LIZ);
        return 2Pr.LIZ;
    }

    /* JADX WARNING: type inference failed for: r0v10, types: [X.AiE, android.widget.EditText] */
    public void onViewCreated(View view, Bundle bundle) {
        String str;
        KeyboardDialogFragment.super.onViewCreated(view, bundle);
        ESN LIZ2 = ESN.LJI.LIZ(this, view);
        AH5 ah5 = new AH5(this);
        AnonymousClass2 r3 = new Dn1() {
            static {
                Covode.recordClassIndex(57364);
            }

            public final void LIZIZ(4Qu r5, int i) {
                KeyboardDialogFragment keyboardDialogFragment = KeyboardDialogFragment.this;
                keyboardDialogFragment.LIZIZ("search", keyboardDialogFragment.LIZIZ(r5), i, r5.getLogPb());
            }

            public final void LIZ(4Qu r5, int i) {
                KeyboardDialogFragment.this.LIZ(r5);
                KeyboardDialogFragment keyboardDialogFragment = KeyboardDialogFragment.this;
                keyboardDialogFragment.LIZ("search", keyboardDialogFragment.LIZIZ(r5), i, r5.getLogPb());
                KeyboardDialogFragment.this.LIZ(true, true);
                KeyboardDialogFragment.this.LJIIJ();
            }
        };
        AH3 ah3 = new AH3(this);
        Aweme aweme = this.LJJIZ;
        if (aweme == null || aweme.getAid() == null) {
            str = "";
        } else {
            str = this.LJJIZ.getAid();
        }
        if (AnonymousClass9o6.LIZ()) {
            this.LJJJ = new SearchGifWidgetV2(ah5, r3, ah3, str);
        } else {
            this.LJJJ = new SearchGifWidget(ah5, r3, ah3, str);
        }
        LIZ2.LIZ(2131366935, this.LJJJ, false);
        C00969ps r1 = this.LJJJIL;
        if (r1 != null) {
            r1.LIZIZ((EditText) this.LIZLLL);
            this.LJJJIL.LIZ(this.LIZLLL, 2131099750);
        }
        if (!C0795AGp.LIZ) {
            C0795AGp.LIZLLL = System.currentTimeMillis();
        }
        if (SettingsManager.LIZ().LIZ("keyboard_show_judge_by_screen_height", true)) {
            this.LJIILLIIL.setKeyBoardObservable(new 3MK());
        }
    }

    public final /* synthetic */ 2Pr LIZ(String[] strArr, String str) {
        LIZ(this.LJJIZ, strArr[0], str, "dismiss_gift_tooltip");
        return null;
    }

    public void onEmojiClick(String str, int i, int i2) {
        AnonymousClass9rL r0 = this.LJJIIJ;
        if (r0 != null) {
            r0.LIZ(str, i, i2);
        }
    }

    public final void LIZIZ(4Qu r4, int i, int i2) {
        LIZIZ(LIZJ(i), LIZIZ(r4), i2, r4.getLogPb());
    }

    public static KeyboardDialogFragment LIZ(int i, boolean z, String str) {
        KeyboardDialogFragment keyboardDialogFragment = new KeyboardDialogFragment();
        Bundle bundle = new Bundle();
        bundle.putInt("viewType", i);
        bundle.putBoolean("hasUpvoteCheckBox", z);
        bundle.putString("enterFrom", str);
        keyboardDialogFragment.setArguments(bundle);
        return keyboardDialogFragment;
    }

    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        View LIZ2;
        MethodCollector.i(9587);
        if (AnonymousClass9o6.LIZ()) {
            LIZ2 = 0HB.LIZ(getActivity(), 2131558785, viewGroup, false);
        } else {
            LIZ2 = 0HH.LIZ(layoutInflater, 2131558785, viewGroup, false);
        }
        this.LIZIZ = LIZ2.findViewById(2131369482);
        this.LIZJ = LIZ2.findViewById(2131363482);
        this.LIZLLL = (C1810AiE) LIZ2.findViewById(2131363496);
        this.LIZ = (ViewGroup) LIZ2.findViewById(2131363494);
        this.LJ = LIZ2.findViewById(2131366290);
        this.LJFF = LIZ2.findViewById(2131366408);
        this.LJII = LIZ2.findViewById(2131366449);
        this.LJI = LIZ2.findViewById(2131363526);
        this.LJIIIIZZ = LIZ2.findViewById(2131366823);
        this.LJIIIZ = LIZ2.findViewById(2131366858);
        this.LJIIJ = LIZ2.findViewById(2131366935);
        this.LJIIJJI = LIZ2.findViewById(2131366848);
        this.LJIIL = LIZ2.findViewById(2131365288);
        this.LJIILIIL = LIZ2.findViewById(2131365289);
        this.LJIILJJIL = (LinearLayout) LIZ2.findViewById(2131368341);
        if (!C00409no.LIZJ()) {
            this.LJIILL = (FrameLayout) LIZ2.findViewById(2131367653);
        } else {
            this.LJIILL = (FrameLayout) LIZ2.findViewById(2131367652);
        }
        this.LJIILL.setVisibility(0);
        this.LJIILLIIL = LIZ2.findViewById(2131368298);
        this.LJIIZILJ = (ImageView) LIZ2.findViewById(2131365290);
        this.LJIJ = LIZ2.findViewById(2131366851);
        this.LJIJI = (ViewGroup) LIZ2.findViewById(2131363489);
        this.LJIJJ = (TextView) LIZ2.findViewById(2131371124);
        this.LJIJJLI = (LinearLayout) LIZ2.findViewById(2131365333);
        this.LJIL = LIZ2.findViewById(2131370062);
        this.LJJ = (ImageView) LIZ2.findViewById(2131369449);
        this.LJJI = LIZ2.findViewById(2131370063);
        this.LJJIFFI = LIZ2.findViewById(2131371676);
        this.LJL = LIZ2.findViewById(2131362589);
        this.LJJII = (FrameLayout) LIZ2.findViewById(2131363513);
        if (AnonymousClass9o6.LIZ()) {
            this.LJIIIIZZ.setVisibility(4);
            this.LJIIIIZZ.postDelayed(new C0802AGw(this), 500);
        }
        Context context = getContext();
        if (context == null) {
            context = 9EH.LJJIFFI.LIZ();
        }
        C2878AzS.LIZ.LIZ(context, (ViewGroup) this.LJJII);
        this.LJJZ = new C02229uo(this.LIZ);
        AHD ahd = new AHD(context);
        this.LJJJLZIJ = ahd;
        this.LJIILL.addView(ahd);
        MethodCollector.o(9587);
        return LIZ2;
    }

    public final void LIZ(4Qu r4, int i, int i2) {
        LJIILL();
        LIZ(r4);
        LIZ(LIZJ(i), LIZIZ(r4), i2, r4.getLogPb());
        LIZ(true, true);
    }

    public static KeyboardDialogFragment LIZ(int i, boolean z, String str, Bundle bundle) {
        KeyboardDialogFragment LIZ2 = LIZ(i, z, str);
        Bundle arguments = LIZ2.getArguments();
        if (arguments != null) {
            arguments.putAll(bundle);
        }
        return LIZ2;
    }

    public final void LIZIZ(String str, String str2, int i, LogPbBean logPbBean) {
        AnonymousClass9qM r1 = this.LJJIIJZLJL;
        if (r1 != null) {
            r1.LIZIZ(str, this.LJJJ.LJIILJJIL(), str2, i, logPbBean);
        }
    }
}
