package com.tencent.mm.plugin.luckymoney.ui;

import android.content.Context;
import android.text.InputFilter;
import android.text.InputFilter.LengthFilter;
import android.text.TextWatcher;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.compatible.util.j;
import com.tencent.mm.pluginsdk.ui.ChatFooterPanel;
import com.tencent.mm.pluginsdk.ui.chat.d;
import com.tencent.mm.pluginsdk.ui.chat.e;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.BasePanelKeybordLayout;
import com.tencent.mm.ui.MMActivity;
import com.tencent.mm.ui.widget.MMEditText;
import com.tencent.mm.ui.widget.MMEditText.a;
import com.tencent.ytcommon.BuildConfig;
import java.util.ArrayList;
import java.util.List;

public class LuckyMoneyWishFooter extends BasePanelKeybordLayout {
    private MMActivity crP;
    private ChatFooterPanel eAk;
    private ImageButton jZh;
    private MMEditText oij;
    private Button oik;
    boolean oil = false;
    public boolean oim = false;
    private boolean oin = true;
    boolean oio = true;
    private TextWatcher oip = new 3(this);
    private a oiq;
    private c oir;
    private int state = 0;

    static /* synthetic */ void f(LuckyMoneyWishFooter luckyMoneyWishFooter) {
        AppMethodBeat.i(43069);
        luckyMoneyWishFooter.bMN();
        AppMethodBeat.o(43069);
    }

    public void setModeClick(boolean z) {
        this.oil = z;
    }

    public LuckyMoneyWishFooter(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        AppMethodBeat.i(43055);
        this.crP = (MMActivity) context;
        ViewGroup viewGroup = (ViewGroup) inflate(this.crP, 2130970000, this);
        this.oik = (Button) viewGroup.findViewById(2131825672);
        iP(false);
        this.jZh = (ImageButton) viewGroup.findViewById(2131825671);
        this.jZh.setOnClickListener(new 4(this));
        this.oij = (MMEditText) viewGroup.findViewById(2131825670);
        this.oij.setOnTouchListener(new 5(this));
        if (e.vom == null) {
            this.eAk = new d(this.crP);
            AppMethodBeat.o(43055);
            return;
        }
        this.eAk = e.vom.dF(getContext());
        this.eAk.setEntranceScene(ChatFooterPanel.vhh);
        this.eAk.setVisibility(8);
        this.eAk.setBackgroundResource(2130837979);
        ((LinearLayout) findViewById(2131820987)).addView(this.eAk, -1, 0);
        this.eAk.AD();
        this.eAk.bf(false);
        this.eAk.setOnTextOperationListener(new 6(this));
        AppMethodBeat.o(43055);
    }

    public void setVisibility(int i) {
        boolean z;
        AppMethodBeat.i(43056);
        this.state = 0;
        if (i == 0) {
            z = true;
        } else {
            z = false;
        }
        if (this.eAk != null) {
            ab.i("MicroMsg.SnsCommentFooter", "showState ".concat(String.valueOf(z)));
            if (z) {
                bMN();
                this.oin = false;
            } else {
                ab.d("MicroMsg.SnsCommentFooter", bo.dpG());
                this.eAk.setVisibility(8);
                this.jZh.setImageResource(2131231459);
                this.crP.aqX();
                setModeClick(true);
                requestLayout();
            }
        }
        super.setVisibility(i);
        AppMethodBeat.o(43056);
    }

    private void bMN() {
        AppMethodBeat.i(43057);
        if (this.state == 0) {
            this.oij.requestFocus();
            this.crP.getWindow().setSoftInputMode(16);
            this.crP.showVKB();
            this.eAk.postDelayed(new 1(this), 200);
            AppMethodBeat.o(43057);
            return;
        }
        this.oij.requestFocus();
        this.crP.getWindow().setSoftInputMode(32);
        this.crP.aqX();
        aRd();
        AppMethodBeat.o(43057);
    }

    private void aRd() {
        AppMethodBeat.i(43058);
        this.eAk.onResume();
        this.eAk.postDelayed(new 2(this), 200);
        LayoutParams layoutParams = this.eAk.getLayoutParams();
        if ((layoutParams != null && layoutParams.height <= 0) || (layoutParams != null && j.gu(getContext()) && this.oin)) {
            layoutParams.height = j.gs(getContext());
            this.eAk.setLayoutParams(layoutParams);
            this.oin = false;
        }
        AppMethodBeat.o(43058);
    }

    public void setMaxLength(int i) {
        AppMethodBeat.i(43059);
        this.oij.setFilters(new InputFilter[]{new LengthFilter(i)});
        AppMethodBeat.o(43059);
    }

    public final boolean a(a aVar) {
        AppMethodBeat.i(43060);
        if (this.oij != null) {
            this.oij.setBackListener(aVar);
            AppMethodBeat.o(43060);
            return true;
        }
        AppMethodBeat.o(43060);
        return false;
    }

    public void setText(String str) {
        AppMethodBeat.i(43061);
        if (this.oij != null) {
            this.oij.setText(BuildConfig.FLAVOR);
            this.oij.asB(str);
        }
        AppMethodBeat.o(43061);
    }

    public void setHint(String str) {
        AppMethodBeat.i(43062);
        this.oij.setHint(str);
        AppMethodBeat.o(43062);
    }

    public void setOnEditTouchListener(a aVar) {
        this.oiq = aVar;
    }

    public void setOnSmileyShowListener(c cVar) {
        this.oir = cVar;
    }

    public void setOnWishSendImp(b bVar) {
        AppMethodBeat.i(43063);
        this.oik.setOnClickListener(new 7(this, bVar));
        AppMethodBeat.o(43063);
    }

    public final void sD(int i) {
        AppMethodBeat.i(43064);
        super.sD(i);
        switch (i) {
            case -3:
                this.oim = true;
                AppMethodBeat.o(43064);
                return;
            default:
                this.oim = false;
                AppMethodBeat.o(43064);
                return;
        }
    }

    public final void bMO() {
        AppMethodBeat.i(43065);
        if (this.eAk != null) {
            ab.i("MicroMsg.SnsCommentFooter", "commentfooter release");
            this.eAk.AC();
            this.eAk.destroy();
        }
        AppMethodBeat.o(43065);
    }

    private void iP(boolean z) {
        AppMethodBeat.i(43066);
        Animation loadAnimation = AnimationUtils.loadAnimation(getContext(), 2131034216);
        Animation loadAnimation2 = AnimationUtils.loadAnimation(getContext(), 2131034221);
        loadAnimation.setDuration(150);
        loadAnimation2.setDuration(150);
        if (this.oik == null) {
            AppMethodBeat.o(43066);
        } else if (z) {
            if (this.oik.getVisibility() == 8 || this.oik.getVisibility() == 4) {
                AppMethodBeat.o(43066);
                return;
            }
            this.oik.startAnimation(loadAnimation2);
            this.oik.setVisibility(8);
            AppMethodBeat.o(43066);
        } else if (this.oik.getVisibility() == 0 || this.oik.getVisibility() == 0) {
            AppMethodBeat.o(43066);
        } else {
            this.oik.startAnimation(loadAnimation);
            this.oik.setVisibility(0);
            AppMethodBeat.o(43066);
        }
    }

    public List<View> getPanelView() {
        AppMethodBeat.i(43067);
        ArrayList arrayList = new ArrayList();
        arrayList.add(this.eAk);
        AppMethodBeat.o(43067);
        return arrayList;
    }
}
