|
|
@@ -1,4 +1,5 @@
|
|
|
package com.jiaju.activity;
|
|
|
+
|
|
|
import org.json.JSONException;
|
|
|
import org.json.JSONObject;
|
|
|
import com.jiaju.net.WebClient;
|
|
|
@@ -33,46 +34,48 @@ import android.widget.LinearLayout;
|
|
|
import android.widget.PopupWindow;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
+
|
|
|
public class ChangeBarcodeActivity extends Activity {
|
|
|
-private Button search;
|
|
|
-private TextView title;
|
|
|
-private EditText barcodeEdt;
|
|
|
-private String barcode=null;
|
|
|
-private ImageView productRecord;
|
|
|
-private LinearLayout parent;
|
|
|
-private PopupWindow mPopupWindow; // 弹出框
|
|
|
-private EditText memoEdt;
|
|
|
-private Button saveBtn;
|
|
|
-private EditText newBarCodeEdt;
|
|
|
-private String newBarCode;
|
|
|
-private String originalBarCode;
|
|
|
-private String memo;
|
|
|
-private HandlerThread thread;
|
|
|
-private Handler mHandler;
|
|
|
-private String accountCode;
|
|
|
-private String changeBarcode_userCode;
|
|
|
-private String password;
|
|
|
-private String sessionkey;
|
|
|
-private SharedPreferences preferences;
|
|
|
-private String ServerAddress_ip;
|
|
|
-private String ServerAddress_duankou;
|
|
|
-private ImageButton backbtn;
|
|
|
-private TextView backtext;
|
|
|
-private EditText worknoEdt;
|
|
|
-private String groutingWorkNo;
|
|
|
-private EditText goodsCodeEdt;
|
|
|
-private String goodsCode;
|
|
|
-private String user;
|
|
|
-private Handler h=new Handler();
|
|
|
-private String code;
|
|
|
-private Handler h1=new Handler();
|
|
|
+ private Button search;
|
|
|
+ private TextView title;
|
|
|
+ private EditText barcodeEdt;
|
|
|
+ private String barcode = null;
|
|
|
+ private ImageView productRecord;
|
|
|
+ private LinearLayout parent;
|
|
|
+ private PopupWindow mPopupWindow; // 弹出框
|
|
|
+ private EditText memoEdt;
|
|
|
+ private Button saveBtn;
|
|
|
+ private EditText newBarCodeEdt;
|
|
|
+ private String newBarCode;
|
|
|
+ private String originalBarCode;
|
|
|
+ private String memo;
|
|
|
+ private HandlerThread thread;
|
|
|
+ private Handler mHandler;
|
|
|
+ private String accountCode;
|
|
|
+ private String changeBarcode_userCode;
|
|
|
+ private String password;
|
|
|
+ private String sessionkey;
|
|
|
+ private SharedPreferences preferences;
|
|
|
+ private String ServerAddress_ip;
|
|
|
+ private String ServerAddress_duankou;
|
|
|
+ private ImageButton backbtn;
|
|
|
+ private TextView backtext;
|
|
|
+ private EditText worknoEdt;
|
|
|
+ private String groutingWorkNo;
|
|
|
+ private EditText goodsCodeEdt;
|
|
|
+ private String goodsCode;
|
|
|
+ private String user;
|
|
|
+ private Handler h = new Handler();
|
|
|
+ private String code;
|
|
|
+ private Handler h1 = new Handler();
|
|
|
//private long saveStart;
|
|
|
//private long saveEnd;
|
|
|
-private Object obj=new Object();
|
|
|
-private Handler newBarcodeUpperH = new Handler();
|
|
|
-private String newBarcodeUpper;
|
|
|
-private Handler originalBarcodeUpperH = new Handler();
|
|
|
-private String originalBarcodeUpper;
|
|
|
+ private Object obj = new Object();
|
|
|
+ private Handler newBarcodeUpperH = new Handler();
|
|
|
+ private String newBarcodeUpper;
|
|
|
+ private Handler originalBarcodeUpperH = new Handler();
|
|
|
+ private String originalBarcodeUpper;
|
|
|
+
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
|
@@ -80,160 +83,151 @@ private String originalBarcodeUpper;
|
|
|
initView();
|
|
|
preferences = getSharedPreferences("user", Context.MODE_PRIVATE);
|
|
|
ServerAddress_ip = preferences.getString("ServerAddress_ip", "");
|
|
|
- ServerAddress_duankou = preferences.getString("ServerAddress_duankou","");
|
|
|
+ ServerAddress_duankou = preferences.getString("ServerAddress_duankou", "");
|
|
|
accountCode = preferences.getString("AccountCode", "");
|
|
|
changeBarcode_userCode = preferences.getString("UserCode", "");
|
|
|
password = preferences.getString("UserPassword", "");
|
|
|
sessionkey = preferences.getString("SessionKey", "");
|
|
|
title.setText("条码变更");
|
|
|
- CommonUtil.BarcodeMaxLength(barcodeEdt,50);
|
|
|
- CommonUtil.BarcodeMaxLength(newBarCodeEdt,50);
|
|
|
+ CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
|
|
|
+ CommonUtil.BarcodeMaxLength(newBarCodeEdt, 50);
|
|
|
allListener();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void initView() {
|
|
|
- search=(Button) findViewById(R.id.barcodeSearch);
|
|
|
+ search = (Button) findViewById(R.id.barcodeSearch);
|
|
|
title = (TextView) findViewById(R.id.title);
|
|
|
- barcodeEdt=(EditText) findViewById(R.id.barcodetxt);
|
|
|
+ barcodeEdt = (EditText) findViewById(R.id.barcodetxt);
|
|
|
barcodeEdt.setRawInputType(InputType.TYPE_CLASS_NUMBER);
|
|
|
- productRecord=(ImageView) findViewById(R.id.search);
|
|
|
+ productRecord = (ImageView) findViewById(R.id.search);
|
|
|
productRecord.setVisibility(View.VISIBLE);
|
|
|
- parent=(LinearLayout) findViewById(R.id.parentRel);
|
|
|
- memoEdt=(EditText) findViewById(R.id.memotxt);
|
|
|
- saveBtn=(Button) findViewById(R.id.saveBtn);
|
|
|
- newBarCodeEdt=(EditText) findViewById(R.id.newbarcodetxt);
|
|
|
+ parent = (LinearLayout) findViewById(R.id.parentRel);
|
|
|
+ memoEdt = (EditText) findViewById(R.id.memotxt);
|
|
|
+ saveBtn = (Button) findViewById(R.id.saveBtn);
|
|
|
+ newBarCodeEdt = (EditText) findViewById(R.id.newbarcodetxt);
|
|
|
newBarCodeEdt.setRawInputType(InputType.TYPE_CLASS_NUMBER);
|
|
|
backbtn = (ImageButton) findViewById(R.id.left_img);
|
|
|
- backtext=(TextView) findViewById(R.id.back);
|
|
|
- worknoEdt=(EditText) findViewById(R.id.groutingworknotxt);
|
|
|
- goodsCodeEdt=(EditText) findViewById(R.id.goodscodeEdt);
|
|
|
+ backtext = (TextView) findViewById(R.id.back);
|
|
|
+ worknoEdt = (EditText) findViewById(R.id.groutingworknotxt);
|
|
|
+ goodsCodeEdt = (EditText) findViewById(R.id.goodscodeEdt);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void allListener() {
|
|
|
- worknoEdt.addTextChangedListener(new TextWatcher() {
|
|
|
-
|
|
|
- public void onTextChanged(CharSequence text, int start, int before,
|
|
|
- int count) {
|
|
|
- user = worknoEdt.getText().toString();
|
|
|
- // 判断输入的文字是否是小写
|
|
|
- for (int i = 0; i < user.length(); i++) {
|
|
|
- if (user.charAt(i) - 0 >= 97 && user.charAt(i) - 0 <= 122) {
|
|
|
- h.postDelayed(UpperCase, 300);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void beforeTextChanged(CharSequence text, int start,
|
|
|
- int count, int after) {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void afterTextChanged(Editable edit) {
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
+ worknoEdt.addTextChangedListener(new TextWatcher() {
|
|
|
+
|
|
|
+ public void onTextChanged(CharSequence text, int start, int before, int count) {
|
|
|
+ user = worknoEdt.getText().toString();
|
|
|
+ // 判断输入的文字是否是小写
|
|
|
+ for (int i = 0; i < user.length(); i++) {
|
|
|
+ if (user.charAt(i) - 0 >= 97 && user.charAt(i) - 0 <= 122) {
|
|
|
+ h.postDelayed(UpperCase, 300);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void beforeTextChanged(CharSequence text, int start, int count, int after) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void afterTextChanged(Editable edit) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
barcodeEdt.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
|
@Override
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
- if(barcodeEdt.getText().toString().contains("\n")){
|
|
|
+ if (barcodeEdt.getText().toString().contains("\n")) {
|
|
|
newBarCodeEdt.setFocusable(true);
|
|
|
newBarCodeEdt.requestFocus();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void beforeTextChanged(CharSequence s, int start, int count,
|
|
|
- int after) {
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
// TODO Auto-generated method stub
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onTextChanged(CharSequence s, int start, int before,
|
|
|
- int count) {
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
originalBarcodeUpper = barcodeEdt.getText().toString();
|
|
|
// 判断输入的文字是否是小写
|
|
|
for (int i = 0; i < originalBarcodeUpper.length(); i++) {
|
|
|
- if (originalBarcodeUpper.charAt(i) - 0 >= 97
|
|
|
- && originalBarcodeUpper.charAt(i) - 0 <= 122) {
|
|
|
+ if (originalBarcodeUpper.charAt(i) - 0 >= 97 && originalBarcodeUpper.charAt(i) - 0 <= 122) {
|
|
|
originalBarcodeUpperH.postDelayed(OriginalBarcodeUpperCase, 300);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- }});
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
newBarCodeEdt.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
|
@Override
|
|
|
public void afterTextChanged(Editable s) {
|
|
|
- if(newBarCodeEdt.getText().toString().contains("\n")){
|
|
|
- //newBarCode = newBarCodeEdt.getText().toString().trim().replaceAll("\\n", "");
|
|
|
- memoEdt.setFocusable(true);
|
|
|
- memoEdt.requestFocus();
|
|
|
-
|
|
|
- }
|
|
|
+ if (newBarCodeEdt.getText().toString().contains("\n")) {
|
|
|
+ // newBarCode = newBarCodeEdt.getText().toString().trim().replaceAll("\\n", "");
|
|
|
+ memoEdt.setFocusable(true);
|
|
|
+ memoEdt.requestFocus();
|
|
|
+
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void beforeTextChanged(CharSequence s, int start, int count,
|
|
|
- int after) {
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
// TODO Auto-generated method stub
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void onTextChanged(CharSequence s, int start, int before,
|
|
|
- int count) {
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
newBarcodeUpper = newBarCodeEdt.getText().toString();
|
|
|
// 判断输入的文字是否是小写
|
|
|
for (int i = 0; i < newBarcodeUpper.length(); i++) {
|
|
|
- if (newBarcodeUpper.charAt(i) - 0 >= 97
|
|
|
- && newBarcodeUpper.charAt(i) - 0 <= 122) {
|
|
|
+ if (newBarcodeUpper.charAt(i) - 0 >= 97 && newBarcodeUpper.charAt(i) - 0 <= 122) {
|
|
|
newBarcodeUpperH.postDelayed(NewBarcodeUpperCase, 300);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- }});
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
backbtn.setOnClickListener(new View.OnClickListener() {
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
finish();
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
backtext.setOnClickListener(new View.OnClickListener() {
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- finish();
|
|
|
-
|
|
|
+ finish();
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
saveBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- originalBarCode=barcodeEdt.getText().toString();
|
|
|
- if(originalBarCode.contains("\n")){
|
|
|
- originalBarCode = originalBarCode.trim().replaceAll("\\n", "");
|
|
|
- }
|
|
|
- if(TextUtils.isEmpty(originalBarCode)){
|
|
|
+ originalBarCode = barcodeEdt.getText().toString();
|
|
|
+ if (originalBarCode.contains("\n")) {
|
|
|
+ originalBarCode = originalBarCode.trim().replaceAll("\\n", "");
|
|
|
+ }
|
|
|
+ if (TextUtils.isEmpty(originalBarCode)) {
|
|
|
barcodeEdt.setText("");
|
|
|
barcodeEdt.setFocusable(true);
|
|
|
barcodeEdt.requestFocus();
|
|
|
- Toast.makeText(getApplicationContext(),"原条码不能为空",Toast.LENGTH_SHORT).show();
|
|
|
+ Toast.makeText(getApplicationContext(), "原条码不能为空", Toast.LENGTH_SHORT).show();
|
|
|
return;
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
// if(!CommonUtil.isNumber(originalBarCode)){
|
|
|
// //CommonUtil.showRepeatDialog(originalBarCode+"格式不匹配",ChangeBarcodeActivity.this);
|
|
|
// Toast.makeText(getApplicationContext(),originalBarCode+"格式不匹配",Toast.LENGTH_SHORT).show();
|
|
|
@@ -243,17 +237,16 @@ private String originalBarcodeUpper;
|
|
|
// return ;
|
|
|
// }
|
|
|
}
|
|
|
- newBarCode=newBarCodeEdt.getText().toString();
|
|
|
- if(newBarCode.contains("\n")){
|
|
|
- newBarCode = newBarCode.trim().replaceAll("\\n", "");
|
|
|
- }
|
|
|
- if(TextUtils.isEmpty(newBarCode)){
|
|
|
- Toast.makeText(getApplicationContext(),"新条码不能为空",Toast.LENGTH_SHORT).show();
|
|
|
- newBarCodeEdt.setFocusable(true);
|
|
|
- newBarCodeEdt.requestFocus();
|
|
|
- return;
|
|
|
- }
|
|
|
- else{
|
|
|
+ newBarCode = newBarCodeEdt.getText().toString();
|
|
|
+ if (newBarCode.contains("\n")) {
|
|
|
+ newBarCode = newBarCode.trim().replaceAll("\\n", "");
|
|
|
+ }
|
|
|
+ if (TextUtils.isEmpty(newBarCode)) {
|
|
|
+ Toast.makeText(getApplicationContext(), "新条码不能为空", Toast.LENGTH_SHORT).show();
|
|
|
+ newBarCodeEdt.setFocusable(true);
|
|
|
+ newBarCodeEdt.requestFocus();
|
|
|
+ return;
|
|
|
+ } else {
|
|
|
// if(!CommonUtil.isNumber(newBarCode)){
|
|
|
// //CommonUtil.showRepeatDialog(newBarCode+"格式不匹配",ChangeBarcodeActivity.this);
|
|
|
// Toast.makeText(getApplicationContext(),newBarCode+"格式不匹配",Toast.LENGTH_SHORT).show();
|
|
|
@@ -262,208 +255,198 @@ private String originalBarcodeUpper;
|
|
|
// newBarCodeEdt.requestFocus();
|
|
|
// return ;
|
|
|
// }
|
|
|
- }
|
|
|
- if(originalBarCode.equals( newBarCode)){
|
|
|
- //Toast.makeText(getApplicationContext(),"新条码与原条码重复",Toast.LENGTH_SHORT).show();
|
|
|
- CommonUtil.showRepeatDialog("新条码与原条码重复",ChangeBarcodeActivity.this);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- memo= memoEdt.getText().toString();
|
|
|
- groutingWorkNo=worknoEdt.getText().toString();
|
|
|
- if(TextUtils.isEmpty(groutingWorkNo)){
|
|
|
- Toast.makeText(getApplicationContext(),"成型工号不能为空",Toast.LENGTH_SHORT).show();
|
|
|
+ }
|
|
|
+ if (originalBarCode.equals(newBarCode)) {
|
|
|
+ // Toast.makeText(getApplicationContext(),"新条码与原条码重复",Toast.LENGTH_SHORT).show();
|
|
|
+ CommonUtil.showRepeatDialog("新条码与原条码重复", ChangeBarcodeActivity.this);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ memo = memoEdt.getText().toString();
|
|
|
+ groutingWorkNo = worknoEdt.getText().toString();
|
|
|
+ if (TextUtils.isEmpty(groutingWorkNo)) {
|
|
|
+ Toast.makeText(getApplicationContext(), "成型工号不能为空", Toast.LENGTH_SHORT).show();
|
|
|
worknoEdt.setFocusable(true);
|
|
|
worknoEdt.requestFocus();
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- goodsCode=goodsCodeEdt.getText().toString();
|
|
|
- if(TextUtils.isEmpty(goodsCode)){
|
|
|
- Toast.makeText(getApplicationContext(),"产品编码不能为空",Toast.LENGTH_SHORT).show();
|
|
|
- goodsCodeEdt.setFocusable(true);
|
|
|
- goodsCodeEdt.requestFocus();
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ goodsCode = goodsCodeEdt.getText().toString();
|
|
|
+ if (TextUtils.isEmpty(goodsCode)) {
|
|
|
+ Toast.makeText(getApplicationContext(), "产品编码不能为空", Toast.LENGTH_SHORT).show();
|
|
|
+ goodsCodeEdt.setFocusable(true);
|
|
|
+ goodsCodeEdt.requestFocus();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
ProcessDialogUtils.showProcessDialog(ChangeBarcodeActivity.this);
|
|
|
- if(saveBtn.isEnabled()){
|
|
|
- saveBtn.setEnabled(false);
|
|
|
- //saveStart= System.currentTimeMillis();
|
|
|
- thread=new HandlerThread("saveThread",5);
|
|
|
+ if (saveBtn.isEnabled()) {
|
|
|
+ saveBtn.setEnabled(false);
|
|
|
+ // saveStart= System.currentTimeMillis();
|
|
|
+ thread = new HandlerThread("saveThread", 5);
|
|
|
thread.start();
|
|
|
- mHandler=new Handler(thread.getLooper());
|
|
|
- SaveRunnable saveRunnable=new SaveRunnable(obj);
|
|
|
- mHandler.post(saveRunnable);
|
|
|
+ mHandler = new Handler(thread.getLooper());
|
|
|
+ SaveRunnable saveRunnable = new SaveRunnable(obj);
|
|
|
+ mHandler.post(saveRunnable);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
search.setOnClickListener(new View.OnClickListener() {
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
- barcode=barcodeEdt.getText().toString();
|
|
|
- if(barcode.contains("\n")){
|
|
|
+ barcode = barcodeEdt.getText().toString();
|
|
|
+ if (barcode.contains("\n")) {
|
|
|
barcode = barcode.trim().replaceAll("\\n", "");
|
|
|
- }
|
|
|
- groutingWorkNo= worknoEdt.getText().toString();
|
|
|
- Intent i=new Intent();
|
|
|
- Bundle b=new Bundle();
|
|
|
- b.putString("barcode",barcode);
|
|
|
- b.putString("groutingWorkNo",groutingWorkNo);
|
|
|
- i.putExtras(b);
|
|
|
- i.setClass(ChangeBarcodeActivity.this,BarcodeSearchActivity.class);
|
|
|
- startActivityForResult(i, 100);
|
|
|
-
|
|
|
+ }
|
|
|
+ groutingWorkNo = worknoEdt.getText().toString();
|
|
|
+ Intent i = new Intent();
|
|
|
+ Bundle b = new Bundle();
|
|
|
+ b.putString("barcode", barcode);
|
|
|
+ b.putString("groutingWorkNo", groutingWorkNo);
|
|
|
+ i.putExtras(b);
|
|
|
+ i.setClass(ChangeBarcodeActivity.this, BarcodeSearchActivity.class);
|
|
|
+ startActivityForResult(i, 100);
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- productRecord.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- int height = parent.getHeight() - v.getHeight();
|
|
|
- BarcodeChangePopMenu recordPopMenu = new BarcodeChangePopMenu(ChangeBarcodeActivity.this,height);
|
|
|
- mPopupWindow =recordPopMenu.getMenu();
|
|
|
- if (mPopupWindow == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
|
|
|
+ productRecord.setOnClickListener(new View.OnClickListener() {
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ int height = parent.getHeight() - v.getHeight();
|
|
|
+ BarcodeChangePopMenu recordPopMenu = new BarcodeChangePopMenu(ChangeBarcodeActivity.this, height);
|
|
|
+ mPopupWindow = recordPopMenu.getMenu();
|
|
|
+ if (mPopupWindow == null) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (mPopupWindow.isShowing()) {
|
|
|
+ mPopupWindow.dismiss();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ mPopupWindow.showAtLocation(parent, Gravity.BOTTOM, 0, 0);
|
|
|
+ LinearLayout barcodeLay = (LinearLayout) recordPopMenu.menu.findViewById(R.id.barcodechangelay);
|
|
|
+ ImageView scanImg = (ImageView) recordPopMenu.menu.findViewById(R.id.scanimg);
|
|
|
+ TextView scanTitle = (TextView) recordPopMenu.menu.findViewById(R.id.scantitle);
|
|
|
+ scanTitle.setText("扫一扫");
|
|
|
+ scanImg.setBackgroundResource(R.drawable.scan);
|
|
|
+ barcodeLay.setOnClickListener(new View.OnClickListener() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ Intent openCameraIntent = new Intent(ChangeBarcodeActivity.this, CaptureActivity.class);
|
|
|
+ startActivityForResult(openCameraIntent, 102);
|
|
|
if (mPopupWindow.isShowing()) {
|
|
|
mPopupWindow.dismiss();
|
|
|
- return;
|
|
|
+
|
|
|
}
|
|
|
- mPopupWindow.showAtLocation(parent, Gravity.BOTTOM, 0, 0);
|
|
|
- LinearLayout barcodeLay=(LinearLayout) recordPopMenu.menu.findViewById(R.id.barcodechangelay);
|
|
|
- ImageView scanImg= (ImageView) recordPopMenu.menu.findViewById(R.id.scanimg);
|
|
|
- TextView scanTitle= (TextView) recordPopMenu.menu.findViewById(R.id.scantitle);
|
|
|
- scanTitle.setText("扫一扫");
|
|
|
- scanImg.setBackgroundResource(R.drawable.scan);
|
|
|
- barcodeLay.setOnClickListener(new View.OnClickListener() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- Intent openCameraIntent = new Intent(ChangeBarcodeActivity.this,CaptureActivity.class);
|
|
|
- startActivityForResult(openCameraIntent,102);
|
|
|
- if (mPopupWindow.isShowing()) {
|
|
|
- mPopupWindow.dismiss();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- goodsCodeEdt.addTextChangedListener(new TextWatcher() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onTextChanged(CharSequence s, int start,
|
|
|
- int before, int count) {
|
|
|
- code = goodsCodeEdt.getText().toString();
|
|
|
- // 判断输入的文字是否是小写
|
|
|
- for (int i = 0; i <code.length(); i++) {
|
|
|
- if (code.charAt(i) - 0 >= 97 && code.charAt(i) - 0 <= 122) {
|
|
|
- h1.postDelayed(GoodsCodeUpperCase, 300);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
- @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
|
|
|
+ goodsCodeEdt.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
+ code = goodsCodeEdt.getText().toString();
|
|
|
+ // 判断输入的文字是否是小写
|
|
|
+ for (int i = 0; i < code.length(); i++) {
|
|
|
+ if (code.charAt(i) - 0 >= 97 && code.charAt(i) - 0 <= 122) {
|
|
|
+ h1.postDelayed(GoodsCodeUpperCase, 300);
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @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
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
Handler exceptionHandler = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
switch (msg.what) {
|
|
|
case 0:
|
|
|
ProcessDialogUtils.closeProgressDilog();
|
|
|
- if(mHandler!=null){
|
|
|
- mHandler.removeCallbacksAndMessages(null);
|
|
|
- mHandler.getLooper().quit();
|
|
|
- }
|
|
|
- Bundle b=msg.getData();
|
|
|
- String message= b.getString("message");
|
|
|
- saveBtn.setEnabled(true);
|
|
|
- CustomToast.showToast(getApplicationContext(),message,
|
|
|
- 2000);
|
|
|
- break;
|
|
|
+ if (mHandler != null) {
|
|
|
+ mHandler.removeCallbacksAndMessages(null);
|
|
|
+ mHandler.getLooper().quit();
|
|
|
+ }
|
|
|
+ Bundle b = msg.getData();
|
|
|
+ String message = b.getString("message");
|
|
|
+ saveBtn.setEnabled(true);
|
|
|
+ CustomToast.showToast(getApplicationContext(), message, 2000);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
-
|
|
|
+
|
|
|
Handler handler = new Handler() {
|
|
|
@Override
|
|
|
public void handleMessage(Message msg) {
|
|
|
switch (msg.what) {
|
|
|
case 0:
|
|
|
- Bundle b=msg.getData();
|
|
|
- String result= b.getString("result");
|
|
|
- ProcessDialogUtils.closeProgressDilog();
|
|
|
+ Bundle b = msg.getData();
|
|
|
+ String result = b.getString("result");
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
try {
|
|
|
- JSONObject jo=new JSONObject(result);
|
|
|
- JSONObject jo1= jo.optJSONObject("d");
|
|
|
- int status= jo1.optInt("Status");
|
|
|
- String message=jo1.optString("Message");
|
|
|
- goodsCodeEdt.setText("");
|
|
|
- barcodeEdt.setText("");
|
|
|
- newBarCodeEdt.setText("");
|
|
|
- memoEdt.setText("");
|
|
|
- saveBtn.setEnabled(true);
|
|
|
- if(status==0){
|
|
|
- CommonUtil.playSound(getApplicationContext());
|
|
|
- goodsCodeEdt.setFocusable(true);
|
|
|
- goodsCodeEdt.requestFocus();
|
|
|
- // saveEnd=System.currentTimeMillis();
|
|
|
- //long saveTime= saveEnd-saveStart;
|
|
|
- //Toast.makeText(getApplicationContext(),saveTime+"save",Toast.LENGTH_LONG).show();
|
|
|
- //System.out.println(saveTime+"save");
|
|
|
- Toast.makeText(getApplicationContext(),"上传成功",Toast.LENGTH_SHORT).show();
|
|
|
- if(mHandler!=null){
|
|
|
- mHandler.removeCallbacksAndMessages(null);
|
|
|
- mHandler.getLooper().quit();
|
|
|
+ JSONObject jo = new JSONObject(result);
|
|
|
+ JSONObject jo1 = jo.optJSONObject("d");
|
|
|
+ int status = jo1.optInt("Status");
|
|
|
+ String message = jo1.optString("Message");
|
|
|
+ goodsCodeEdt.setText("");
|
|
|
+ barcodeEdt.setText("");
|
|
|
+ newBarCodeEdt.setText("");
|
|
|
+ memoEdt.setText("");
|
|
|
+ saveBtn.setEnabled(true);
|
|
|
+ if (status == 0) {
|
|
|
+ CommonUtil.playSound(getApplicationContext());
|
|
|
+ goodsCodeEdt.setFocusable(true);
|
|
|
+ goodsCodeEdt.requestFocus();
|
|
|
+ // saveEnd=System.currentTimeMillis();
|
|
|
+ // long saveTime= saveEnd-saveStart;
|
|
|
+ // Toast.makeText(getApplicationContext(),saveTime+"save",Toast.LENGTH_LONG).show();
|
|
|
+ // System.out.println(saveTime+"save");
|
|
|
+ Toast.makeText(getApplicationContext(), "上传成功", Toast.LENGTH_SHORT).show();
|
|
|
+ if (mHandler != null) {
|
|
|
+ mHandler.removeCallbacksAndMessages(null);
|
|
|
+ mHandler.getLooper().quit();
|
|
|
}
|
|
|
-
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- else{
|
|
|
- goodsCodeEdt.setFocusable(true);
|
|
|
- goodsCodeEdt.requestFocus();
|
|
|
- CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,getApplicationContext()) ;
|
|
|
- CommonUtil.showAlertDialog(status, message,ChangeBarcodeActivity.this);
|
|
|
- if(mHandler!=null){
|
|
|
- mHandler.removeCallbacksAndMessages(null);
|
|
|
- mHandler.getLooper().quit();
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ else {
|
|
|
+ goodsCodeEdt.setFocusable(true);
|
|
|
+ goodsCodeEdt.requestFocus();
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, getApplicationContext());
|
|
|
+ CommonUtil.showAlertDialog(status, message, ChangeBarcodeActivity.this);
|
|
|
+ if (mHandler != null) {
|
|
|
+ mHandler.removeCallbacksAndMessages(null);
|
|
|
+ mHandler.getLooper().quit();
|
|
|
}
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
} catch (JSONException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -471,132 +454,128 @@ private String originalBarcodeUpper;
|
|
|
|
|
|
private class SaveRunnable implements Runnable {
|
|
|
private Object obj;
|
|
|
- public SaveRunnable(Object obj){
|
|
|
- this.obj=obj;
|
|
|
+
|
|
|
+ public SaveRunnable(Object obj) {
|
|
|
+ this.obj = obj;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
|
-
|
|
|
- synchronized(obj){
|
|
|
- try {
|
|
|
- // 生产条码检验请求数据
|
|
|
- JSONObject jsonObject = new JSONObject();
|
|
|
- jsonObject.put("accountCode", accountCode);
|
|
|
- jsonObject.put("userCode",changeBarcode_userCode);
|
|
|
- jsonObject.put("userPassword",password);
|
|
|
- jsonObject.put("sessionKey", sessionkey);
|
|
|
- jsonObject.put("barcode",originalBarCode);// 条码
|
|
|
- jsonObject.put("newBarcode",newBarCode);// 条码
|
|
|
- jsonObject.put("remarks",memo);// 条码
|
|
|
- jsonObject.put("groutingUserCode",groutingWorkNo);
|
|
|
- jsonObject.put("goodsCode",goodsCode);
|
|
|
- WebClient client = null;
|
|
|
- client = new WebClient();
|
|
|
- String result = client.doPost("http://" + ServerAddress_ip
|
|
|
- + ":" + ServerAddress_duankou
|
|
|
- + Constants.CHANGE_BARCODE, jsonObject.toString(),
|
|
|
- "application/json");
|
|
|
- Message m=new Message();
|
|
|
- m.what=0;
|
|
|
- Bundle b=new Bundle();
|
|
|
- b.putString("result",result);
|
|
|
- m.setData(b);
|
|
|
- handler.sendMessage(m);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- Message m=new Message();
|
|
|
- m.what=0;
|
|
|
- Bundle b=new Bundle();
|
|
|
- b.putString("message","网络连接异常");
|
|
|
- m.setData(b);
|
|
|
- exceptionHandler.sendMessage(m);
|
|
|
- }
|
|
|
+
|
|
|
+ synchronized (obj) {
|
|
|
+ try {
|
|
|
+ // 生产条码检验请求数据
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("accountCode", accountCode);
|
|
|
+ jsonObject.put("userCode", changeBarcode_userCode);
|
|
|
+ jsonObject.put("userPassword", password);
|
|
|
+ jsonObject.put("sessionKey", sessionkey);
|
|
|
+ jsonObject.put("barcode", originalBarCode);// 条码
|
|
|
+ jsonObject.put("newBarcode", newBarCode);// 条码
|
|
|
+ jsonObject.put("remarks", memo);// 条码
|
|
|
+ jsonObject.put("groutingUserCode", groutingWorkNo);
|
|
|
+ jsonObject.put("goodsCode", goodsCode);
|
|
|
+ WebClient client = null;
|
|
|
+ client = new WebClient();
|
|
|
+ String result = client.doPost(
|
|
|
+ "http://" + ServerAddress_ip + ":" + ServerAddress_duankou + Constants.CHANGE_BARCODE,
|
|
|
+ jsonObject.toString(), "application/json");
|
|
|
+ Message m = new Message();
|
|
|
+ m.what = 0;
|
|
|
+ Bundle b = new Bundle();
|
|
|
+ b.putString("result", result);
|
|
|
+ m.setData(b);
|
|
|
+ handler.sendMessage(m);
|
|
|
+ }
|
|
|
+
|
|
|
+ catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ Message m = new Message();
|
|
|
+ m.what = 0;
|
|
|
+ Bundle b = new Bundle();
|
|
|
+ b.putString("message", "网络连接异常");
|
|
|
+ m.setData(b);
|
|
|
+ exceptionHandler.sendMessage(m);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
-
|
|
|
- Runnable UpperCase = new Runnable() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- // 小写转大写
|
|
|
- worknoEdt.setText(user.toUpperCase());
|
|
|
- // 设置EditText光标位置
|
|
|
- worknoEdt.setSelection(user.length());
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- Runnable GoodsCodeUpperCase = new Runnable() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- // 小写转大写
|
|
|
- goodsCodeEdt.setText(code.toUpperCase());
|
|
|
- // 设置EditText光标位置
|
|
|
- goodsCodeEdt.setSelection(code.length());
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- };
|
|
|
-
|
|
|
- Runnable NewBarcodeUpperCase = new Runnable() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- // 小写转大写
|
|
|
- newBarCodeEdt.setText(newBarcodeUpper.toUpperCase());
|
|
|
- // 设置EditText光标位置
|
|
|
- newBarCodeEdt.setSelection(newBarcodeUpper.length());
|
|
|
|
|
|
- }
|
|
|
+ Runnable UpperCase = new Runnable() {
|
|
|
|
|
|
- };
|
|
|
-
|
|
|
- Runnable OriginalBarcodeUpperCase = new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ // 小写转大写
|
|
|
+ worknoEdt.setText(user.toUpperCase());
|
|
|
+ // 设置EditText光标位置
|
|
|
+ worknoEdt.setSelection(user.length());
|
|
|
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- // 小写转大写
|
|
|
- barcodeEdt.setText(newBarcodeUpper.toUpperCase());
|
|
|
- // 设置EditText光标位置
|
|
|
- barcodeEdt.setSelection(newBarcodeUpper.length());
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ };
|
|
|
+
|
|
|
+ Runnable GoodsCodeUpperCase = new Runnable() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ // 小写转大写
|
|
|
+ goodsCodeEdt.setText(code.toUpperCase());
|
|
|
+ // 设置EditText光标位置
|
|
|
+ goodsCodeEdt.setSelection(code.length());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
|
|
|
- };
|
|
|
+ Runnable NewBarcodeUpperCase = new Runnable() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ // 小写转大写
|
|
|
+ newBarCodeEdt.setText(newBarcodeUpper.toUpperCase());
|
|
|
+ // 设置EditText光标位置
|
|
|
+ newBarCodeEdt.setSelection(newBarcodeUpper.length());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
+
|
|
|
+ Runnable OriginalBarcodeUpperCase = new Runnable() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ // 小写转大写
|
|
|
+ barcodeEdt.setText(newBarcodeUpper.toUpperCase());
|
|
|
+ // 设置EditText光标位置
|
|
|
+ barcodeEdt.setSelection(newBarcodeUpper.length());
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ };
|
|
|
|
|
|
-
|
|
|
@Override
|
|
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
- if (requestCode == 100 && resultCode == 101) {
|
|
|
+ if (requestCode == 100 && resultCode == 101) {
|
|
|
// 图片放大删除选中图片
|
|
|
Bundle b = data.getExtras();
|
|
|
- String goodscode=b.getString("goodscode");
|
|
|
+ String goodscode = b.getString("goodscode");
|
|
|
goodsCodeEdt.setText(goodscode);
|
|
|
- String barcode= b.getString("barcode");
|
|
|
- barcodeEdt.setText(barcode);
|
|
|
- int size= barcode.length();
|
|
|
- barcodeEdt.setSelection(size);
|
|
|
-
|
|
|
- }
|
|
|
- else if (requestCode ==102&&resultCode == RESULT_OK) {
|
|
|
+ String barcode = b.getString("barcode");
|
|
|
+ barcodeEdt.setText(barcode);
|
|
|
+ int size = barcode.length();
|
|
|
+ barcodeEdt.setSelection(size);
|
|
|
+
|
|
|
+ } else if (requestCode == 102 && resultCode == RESULT_OK) {
|
|
|
Bundle bundle = data.getExtras();
|
|
|
String scanResult = bundle.getString("result");
|
|
|
View rootview = this.getWindow().getDecorView();
|
|
|
- EditText v=(EditText) rootview.findFocus();
|
|
|
- v.setText(scanResult);
|
|
|
- v.setSelection(scanResult.length());
|
|
|
+ EditText v = (EditText) rootview.findFocus();
|
|
|
+ v.setText(scanResult);
|
|
|
+ v.setSelection(scanResult.length());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
|
|
|
@Override
|
|
|
public boolean onCreateOptionsMenu(Menu menu) {
|
|
|
@@ -604,13 +583,14 @@ private String originalBarcodeUpper;
|
|
|
getMenuInflater().inflate(R.menu.change_barcode, menu);
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
- public Resources getResources() {
|
|
|
- Resources res = super.getResources();
|
|
|
- Configuration config=new Configuration();
|
|
|
- config.setToDefaults();
|
|
|
- res.updateConfiguration(config,res.getDisplayMetrics() );
|
|
|
- return res;
|
|
|
- }
|
|
|
+ public Resources getResources() {
|
|
|
+ Resources res = super.getResources();
|
|
|
+ Configuration config = new Configuration();
|
|
|
+ config.setToDefaults();
|
|
|
+ res.updateConfiguration(config, res.getDisplayMetrics());
|
|
|
+ return res;
|
|
|
+ }
|
|
|
|
|
|
}
|