package com.xxrv.wallet.activity;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseStatusActivity;
import com.ruiwenliu.wrapper.presenter.MvpPresenter;
import com.ruiwenliu.wrapper.weight.TitleView;
import com.rv.home.rv.module.basic.presenter.CommonPresenter;
import com.xxrv.wallet.R;
import com.xxrv.wallet.R2;
import com.xxrv.wallet.dialog.PayPassDialog;
import com.xxrv.wallet.dialog.SetPasswordDialog;
import com.xxrv.wallet.view.PayPassView;

import butterknife.BindView;

public class SetPayPwdActivity extends BaseStatusActivity<CommonPresenter> {

    @BindView(R2.id.ll_send_code)
    LinearLayout llSendCode;
    @BindView(R2.id.ll_set_pay_pwd)
    LinearLayout llSetPayPwd;
    @BindView(R2.id.edt_phone)
    EditText edtPhone;
    @BindView(R2.id.edt_identify_code)
    EditText edtIdentifyCode;
    @BindView(R2.id.btn_send)
    Button btnSend;
    @BindView(R2.id.btn_next)
    Button btnNext;
    @BindView(R2.id.img_clear_phone)
    ImageView imgClearPhone;
    @BindView(R2.id.edt_pwd1)
    EditText edtPwd1;
    @BindView(R2.id.edt_pwd2)
    EditText edtPwd2;
    @BindView(R2.id.edt_pwd3)
    EditText edtPwd3;
    @BindView(R2.id.edt_pwd4)
    EditText edtPwd4;
    @BindView(R2.id.edt_pwd5)
    EditText edtPwd5;
    @BindView(R2.id.edt_pwd6)
    EditText edtPwd6;
    @BindView(R2.id.btn_confirm)
    Button btnConfirm;

    @Override
    public void onShowResult(int requestType, BaseBean result) {

    }

    @Override
    protected int setLayout() {
        return R.layout.activity_set_pay_pwd;
    }

    @Override
    protected void initView(Bundle savedInstanceState, TitleView titleView, Intent intent) {
        titleView.setTitle("设置支付密码");
        payDialog();
        edtPwd1.addTextChangedListener(watcher);
        edtPwd2.addTextChangedListener(watcher);
        edtPwd3.addTextChangedListener(watcher);
        edtPwd4.addTextChangedListener(watcher);
        edtPwd5.addTextChangedListener(watcher);
        edtPwd6.addTextChangedListener(watcher);

    }

    private TextWatcher watcher = new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            Log.e("xxxxx", charSequence.toString());
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            Log.e("xxxxx", charSequence.toString());
        }

        @Override
        public void afterTextChanged(Editable editable) {

        }
    };

    /**
     * 支付密码
     */
    private void payDialog() {
        final SetPasswordDialog dialog = new SetPasswordDialog(this);
        dialog.setOutColse(false);
        dialog.getPayViewPass().setPayClickListener(new PayPassView.OnPayClickListener() {
            @Override
            public void onPassFinish(String passContent) {
                //输入完成
                showToast(passContent);
                startActivity(CashWithdrawalDetailsActivity.getIntent(mActivity));
                dialog.dismiss();
            }

            @Override
            public void onPayClose() {
                dialog.dismiss();
            }

            @Override
            public void onPayForget() {
                //忘记密码
                dialog.dismiss();
            }
        });
    }
}
