|
@@ -0,0 +1,958 @@
|
|
|
|
|
+package com.jiaju.activity;
|
|
|
|
|
+
|
|
|
|
|
+import java.lang.ref.WeakReference;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+import org.json.JSONArray;
|
|
|
|
|
+import org.json.JSONObject;
|
|
|
|
|
+
|
|
|
|
|
+import com.jiaju.adapter.NakedPorcelainAdapter;
|
|
|
|
|
+import com.jiaju.model.NakedPorcelain;
|
|
|
|
|
+import com.jiaju.net.WebClient;
|
|
|
|
|
+import com.jiaju.utils.CommonUtil;
|
|
|
|
|
+import com.jiaju.utils.Constants;
|
|
|
|
|
+import com.jiaju.utils.CustomToast;
|
|
|
|
|
+import com.jiaju.utils.ProcessDialogUtils;
|
|
|
|
|
+import com.jiaju.utils.Removeduplicate;
|
|
|
|
|
+import com.jiaju.widget.DefectCommonPopMenu;
|
|
|
|
|
+
|
|
|
|
|
+import android.app.Activity;
|
|
|
|
|
+import android.app.Notification;
|
|
|
|
|
+import android.content.Context;
|
|
|
|
|
+import android.content.Intent;
|
|
|
|
|
+import android.content.SharedPreferences;
|
|
|
|
|
+import android.content.res.Configuration;
|
|
|
|
|
+import android.content.res.Resources;
|
|
|
|
|
+import android.os.Bundle;
|
|
|
|
|
+import android.os.Handler;
|
|
|
|
|
+import android.os.HandlerThread;
|
|
|
|
|
+import android.os.Message;
|
|
|
|
|
+import android.text.Editable;
|
|
|
|
|
+import android.text.InputFilter;
|
|
|
|
|
+import android.text.InputType;
|
|
|
|
|
+import android.text.Spanned;
|
|
|
|
|
+import android.text.TextUtils;
|
|
|
|
|
+import android.text.TextWatcher;
|
|
|
|
|
+import android.view.Gravity;
|
|
|
|
|
+import android.view.KeyEvent;
|
|
|
|
|
+import android.view.View;
|
|
|
|
|
+import android.view.View.OnClickListener;
|
|
|
|
|
+import android.view.inputmethod.EditorInfo;
|
|
|
|
|
+import android.widget.Button;
|
|
|
|
|
+import android.widget.EditText;
|
|
|
|
|
+import android.widget.ImageButton;
|
|
|
|
|
+import android.widget.ImageView;
|
|
|
|
|
+import android.widget.LinearLayout;
|
|
|
|
|
+import android.widget.ListView;
|
|
|
|
|
+import android.widget.PopupWindow;
|
|
|
|
|
+import android.widget.RelativeLayout;
|
|
|
|
|
+import android.widget.TextView;
|
|
|
|
|
+import android.widget.Toast;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 裸瓷包装撤销(非工序)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author lenovo
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
+
|
|
|
|
|
+public class NakedPorcelainActivity extends Activity {
|
|
|
|
|
+ private EditText barcode;
|
|
|
|
|
+ private String accountCode;
|
|
|
|
|
+ private String userId;
|
|
|
|
|
+ private String checkCollectModify_userCode;
|
|
|
|
|
+ private String password;
|
|
|
|
|
+ private String sessionkey;
|
|
|
|
|
+ private SharedPreferences preferences;
|
|
|
|
|
+ private String ServerAddress_ip;
|
|
|
|
|
+ private String ServerAddress_duankou;
|
|
|
|
|
+ private HandlerThread thread;
|
|
|
|
|
+ private Handler mHandler;
|
|
|
|
|
+ private WebClient client = null;
|
|
|
|
|
+ private ImageButton backBtn;
|
|
|
|
|
+ private TextView back;
|
|
|
|
|
+ private ListView mListView;
|
|
|
|
|
+ private EditText worknoEdt;
|
|
|
|
|
+ private TextView title;
|
|
|
|
|
+ private boolean worknovalid;
|
|
|
|
|
+ private String workNoName;
|
|
|
|
|
+ private ImageView productRecord;
|
|
|
|
|
+ private RelativeLayout parent;
|
|
|
|
|
+ private PopupWindow mPopupWindow; // 弹出框
|
|
|
|
|
+ public Object obj = new Object();
|
|
|
|
|
+ public Button btnMakeBillet;
|
|
|
|
|
+ private NakedPorcelainAdapter adapter = null;
|
|
|
|
|
+ private List<NakedPorcelain> npList = null;
|
|
|
|
|
+ private ExceptionHandler exceptionHandler = new ExceptionHandler(this);
|
|
|
|
|
+ private ResultHandler handler = new ResultHandler(this);
|
|
|
|
|
+ private Handler barcodeUpperH = new Handler();
|
|
|
|
|
+ private String barcodeUpper;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
+ super.onCreate(savedInstanceState);
|
|
|
|
|
+ setContentView(R.layout.activity_naked_porcelain);
|
|
|
|
|
+
|
|
|
|
|
+ initView();
|
|
|
|
|
+ Bundle b = getIntent().getExtras();
|
|
|
|
|
+ String procedureName = b.getString("ProcedureName");
|
|
|
|
|
+
|
|
|
|
|
+ btnMakeBillet.setVisibility(View.VISIBLE);
|
|
|
|
|
+ procedureName = b.getString("title");
|
|
|
|
|
+ title.setText(procedureName);// 设置标题
|
|
|
|
|
+ npList = new ArrayList<NakedPorcelain>();
|
|
|
|
|
+ preferences = getSharedPreferences("user", Context.MODE_PRIVATE);
|
|
|
|
|
+ ServerAddress_ip = preferences.getString("ServerAddress_ip", "");
|
|
|
|
|
+ ServerAddress_duankou = preferences.getString("ServerAddress_duankou", "");
|
|
|
|
|
+ accountCode = preferences.getString("AccountCode", "");
|
|
|
|
|
+ userId = preferences.getString("UserID", "");
|
|
|
|
|
+ workNoName = preferences.getString("UserName", "");
|
|
|
|
|
+ checkCollectModify_userCode = preferences.getString("UserCode", "");
|
|
|
|
|
+ password = preferences.getString("UserPassword", "");
|
|
|
|
|
+ sessionkey = preferences.getString("SessionKey", "");
|
|
|
|
|
+ CommonUtil.BarcodeMaxLength(barcode, 50);
|
|
|
|
|
+ worknoEdt.setText(checkCollectModify_userCode);
|
|
|
|
|
+ worknoEdt.setEnabled(false);
|
|
|
|
|
+ worknoEdt.setFocusable(false);
|
|
|
|
|
+ worknoEdt.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+
|
|
|
|
|
+ AllListeners();
|
|
|
|
|
+ client = new WebClient();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void initView() {
|
|
|
|
|
+ barcode = (EditText) findViewById(R.id.bar_code);
|
|
|
|
|
+ barcode.setRawInputType(InputType.TYPE_CLASS_NUMBER);
|
|
|
|
|
+ backBtn = (ImageButton) findViewById(R.id.left_img);
|
|
|
|
|
+ btnMakeBillet = (Button) findViewById(R.id.btnMakeBillet);
|
|
|
|
|
+ back = (TextView) findViewById(R.id.back);
|
|
|
|
|
+ mListView = (ListView) findViewById(R.id.listview);
|
|
|
|
|
+ title = (TextView) findViewById(R.id.title);
|
|
|
|
|
+ worknoEdt = (EditText) findViewById(R.id.user_code);
|
|
|
|
|
+ productRecord = (ImageView) findViewById(R.id.search);
|
|
|
|
|
+ productRecord.setVisibility(View.VISIBLE);
|
|
|
|
|
+ parent = (RelativeLayout) findViewById(R.id.parentRel);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private void AllListeners() {
|
|
|
|
|
+
|
|
|
|
|
+ productRecord.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+ int height = parent.getHeight() - v.getHeight();
|
|
|
|
|
+ DefectCommonPopMenu recordPopMenu = new DefectCommonPopMenu(NakedPorcelainActivity.this, height);
|
|
|
|
|
+ mPopupWindow = recordPopMenu.getMenu();
|
|
|
|
|
+ if (mPopupWindow == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (mPopupWindow.isShowing()) {
|
|
|
|
|
+ mPopupWindow.dismiss();
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ mPopupWindow.showAtLocation(parent, Gravity.BOTTOM, 0, 0);
|
|
|
|
|
+ LinearLayout scanLay = (LinearLayout) recordPopMenu.menu.findViewById(R.id.scanlay);
|
|
|
|
|
+ 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);
|
|
|
|
|
+ scanLay.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+ Intent openCameraIntent = new Intent(NakedPorcelainActivity.this, CaptureActivity.class);
|
|
|
|
|
+ startActivityForResult(openCameraIntent, 102);
|
|
|
|
|
+ if (mPopupWindow.isShowing()) {
|
|
|
|
|
+ mPopupWindow.dismiss();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ barcode.addTextChangedListener(new TextWatcher() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void afterTextChanged(Editable arg0) {
|
|
|
|
|
+ if (barcode.getText().toString().contains("\n")) {
|
|
|
|
|
+ String code = barcode.getText().toString().trim().replaceAll("\\n", "");
|
|
|
|
|
+ String workno = worknoEdt.getText().toString();
|
|
|
|
|
+ if (TextUtils.isEmpty(workno)) {
|
|
|
|
|
+ Toast.makeText(getApplicationContext(), "生产工号不能为空", Toast.LENGTH_SHORT).show();
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ ProcessDialogUtils.showProcessDialog(NakedPorcelainActivity.this);
|
|
|
|
|
+
|
|
|
|
|
+ barcode.setEnabled(false);
|
|
|
|
|
+ barcode.setFocusable(false);
|
|
|
|
|
+ barcode.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
|
|
|
|
|
+ int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+
|
|
|
|
|
+ if (npList.size() > 0) {
|
|
|
|
|
+ boolean b = Removeduplicate.removeBarCode(code,
|
|
|
|
|
+ npList);
|
|
|
|
|
+
|
|
|
|
|
+ if (b) {
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+ barcode.setEnabled(true);
|
|
|
|
|
+ barcode.setText("");
|
|
|
|
|
+ barcode.setFocusable(true);
|
|
|
|
|
+ barcode.setFocusableInTouchMode(true);
|
|
|
|
|
+ barcode.requestFocus();
|
|
|
|
|
+ barcode.findFocus();
|
|
|
|
|
+ barcode.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source,
|
|
|
|
|
+ int start, int end, Spanned dest,
|
|
|
|
|
+ int dstart, int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+ CommonUtil.BarcodeMaxLength(barcode, 50);
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
|
|
|
|
|
+ getApplicationContext());
|
|
|
|
|
+
|
|
|
|
|
+ CustomToast.showToast(getApplicationContext(), "条码"
|
|
|
|
|
+ + code + "重复", 2000);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ thread = new HandlerThread("barcodeThread", 5);
|
|
|
|
|
+ thread.start();
|
|
|
|
|
+ mHandler = new Handler(thread.getLooper());
|
|
|
|
|
+ BarcodeRunnable barcodeRunnable = new BarcodeRunnable(code, obj);
|
|
|
|
|
+ mHandler.post(barcodeRunnable);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
|
+ barcodeUpper = barcode.getText().toString();
|
|
|
|
|
+ // 判断输入的文字是否是小写
|
|
|
|
|
+ for (int i = 0; i < barcodeUpper.length(); i++) {
|
|
|
|
|
+ if (barcodeUpper.charAt(i) - 0 >= 97 && barcodeUpper.charAt(i) - 0 <= 122) {
|
|
|
|
|
+ barcodeUpperH.postDelayed(BarcodeUpperCase, 300);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ barcode.setOnEditorActionListener(new TextView.OnEditorActionListener() {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
|
|
|
|
+ if (actionId == EditorInfo.IME_ACTION_GO) {
|
|
|
|
|
+ String workno = worknoEdt.getText().toString();
|
|
|
|
|
+ if (TextUtils.isEmpty(workno)) {
|
|
|
|
|
+ Toast.makeText(getApplicationContext(), "生产工号不能为空", Toast.LENGTH_SHORT).show();
|
|
|
|
|
+
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String code = barcode.getText().toString().trim();
|
|
|
|
|
+ if (!TextUtils.isEmpty(code)) {
|
|
|
|
|
+
|
|
|
|
|
+ ProcessDialogUtils.showProcessDialog(NakedPorcelainActivity.this);
|
|
|
|
|
+
|
|
|
|
|
+ barcode.setEnabled(false);
|
|
|
|
|
+ barcode.setFocusable(false);
|
|
|
|
|
+ barcode.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
|
|
|
|
|
+ int dstart, int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+
|
|
|
|
|
+ if (npList.size() > 0) {
|
|
|
|
|
+ boolean b = Removeduplicate.removeBarCode(code,
|
|
|
|
|
+ npList);
|
|
|
|
|
+
|
|
|
|
|
+ if (b) {
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+ barcode.setEnabled(true);
|
|
|
|
|
+ barcode.setText("");
|
|
|
|
|
+ barcode.setFocusable(true);
|
|
|
|
|
+ barcode.setFocusableInTouchMode(true);
|
|
|
|
|
+ barcode.requestFocus();
|
|
|
|
|
+ barcode.findFocus();
|
|
|
|
|
+ barcode.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source,
|
|
|
|
|
+ int start, int end, Spanned dest,
|
|
|
|
|
+ int dstart, int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+ CommonUtil.BarcodeMaxLength(barcode, 50);
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
|
|
|
|
|
+ getApplicationContext());
|
|
|
|
|
+
|
|
|
|
|
+ CustomToast.showToast(getApplicationContext(), "条码"
|
|
|
|
|
+ + code + "重复", 2000);
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ thread = new HandlerThread("barcodeThread", 5);
|
|
|
|
|
+ thread.start();
|
|
|
|
|
+ mHandler = new Handler(thread.getLooper());
|
|
|
|
|
+ BarcodeRunnable barcodeRunnable = new BarcodeRunnable(code, obj);
|
|
|
|
|
+ mHandler.post(barcodeRunnable);
|
|
|
|
|
+ return true;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return true;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ back.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+
|
|
|
|
|
+ finish();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ backBtn.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+
|
|
|
|
|
+ finish();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ btnMakeBillet.setOnClickListener(new OnClickListener() {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ String workno = worknoEdt.getText().toString();
|
|
|
|
|
+ if (TextUtils.isEmpty(workno)) {
|
|
|
|
|
+ Toast.makeText(getApplicationContext(), "生产工号不能为空", Toast.LENGTH_SHORT).show();
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (npList != null && npList.size() > 0) {
|
|
|
|
|
+
|
|
|
|
|
+ ProcessDialogUtils.showProcessDialog(NakedPorcelainActivity.this);
|
|
|
|
|
+ if (btnMakeBillet.isEnabled()) {
|
|
|
|
|
+ btnMakeBillet.setEnabled(false);
|
|
|
|
|
+ thread = null;
|
|
|
|
|
+ thread = new HandlerThread("SaveThread", 5);
|
|
|
|
|
+ thread.start();
|
|
|
|
|
+ mHandler = null;
|
|
|
|
|
+ mHandler = new Handler(thread.getLooper());
|
|
|
|
|
+ SaveDataRunnable sRunnable = new SaveDataRunnable();
|
|
|
|
|
+ mHandler.post(sRunnable);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Toast.makeText(getApplicationContext(), "产品列表不能为空", Toast.LENGTH_SHORT).show();
|
|
|
|
|
+
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Runnable BarcodeUpperCase = new Runnable() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ // 小写转大写
|
|
|
|
|
+ barcode.setText(barcodeUpper.toUpperCase());
|
|
|
|
|
+ // 设置EditText光标位置
|
|
|
|
|
+ barcode.setSelection(barcodeUpper.length());
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ private class SaveDataRunnable implements Runnable {
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ try {
|
|
|
|
|
+ jsonObject.put("accountCode", accountCode);
|
|
|
|
|
+ jsonObject.put("userCode", checkCollectModify_userCode);
|
|
|
|
|
+ jsonObject.put("userPassword", password);
|
|
|
|
|
+ jsonObject.put("sessionKey", sessionkey);
|
|
|
|
|
+ jsonObject.put("module", "LuociRevoke");
|
|
|
|
|
+ jsonObject.put("action", "AddChancelLuoci");
|
|
|
|
|
+ JSONObject jsonData = new JSONObject();
|
|
|
|
|
+ JSONArray componenListArray = new JSONArray();
|
|
|
|
|
+ if (npList != null && npList.size() > 0) {
|
|
|
|
|
+ for (int m = 0; m < npList.size(); m++) {
|
|
|
|
|
+ JSONObject componenListobj = new JSONObject();
|
|
|
|
|
+ componenListobj.put("barcode",npList.get(m).getBarcode());
|
|
|
|
|
+ componenListobj.put("productionCode",npList.get(m).getProductionCode());
|
|
|
|
|
+ componenListobj.put("productionName",npList.get(m).getProductionName());
|
|
|
|
|
+ componenListobj.put("logonName",npList.get(m).getLogonName());
|
|
|
|
|
+ componenListobj.put("groutingUserCode",npList.get(m).getGroutingUserCode());
|
|
|
|
|
+ componenListobj.put("materialCode",npList.get(m).getMaterialCode());
|
|
|
|
|
+ componenListobj.put("UserID",userId);
|
|
|
|
|
+ componenListobj.put("Usercode",checkCollectModify_userCode);
|
|
|
|
|
+ componenListobj.put("UserName",workNoName);
|
|
|
|
|
+ componenListArray.put(componenListobj);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ jsonData.put("detailTable", componenListArray);
|
|
|
|
|
+ jsonObject.put("jsonData", jsonData.toString());
|
|
|
|
|
+ String result = client.doPost("http://" + ServerAddress_ip + ":" + ServerAddress_duankou
|
|
|
|
|
+ + Constants.serverAction + "/DoAction", jsonObject.toString(), "application/json");
|
|
|
|
|
+ Message m = new Message();
|
|
|
|
|
+ m.what = 2;
|
|
|
|
|
+ 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);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static class ExceptionHandler extends Handler {
|
|
|
|
|
+ private final WeakReference mActivity;
|
|
|
|
|
+
|
|
|
|
|
+ public ExceptionHandler(NakedPorcelainActivity activity) {
|
|
|
|
|
+ mActivity = new WeakReference(activity);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
|
|
+ super.handleMessage(msg);
|
|
|
|
|
+ NakedPorcelainActivity activity = (NakedPorcelainActivity) mActivity.get();
|
|
|
|
|
+ switch (msg.what) {
|
|
|
|
|
+ case 0:
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+ Bundle b = msg.getData();
|
|
|
|
|
+ int status = b.getInt("status");
|
|
|
|
|
+ String errorMsg = b.getString("errorMsg");
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, activity.getApplicationContext());
|
|
|
|
|
+ CommonUtil.showBarCodeAlertDialog(status, errorMsg, activity, activity.barcode, null, null);
|
|
|
|
|
+
|
|
|
|
|
+ if (activity.mHandler != null) {
|
|
|
|
|
+ activity.mHandler.removeCallbacksAndMessages(null);
|
|
|
|
|
+ activity.mHandler.getLooper().quit();
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+ Bundle b2 = msg.getData();
|
|
|
|
|
+ String message = b2.getString("message");
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, activity);
|
|
|
|
|
+
|
|
|
|
|
+ CustomToast.showToast(activity.getApplicationContext(), message, 2000);
|
|
|
|
|
+
|
|
|
|
|
+ activity.barcode.setEnabled(true);
|
|
|
|
|
+ activity.barcode.setFocusable(true);
|
|
|
|
|
+ activity.barcode.setFocusableInTouchMode(true);
|
|
|
|
|
+ activity.barcode.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
|
|
|
|
|
+ int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+ CommonUtil.BarcodeMaxLength(activity.barcode, 50);
|
|
|
|
|
+
|
|
|
|
|
+ if (activity.mHandler != null) {
|
|
|
|
|
+ activity.mHandler.removeCallbacksAndMessages(null);
|
|
|
|
|
+ activity.mHandler.getLooper().quit();
|
|
|
|
|
+ }
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+ if (activity.mHandler != null) {
|
|
|
|
|
+ activity.mHandler.removeCallbacksAndMessages(null);
|
|
|
|
|
+ activity.mHandler.getLooper().quit();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Bundle b3 = msg.getData();
|
|
|
|
|
+ String message3 = b3.getString("message");
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, activity.getApplicationContext());
|
|
|
|
|
+ // CommonUtil.showRepeatDialog(message3,CheckCollectModifyActivity.this);
|
|
|
|
|
+ // Toast.makeText(getApplicationContext(), message3,
|
|
|
|
|
+ // Toast.LENGTH_SHORT).show();
|
|
|
|
|
+ CustomToast.showToast(activity.getApplicationContext(), message3, 2000);
|
|
|
|
|
+ activity.barcode.setEnabled(true);
|
|
|
|
|
+ activity.barcode.setText("");
|
|
|
|
|
+ activity.barcode.setFocusable(true);
|
|
|
|
|
+ activity.barcode.setFocusableInTouchMode(true);
|
|
|
|
|
+ activity.barcode.requestFocus();
|
|
|
|
|
+ activity.barcode.findFocus();
|
|
|
|
|
+ activity.barcode.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
|
|
|
|
|
+ int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+ CommonUtil.BarcodeMaxLength(activity.barcode, 50);
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+ Bundle b7 = msg.getData();
|
|
|
|
|
+ int status7 = b7.getInt("status");
|
|
|
|
|
+ String message7 = b7.getString("message");
|
|
|
|
|
+
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, activity.getApplicationContext());
|
|
|
|
|
+ CommonUtil.showBarCodeAlertDialog(status7, message7, activity, activity.barcode, null, null);
|
|
|
|
|
+
|
|
|
|
|
+ if (activity.mHandler != null) {
|
|
|
|
|
+ activity.mHandler.removeCallbacksAndMessages(null);
|
|
|
|
|
+ activity.mHandler.getLooper().quit();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case 4:
|
|
|
|
|
+ if (activity.mHandler != null) {
|
|
|
|
|
+ activity.mHandler.removeCallbacksAndMessages(null);
|
|
|
|
|
+ activity.mHandler.getLooper().quit();
|
|
|
|
|
+ }
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+ Bundle b4 = msg.getData();
|
|
|
|
|
+ String message4 = b4.getString("message");
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, activity.getApplicationContext());
|
|
|
|
|
+
|
|
|
|
|
+ CustomToast.showToast(activity.getApplicationContext(), message4, 2000);
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case 5:
|
|
|
|
|
+ if (activity.mHandler != null) {
|
|
|
|
|
+ activity.mHandler.removeCallbacksAndMessages(null);
|
|
|
|
|
+ activity.mHandler.getLooper().quit();
|
|
|
|
|
+ }
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+ Bundle b5 = msg.getData();
|
|
|
|
|
+ String message5 = b5.getString("message");
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, activity.getApplicationContext());
|
|
|
|
|
+ // CommonUtil.showRepeatDialog(message5,CheckCollectModifyActivity.this);
|
|
|
|
|
+ // Toast.makeText(getApplicationContext(), message5,
|
|
|
|
|
+ // Toast.LENGTH_SHORT).show();
|
|
|
|
|
+ CustomToast.showToast(activity.getApplicationContext(), message5, 2000);
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 6:
|
|
|
|
|
+ if (activity.mHandler != null) {
|
|
|
|
|
+ activity.mHandler.removeCallbacksAndMessages(null);
|
|
|
|
|
+ activity.mHandler.getLooper().quit();
|
|
|
|
|
+ }
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+
|
|
|
|
|
+ Bundle b1 = msg.getData();
|
|
|
|
|
+ String errmsg = b1.getString("errmsg");
|
|
|
|
|
+ String missingFlag = b1.getString("flag");
|
|
|
|
|
+ Intent intent = new Intent();
|
|
|
|
|
+ Bundle b6 = new Bundle();
|
|
|
|
|
+ b6.putString("msg", errmsg);
|
|
|
|
|
+ b6.putString("missingFlag", missingFlag);
|
|
|
|
|
+ intent.putExtras(b6);
|
|
|
|
|
+ intent.setClass(activity, MissingScanActivity.class);
|
|
|
|
|
+ activity.startActivityForResult(intent, 101);
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case 7:
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+ if (activity.mHandler != null) {
|
|
|
|
|
+ activity.mHandler.removeCallbacksAndMessages(null);
|
|
|
|
|
+ activity.mHandler.getLooper().quit();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Bundle b8 = msg.getData();
|
|
|
|
|
+ String message8 = b8.getString("message");
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, activity.getApplicationContext());
|
|
|
|
|
+ CommonUtil.showRepeatDialog(message8, activity);
|
|
|
|
|
+
|
|
|
|
|
+ activity.barcode.setEnabled(true);
|
|
|
|
|
+ activity.barcode.setText("");
|
|
|
|
|
+ activity.barcode.setFocusable(true);
|
|
|
|
|
+ activity.barcode.setFocusableInTouchMode(true);
|
|
|
|
|
+ activity.barcode.requestFocus();
|
|
|
|
|
+ activity.barcode.findFocus();
|
|
|
|
|
+ activity.barcode.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
|
|
|
|
|
+ int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+ CommonUtil.BarcodeMaxLength(activity.barcode, 50);
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ private static class ResultHandler extends Handler {
|
|
|
|
|
+
|
|
|
|
|
+ private final WeakReference mActivity;
|
|
|
|
|
+
|
|
|
|
|
+ public ResultHandler(NakedPorcelainActivity activity) {
|
|
|
|
|
+ mActivity = new WeakReference(activity);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void handleMessage(Message msg) {
|
|
|
|
|
+ final NakedPorcelainActivity activity = (NakedPorcelainActivity) mActivity.get();
|
|
|
|
|
+ switch (msg.what) {
|
|
|
|
|
+
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+
|
|
|
|
|
+ if (activity.adapter == null) {
|
|
|
|
|
+ activity.adapter = new NakedPorcelainAdapter(activity, activity.npList);
|
|
|
|
|
+ activity.mListView.setAdapter(activity.adapter);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ activity.adapter.notifyDataSetChanged();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ activity.btnMakeBillet.setText("保存(" + activity.npList.size() + ")");
|
|
|
|
|
+
|
|
|
|
|
+ activity.barcode.setEnabled(true);
|
|
|
|
|
+ activity.barcode.setText("");
|
|
|
|
|
+ activity.barcode.setFocusable(true);
|
|
|
|
|
+ activity.barcode.setFocusableInTouchMode(true);
|
|
|
|
|
+ activity.barcode.requestFocus();
|
|
|
|
|
+ activity.barcode.findFocus();
|
|
|
|
|
+ activity.barcode.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
|
|
|
|
|
+ int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+ CommonUtil.BarcodeMaxLength(activity.barcode, 50);
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ case 2:
|
|
|
|
|
+
|
|
|
|
|
+ String rest8 = msg.getData().getString("result");
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+ activity.btnMakeBillet.setEnabled(true);
|
|
|
|
|
+ if (activity.mHandler != null) {
|
|
|
|
|
+ activity.mHandler.removeCallbacksAndMessages(null);
|
|
|
|
|
+ activity.mHandler.getLooper().quit();
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ JSONObject jsonObject4 = new JSONObject(rest8);
|
|
|
|
|
+ JSONObject jsonObject5 = jsonObject4.getJSONObject("d");
|
|
|
|
|
+ int status8 = jsonObject5.getInt("Status");
|
|
|
|
|
+ String message8 = jsonObject5.getString("Message");
|
|
|
|
|
+ if (status8 == 0) {
|
|
|
|
|
+ activity.barcode.setEnabled(true);
|
|
|
|
|
+ activity.barcode.setText("");
|
|
|
|
|
+ activity.barcode.setFocusable(true);
|
|
|
|
|
+ activity.barcode.setFocusableInTouchMode(true);
|
|
|
|
|
+ activity.barcode.requestFocus();
|
|
|
|
|
+ activity.barcode.findFocus();
|
|
|
|
|
+ activity.barcode.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
|
|
|
|
|
+ int dstart, int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+ CommonUtil.BarcodeMaxLength(activity.barcode, 50);
|
|
|
|
|
+
|
|
|
|
|
+ CommonUtil.playSound(activity.getApplicationContext());
|
|
|
|
|
+ CustomToast.showToast(activity.getApplicationContext(), "上传成功", 2000);
|
|
|
|
|
+
|
|
|
|
|
+ if (activity.npList != null && activity.npList.size() > 0) {
|
|
|
|
|
+ activity.npList.clear();
|
|
|
|
|
+ if (activity.adapter != null) {
|
|
|
|
|
+ activity.adapter.notifyDataSetChanged();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ activity.btnMakeBillet.setText("保存(" + activity.npList.size() + ")");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ else {
|
|
|
|
|
+
|
|
|
|
|
+ CommonUtil.setDefault(Notification.DEFAULT_VIBRATE, activity.getApplicationContext());
|
|
|
|
|
+ CommonUtil.showSaveAlertDialog(status8, message8, activity, activity.worknoEdt,
|
|
|
|
|
+ activity.barcode, 2);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ private class BarcodeRunnable implements Runnable {
|
|
|
|
|
+ String barcode;
|
|
|
|
|
+ Object obj;
|
|
|
|
|
+
|
|
|
|
|
+ public BarcodeRunnable(String barcode, Object obj) {
|
|
|
|
|
+ this.barcode = barcode;
|
|
|
|
|
+ this.obj = obj;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void run() {
|
|
|
|
|
+ synchronized (obj) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ jsonObject.put("accountCode", accountCode);
|
|
|
|
|
+ jsonObject.put("userCode", checkCollectModify_userCode);
|
|
|
|
|
+ jsonObject.put("userPassword", password);
|
|
|
|
|
+ jsonObject.put("sessionKey", sessionkey);
|
|
|
|
|
+ jsonObject.put("module", "LuociRevoke");
|
|
|
|
|
+ jsonObject.put("action", "CheckLuoci");
|
|
|
|
|
+ JSONObject jsonData = new JSONObject();
|
|
|
|
|
+ jsonData.put("barcode", barcode);// 产品条码
|
|
|
|
|
+ jsonObject.put("jsonData", jsonData.toString());
|
|
|
|
|
+ String result = client.doPost("http://" + ServerAddress_ip + ":" + ServerAddress_duankou
|
|
|
|
|
+ + Constants.serverAction + "/DoAction", jsonObject.toString(), "application/json");
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject jsonObjectR = new JSONObject(result);
|
|
|
|
|
+ JSONObject jsonObjectResult = jsonObjectR.getJSONObject("d");
|
|
|
|
|
+ int status30 = jsonObjectResult.getInt("Status");
|
|
|
|
|
+ String message30 = jsonObjectResult.getString("Message");
|
|
|
|
|
+
|
|
|
|
|
+ if (status30 == 0) {
|
|
|
|
|
+ String result30 = jsonObjectResult.getString("Result");
|
|
|
|
|
+ JSONArray jsonArray30 = new JSONArray(result30);
|
|
|
|
|
+ JSONObject jsonObject31 = (JSONObject) jsonArray30.get(0);
|
|
|
|
|
+ NakedPorcelain nakedPorcelain = new NakedPorcelain();
|
|
|
|
|
+ nakedPorcelain.setUserId(Integer.parseInt(userId));
|
|
|
|
|
+ nakedPorcelain.setBarcode(jsonObject31.optString("BARCODE"));
|
|
|
|
|
+ nakedPorcelain.setProductionCode(jsonObject31.optString("GOODSCODE"));
|
|
|
|
|
+ nakedPorcelain.setProductionName(jsonObject31.optString("GOODSNAME"));
|
|
|
|
|
+ nakedPorcelain.setLogonName(jsonObject31.optString("LOGONAME"));
|
|
|
|
|
+ nakedPorcelain.setGroutingUserCode(jsonObject31.optString("GROUTINGUSERCODE"));
|
|
|
|
|
+ nakedPorcelain.setMaterialCode(jsonObject31.optString("MATERIALCODE"));
|
|
|
|
|
+ npList.add(nakedPorcelain);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ else {
|
|
|
|
|
+ Message m = new Message();
|
|
|
|
|
+ m.what = 0;
|
|
|
|
|
+ Bundle b = new Bundle();
|
|
|
|
|
+ b.putInt("status", status30);
|
|
|
|
|
+ b.putString("errorMsg", message30);
|
|
|
|
|
+ m.setData(b);
|
|
|
|
|
+ exceptionHandler.sendMessage(m);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ handler.sendEmptyMessage(1);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ Message m = new Message();
|
|
|
|
|
+ m.what = 2;
|
|
|
|
|
+ Bundle b4 = new Bundle();
|
|
|
|
|
+ b4.putString("message", "网络连接异常");
|
|
|
|
|
+ m.setData(b4);
|
|
|
|
|
+ exceptionHandler.sendMessage(m);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ @SuppressWarnings("unchecked")
|
|
|
|
|
+ @Override
|
|
|
|
|
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
|
|
|
+
|
|
|
|
|
+ if (requestCode == 101 && resultCode == 103) {
|
|
|
|
|
+ barcode.setEnabled(true);
|
|
|
|
|
+ barcode.setText("");
|
|
|
|
|
+ barcode.setFocusable(true);
|
|
|
|
|
+ barcode.setFocusableInTouchMode(true);
|
|
|
|
|
+ barcode.requestFocus();
|
|
|
|
|
+ barcode.findFocus();
|
|
|
|
|
+ barcode.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
|
|
|
|
|
+ int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+ CommonUtil.BarcodeMaxLength(barcode, 50);
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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();
|
|
|
|
|
+ int id = v.getId();
|
|
|
|
|
+ v.setText(scanResult);
|
|
|
|
|
+ v.setSelection(scanResult.length());
|
|
|
|
|
+ switch (id) {
|
|
|
|
|
+
|
|
|
|
|
+ case R.id.bar_code:
|
|
|
|
|
+ String worknocode = worknoEdt.getText().toString();
|
|
|
|
|
+ if (TextUtils.isEmpty(worknocode)) {
|
|
|
|
|
+ // Toast.makeText(getApplicationContext(), "生产工号不能为空",
|
|
|
|
|
+ // Toast.LENGTH_SHORT).show();
|
|
|
|
|
+ CustomToast.showToast(getApplicationContext(), "生产工号不能为空", 2000);
|
|
|
|
|
+ worknoEdt.setEnabled(true);
|
|
|
|
|
+ worknoEdt.setFocusable(true);
|
|
|
|
|
+ worknoEdt.setFocusableInTouchMode(true);
|
|
|
|
|
+ worknoEdt.requestFocus();
|
|
|
|
|
+ worknoEdt.findFocus();
|
|
|
|
|
+ worknoEdt.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
|
|
|
|
|
+ int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+ return;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (!worknovalid) {
|
|
|
|
|
+ // Toast.makeText(getApplicationContext(), "请先验证生产工号",
|
|
|
|
|
+ // Toast.LENGTH_SHORT).show();
|
|
|
|
|
+ CustomToast.showToast(getApplicationContext(), "请先验证生产工号", 2000);
|
|
|
|
|
+ worknoEdt.setEnabled(true);
|
|
|
|
|
+ worknoEdt.setFocusable(true);
|
|
|
|
|
+ worknoEdt.setFocusableInTouchMode(true);
|
|
|
|
|
+ worknoEdt.requestFocus();
|
|
|
|
|
+ worknoEdt.findFocus();
|
|
|
|
|
+ worknoEdt.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest,
|
|
|
|
|
+ int dstart, int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+ return;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ String code = v.getText().toString().trim();
|
|
|
|
|
+ ProcessDialogUtils.showProcessDialog(NakedPorcelainActivity.this);
|
|
|
|
|
+ if (!CommonUtil.isNumber(code)) {
|
|
|
|
|
+ ProcessDialogUtils.closeProgressDilog();
|
|
|
|
|
+ // CommonUtil.showRepeatDialog(code+"格式不匹配",CheckCollectModifyActivity.this);
|
|
|
|
|
+ // Toast.makeText(getApplicationContext(), code + "格式不匹配",
|
|
|
|
|
+ // Toast.LENGTH_SHORT).show();
|
|
|
|
|
+ CustomToast.showToast(getApplicationContext(), code + "格式不匹配", 2000);
|
|
|
|
|
+ barcode.setEnabled(true);
|
|
|
|
|
+ barcode.setText("");
|
|
|
|
|
+ barcode.setFocusable(true);
|
|
|
|
|
+ barcode.setFocusableInTouchMode(true);
|
|
|
|
|
+ barcode.requestFocus();
|
|
|
|
|
+ barcode.findFocus();
|
|
|
|
|
+ barcode.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
|
|
|
|
|
+ int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+ CommonUtil.BarcodeMaxLength(barcode, 50);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ barcode.setEnabled(false);
|
|
|
|
|
+ barcode.setFocusable(false);
|
|
|
|
|
+ barcode.setFilters(new InputFilter[] { new InputFilter() {
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
|
|
|
|
|
+ int dend) {
|
|
|
|
|
+
|
|
|
|
|
+ return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
|
|
|
|
|
+ }
|
|
|
|
|
+ } });
|
|
|
|
|
+
|
|
|
|
|
+ thread = new HandlerThread("barcodeThread", 5);
|
|
|
|
|
+ thread.start();
|
|
|
|
|
+ mHandler = new Handler(thread.getLooper());
|
|
|
|
|
+ BarcodeRunnable barcodeRunnable = new BarcodeRunnable(code, obj);
|
|
|
|
|
+ mHandler.post(barcodeRunnable);
|
|
|
|
|
+
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onBackPressed() {
|
|
|
|
|
+ super.onBackPressed();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Resources getResources() {
|
|
|
|
|
+ Resources res = super.getResources();
|
|
|
|
|
+ Configuration config = new Configuration();
|
|
|
|
|
+ config.setToDefaults();
|
|
|
|
|
+ res.updateConfiguration(config, res.getDisplayMetrics());
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|