diff --git a/app/src/main/java/com/icssoft/icspda/activity/INVOutActivity.java b/app/src/main/java/com/icssoft/icspda/activity/INVOutActivity.java index f254feb..fe5ba34 100644 --- a/app/src/main/java/com/icssoft/icspda/activity/INVOutActivity.java +++ b/app/src/main/java/com/icssoft/icspda/activity/INVOutActivity.java @@ -12,7 +12,9 @@ import android.os.SystemClock; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; +import android.view.KeyEvent; import android.view.View; +import android.view.inputmethod.EditorInfo; import android.widget.Button; import android.widget.EditText; import android.widget.RadioButton; @@ -35,6 +37,7 @@ import com.icssoft.icspda.util.HelpUtil; import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; @@ -104,7 +107,7 @@ public class INVOutActivity extends AppCompatActivity { break; case 5: barCode.requestFocus(); - HelpUtil.SetMsg(tvMsg, Color.BLUE, "退货数量记录成功!"); + HelpUtil.SetMsg(tvMsg, Color.BLUE, "数量记录成功!"); break; case 11: outQty.setText(ErrorMsg); @@ -149,53 +152,57 @@ public class INVOutActivity extends AppCompatActivity { dataList = new ArrayList<>(); dataDetailList = new ArrayList<>(); - transNo.addTextChangedListener(new TextWatcher() { + transNo.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - - } - - @Override - public void afterTextChanged(Editable s) { - if (s.toString().length() > 0) { - new Thread(new Runnable() { - @Override - public void run() { - CheckVouchCode(); + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + try { + if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE + || (event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode() && KeyEvent.ACTION_DOWN == event.getAction())) { + if (v.getText().length() > 0) { + new Thread(new Runnable() { + @Override + public void run() { + CheckVouchCode(); + } + }).start(); } - }).start(); + } + return false; + } catch (Exception ex) { + ErrorMsg = ex.getMessage(); + handler.sendEmptyMessage(99); } + + return false; } }); - barCode.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) { + barCode.setOnEditorActionListener(new TextView.OnEditorActionListener() { + @Override + public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { + try { + if (actionId == EditorInfo.IME_ACTION_SEND || actionId == EditorInfo.IME_ACTION_DONE + || (event != null && KeyEvent.KEYCODE_ENTER == event.getKeyCode() && KeyEvent.ACTION_DOWN == event.getAction())) { + if (v.getText().length() > 0) { + new Thread(new Runnable() { + @Override + public void run() { + CheckLotNoForReturn(); + } + }).start(); + } + } + return false; + } catch (Exception ex) { + ErrorMsg = ex.getMessage(); + handler.sendEmptyMessage(99); + } - } + return false; + } + }); - @Override - public void afterTextChanged(Editable s) { - if (s.toString().length() > 0) { - new Thread(new Runnable() { - @Override - public void run() { - CheckLotNoForReturn(); - } - }).start(); - } - } - }); barCode.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override @@ -242,6 +249,8 @@ public class INVOutActivity extends AppCompatActivity { DetailSum(); } } + tableData = new TableData<>("材料出库信息", dataList, columns); + smartTable.setTableData(tableData); handler.sendEmptyMessage(5); } }); @@ -250,22 +259,24 @@ public class INVOutActivity extends AppCompatActivity { @Override public void onClick(View v) { try { - if (tableData != null && selectRowIndex != 999 && !TextUtils.isEmpty(selectRowInvCode) - && !TextUtils.isEmpty(selectRowVouchNo)) { - dataList.remove(selectRowIndex); - for (InvOutDetailData invOutDetailData : dataDetailList) { - if (invOutDetailData.getINVCODE().equals(selectRowInvCode) - && invOutDetailData.getVouchRow().endsWith(selectRowVouchNo)) - dataDetailList.remove(invOutDetailData); - } - tableData = new TableData<>("材料出库信息", dataList, columns); - smartTable.setTableData(tableData); - HelpUtil.SetMsg(tvMsg, Color.BLUE, "物料编码:" + selectRowInvCode + ",移除成功!"); - selectRowInvCode = ""; - selectRowIndex = 999; - } else { - HelpUtil.SetMsg(tvMsg, Color.RED, "尚未扫入任何条码!"); - } + clear(); + HelpUtil.SetMsg(tvMsg, Color.RED, "内容已清空"); +// if (tableData != null && selectRowIndex != 999 && !TextUtils.isEmpty(selectRowInvCode) +// && !TextUtils.isEmpty(selectRowVouchNo)) { +// dataList.remove(selectRowIndex); +// for (InvOutDetailData invOutDetailData : dataDetailList) { +// if (invOutDetailData.getINVCODE().equals(selectRowInvCode) +// && invOutDetailData.getVouchRow().endsWith(selectRowVouchNo)) +// dataDetailList.remove(invOutDetailData); +// } +// tableData = new TableData<>("材料出库信息", dataList, columns); +// smartTable.setTableData(tableData); +// HelpUtil.SetMsg(tvMsg, Color.BLUE, "物料编码:" + selectRowInvCode + ",移除成功!"); +// selectRowInvCode = ""; +// selectRowIndex = 999; +// } else { +// HelpUtil.SetMsg(tvMsg, Color.RED, "尚未扫入任何条码!"); +// } } catch (Exception ex) { HelpUtil.SetMsg(tvMsg, Color.RED, ex.getMessage()); }