etMinAmout.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
inputIndex = MIN_AMOUT_INPUT;
mHandler.removeCallbacks(mRunnable);
//800毫秒没有输入认为输入完毕
mHandler.postDelayed(mRunnable, 1000);
minAmoutInput = s.toString();
}
@Override
public void afterTextChanged(Editable s) {
}
});
etMaxAmout.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
inputIndex = MAX_AMOUT_INPUT;
mHandler.removeCallbacks(mRunnable);
//800毫秒没有输入认为输入完毕
mHandler.postDelayed(mRunnable, 1000);
maxAmoutInput = s.toString();
}
@Override
public void afterTextChanged(Editable s) {
}
});
//输入完成标志
private static final int MIN_AMOUT_EDIT_OK = 1000;
private static final int MAX_AMOUT_EDIT_OK = 1001;
//输入标志
private static final int MIN_AMOUT_INPUT = 1;
private static final int MAX_AMOUT_INPUT = 2;
private Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
if (MIN_AMOUT_EDIT_OK == msg.what) {
String minAmout = minAmoutInput;
MbsLogManager.logD("tMinAmout=====afterTextChanged========" + minAmout);
if (NotNull.isNotNull(minAmout)){
String maxAmout = etMaxAmout.getText().toString();
if (NotNull.isNotNull(getAvailableMinAmout()) && Double.parseDouble(minAmout) < Double.parseDouble(getAvailableMinAmout())){
}else if (NotNull.isNotNull(maxAmout) && (Double.parseDouble(minAmout) > Double.parseDouble(maxAmout))){
}
}
}else if (MAX_AMOUT_EDIT_OK == msg.what){
String maxAmout = maxAmoutInput;
if (NotNull.isNotNull(maxAmout)){
String minAmout = etMinAmout.getText().toString().trim();
if (NotNull.isNotNull(getAvailableMaxAmout()) && Double.parseDouble(maxAmout) > Double.parseDouble( getAvailableMaxAmout())){
}else if (NotNull.isNotNull(minAmout) && (Double.parseDouble(minAmout) > Double.parseDouble(maxAmout))){
}
}
}
}
};
private Runnable mRunnable = new Runnable() {
@Override
public void run() {
switch (inputIndex){
case MIN_AMOUT_INPUT:
mHandler.sendEmptyMessage(MIN_AMOUT_EDIT_OK);
break;
case MAX_AMOUT_INPUT:
mHandler.sendEmptyMessage(MAX_AMOUT_EDIT_OK);
break;
}
}
};
@Override
protected void onDestroy() {
super.onDestroy();
if (mHandler != null){
mHandler.removeCallbacksAndMessages(null);
mHandler = null;
}
}
}