265 lines
7.3 KiB
Java
265 lines
7.3 KiB
Java
package cn.shangyu.gdxzExpert.activity;
|
|
|
|
import android.content.DialogInterface;
|
|
import android.content.Intent;
|
|
import android.text.Editable;
|
|
import android.text.TextWatcher;
|
|
import android.view.View;
|
|
import android.widget.Button;
|
|
import android.widget.EditText;
|
|
|
|
import com.gyf.immersionbar.ImmersionBar;
|
|
|
|
import cn.shangyu.gdxzExpert.R;
|
|
import cn.shangyu.gdxzExpert.application.BaseApplication;
|
|
import cn.shangyu.gdxzExpert.base.BaseActivity;
|
|
import cn.shangyu.gdxzExpert.http.OnCallBackFromNet;
|
|
import cn.shangyu.gdxzExpert.utils.CommonUtil;
|
|
import cn.shangyu.gdxzExpert.utils.StringUtil;
|
|
import cn.shangyu.gdxzExpert.utils.UIUtils;
|
|
import cn.shangyu.gdxzExpert.utils.ValidateUtils;
|
|
import cn.shangyu.gdxzExpert.widget.CustomClearEditText;
|
|
import cn.shangyu.gdxzExpert.widget.ECAlertDialog;
|
|
import cn.shangyu.gdxzExpert.widget.LoadingPage.ResultState;
|
|
|
|
public class AddBankCardFirstActivity extends BaseActivity implements
|
|
OnCallBackFromNet {
|
|
private View view;
|
|
private CustomClearEditText mEt_name, mEt_card;
|
|
private Button mBt_next;
|
|
private AddBankCardFirstActivity mActivity;
|
|
private String name, card;
|
|
private double ableBlance, mFwMoney,mOneDraw;
|
|
|
|
@Override
|
|
public void setTitle() {
|
|
// TODO Auto-generated method stub
|
|
top_title.setText("身份验证");
|
|
ableBlance = getIntent().getDoubleExtra("ableBlance", 0);
|
|
mFwMoney = getIntent().getDoubleExtra("mFwMoney", 0);
|
|
mOneDraw = getIntent().getDoubleExtra("mOneDraw", 0);
|
|
if(CommonUtil.BigModule())
|
|
{
|
|
top_title.setTextSize(23);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public View onCreateSuccessedView() {
|
|
// TODO Auto-generated method stub
|
|
ImmersionBar.with(this).keyboardEnable(true).statusBarDarkFont(true).titleBar(mToolbar).init();
|
|
if(CommonUtil.BigModule())
|
|
{
|
|
view = UIUtils.inflate(R.layout.activity_add_card_big);
|
|
}
|
|
else
|
|
{
|
|
view = UIUtils.inflate(R.layout.activity_add_card);
|
|
}
|
|
mEt_name = (CustomClearEditText) view
|
|
.findViewById(R.id.et_addcard_name);
|
|
mActivity = this;
|
|
mEt_card = (CustomClearEditText) view
|
|
.findViewById(R.id.et_addcard_card);
|
|
mBt_next = (Button) view.findViewById(R.id.bt_add_card_first);
|
|
|
|
initListener();
|
|
return view;
|
|
}
|
|
|
|
public void initListener() {
|
|
mBt_next.setOnClickListener(this);
|
|
mEt_name.addTextChangedListener(new LimitInputTextWatcher(mEt_name));
|
|
mEt_card.addTextChangedListener(new TextWatcher() {
|
|
|
|
@Override
|
|
public void onTextChanged(CharSequence s, int start, int before,
|
|
int count) {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
@Override
|
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
|
int after) {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
@Override
|
|
public void afterTextChanged(Editable s) {
|
|
// TODO Auto-generated method stub
|
|
if (!StringUtil.isEmpty(mEt_card.getText().toString())
|
|
&& !StringUtil.isEmpty(mEt_name.getText().toString())) {
|
|
mBt_next.setClickable(true);
|
|
mBt_next.setBackgroundResource(R.drawable.selector_btn);
|
|
} else {
|
|
mBt_next.setClickable(false);
|
|
mBt_next.setBackgroundResource(R.drawable.bg_next_btnbar);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
// public void getPayResult(String name, String number) {
|
|
// String uuid = SharePrefUtil.getString(ct, Constant.USERID, "");
|
|
// Map<String, String> param = new HashMap<String, String>();
|
|
// param.put("user_uuid", uuid);
|
|
// param.put("id_name", name);
|
|
// param.put("id_number", number);
|
|
// sendParamtoNet(Url.getIdentificationIdCard, param, 101, mActivity, true);
|
|
// }
|
|
|
|
@Override
|
|
public ResultState onLoad() {
|
|
// TODO Auto-generated method stub
|
|
return ResultState.STATE_SUCCESSED;
|
|
}
|
|
|
|
@Override
|
|
protected void processClick(View v) {
|
|
// TODO Auto-generated method stub
|
|
// AGP 8.0+ R.id 不再是 final 常量,不能用于 switch,改用 if-else
|
|
int id = v.getId();
|
|
if (id == R.id.bt_add_card_first) {
|
|
name = mEt_name.getText().toString();
|
|
if (name.length() < 2 || name.length() > 15) {
|
|
aaa("请输入正确的姓名");
|
|
return;
|
|
}
|
|
card = mEt_card.getText().toString().trim();
|
|
if (!ValidateUtils.isCardId(card)) {
|
|
aaa("请输入正确的身份证号");
|
|
return;
|
|
}
|
|
BaseApplication.addActivity(mActivity);
|
|
Intent intent = new Intent(mActivity,
|
|
AddBankCardSecondActivity.class);
|
|
intent.putExtra("name", name);
|
|
intent.putExtra("card", card);
|
|
intent.putExtra("ableBlance", ableBlance);
|
|
intent.putExtra("mFwMoney", mFwMoney);
|
|
intent.putExtra("mOneDraw", mOneDraw);
|
|
startActivity(intent);
|
|
}
|
|
}
|
|
|
|
private ECAlertDialog buildAlert;
|
|
|
|
public void aaa(String message) {
|
|
buildAlert = ECAlertDialog.buildAlert(mActivity, message, null, "确定",
|
|
new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
// TODO Auto-generated method stub
|
|
buildAlert.dismiss();
|
|
}
|
|
}, new DialogInterface.OnClickListener() {
|
|
@Override
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
buildAlert.dismiss();
|
|
|
|
}
|
|
});
|
|
buildAlert.setTitle("温馨提示");
|
|
buildAlert.setTitleColor(mActivity.getResources().getColor(
|
|
R.color.top_title));
|
|
buildAlert.show();
|
|
}
|
|
|
|
@Override
|
|
public void onCallbackFromThread(String resultJson) {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onCallBackFromThread(String resultJson, int resultCode) {
|
|
// TODO Auto-generated method stub
|
|
|
|
}
|
|
|
|
/**
|
|
* Created by junweiliu on 17/1/6.
|
|
*/
|
|
public class LimitInputTextWatcher implements TextWatcher {
|
|
/**
|
|
* et
|
|
*/
|
|
private EditText et = null;
|
|
/**
|
|
* 筛选条件
|
|
*/
|
|
private String regex;
|
|
/**
|
|
* 默认的筛选条件(正则:只能输入中文)
|
|
*/
|
|
private String DEFAULT_REGEX = "[^\u4E00-\u9FA5]";
|
|
|
|
/**
|
|
* 构造方法
|
|
*
|
|
* @param et
|
|
*/
|
|
public LimitInputTextWatcher(EditText et) {
|
|
this.et = et;
|
|
this.regex = DEFAULT_REGEX;
|
|
}
|
|
|
|
/**
|
|
* 构造方法
|
|
*
|
|
* @param et
|
|
* et
|
|
* @param regex
|
|
* 筛选条件
|
|
*/
|
|
public LimitInputTextWatcher(EditText et, String regex) {
|
|
this.et = et;
|
|
this.regex = regex;
|
|
}
|
|
|
|
@Override
|
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1,
|
|
int i2) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onTextChanged(CharSequence charSequence, int i, int i1,
|
|
int i2) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void afterTextChanged(Editable editable) {
|
|
String str = editable.toString();
|
|
String inputStr = clearLimitStr(regex, str);
|
|
et.removeTextChangedListener(this);
|
|
// et.setText方法可能会引起键盘变化,所以用editable.replace来显示内容
|
|
editable.replace(0, editable.length(), inputStr.trim());
|
|
et.addTextChangedListener(this);
|
|
if (!StringUtil.isEmpty(mEt_card.getText().toString())
|
|
&& !StringUtil.isEmpty(mEt_name.getText().toString())) {
|
|
mBt_next.setClickable(true);
|
|
mBt_next.setBackgroundResource(R.drawable.selector_btn);
|
|
} else {
|
|
mBt_next.setClickable(false);
|
|
mBt_next.setBackgroundResource(R.drawable.bg_next_btnbar);
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 清除不符合条件的内容
|
|
*
|
|
* @param regex
|
|
* @return
|
|
*/
|
|
private String clearLimitStr(String regex, String str) {
|
|
return str.replaceAll(regex, "");
|
|
}
|
|
}
|
|
|
|
}
|