LuociRevokeActivity.java 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627
  1. package com.jiaju.activity;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import org.json.JSONArray;
  5. import org.json.JSONException;
  6. import org.json.JSONObject;
  7. import com.jiaju.adapter.CancelFinishedProductHandOverAdapter;
  8. import com.jiaju.model.BarcodeInfo;
  9. import com.jiaju.net.WebClient;
  10. import com.jiaju.utils.CommonUtil;
  11. import com.jiaju.utils.Constants;
  12. import com.jiaju.utils.ProcessDialogUtils;
  13. import com.jiaju.utils.Removeduplicate;
  14. import android.app.Activity;
  15. import android.app.Notification;
  16. import android.content.Context;
  17. import android.content.SharedPreferences;
  18. import android.os.Bundle;
  19. import android.os.Handler;
  20. import android.os.HandlerThread;
  21. import android.os.Message;
  22. import android.text.Editable;
  23. import android.text.InputFilter;
  24. import android.text.InputType;
  25. import android.text.Spanned;
  26. import android.text.TextUtils;
  27. import android.text.TextWatcher;
  28. import android.view.KeyEvent;
  29. import android.view.Menu;
  30. import android.view.View;
  31. import android.view.View.OnClickListener;
  32. import android.view.inputmethod.EditorInfo;
  33. import android.view.inputmethod.InputMethodManager;
  34. import android.widget.Button;
  35. import android.widget.EditText;
  36. import android.widget.ImageButton;
  37. import android.widget.ListView;
  38. import android.widget.TextView;
  39. import android.widget.Toast;
  40. //裸辞交接 撤销
  41. public class LuociRevokeActivity extends Activity {
  42. private TextView title;
  43. private EditText barcodeEdt;
  44. private String accountCode;
  45. private String cancelPacking_userCode;
  46. private String password;
  47. private String sessionkey;
  48. private SharedPreferences preferences;
  49. private String ServerAddress_ip;
  50. private String ServerAddress_duankou;
  51. private HandlerThread thread;
  52. private Handler mHandler;
  53. private WebClient client = null;
  54. private TextView backtext;
  55. private ImageButton backbtn;
  56. private Object obj = new Object();
  57. private List<BarcodeInfo> barcodeList;
  58. private CancelFinishedProductHandOverAdapter adapter = null;
  59. private ListView cancellstview;
  60. private Button saveBtn;
  61. private String procedureName;
  62. private Handler barcodeUpperH = new Handler();
  63. private String barcodeUpper;
  64. @Override
  65. protected void onCreate(Bundle savedInstanceState) {
  66. super.onCreate(savedInstanceState);
  67. setContentView(R.layout.activity_cancel_finished_product_hand_over);
  68. initView();
  69. preferences = getSharedPreferences("user", Context.MODE_PRIVATE);
  70. ServerAddress_ip = preferences.getString("ServerAddress_ip", "");
  71. ServerAddress_duankou = preferences.getString("ServerAddress_duankou",
  72. "");
  73. accountCode = preferences.getString("AccountCode", "");
  74. cancelPacking_userCode = preferences.getString("UserCode", "");
  75. password = preferences.getString("UserPassword", "");
  76. sessionkey = preferences.getString("SessionKey", "");
  77. Bundle b = getIntent().getExtras();
  78. procedureName = b.getString("title");
  79. title.setText(procedureName);
  80. CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
  81. barcodeList = new ArrayList<BarcodeInfo>();
  82. allListeners();
  83. }
  84. public void initView() {
  85. title = (TextView) findViewById(R.id.title);
  86. barcodeEdt = (EditText) findViewById(R.id.barcodeEdt);
  87. barcodeEdt.setRawInputType(InputType.TYPE_CLASS_NUMBER);
  88. backbtn = (ImageButton) findViewById(R.id.left_img);
  89. backtext = (TextView) findViewById(R.id.back);
  90. cancellstview = (ListView) findViewById(R.id.cancel_listview);
  91. saveBtn = (Button) findViewById(R.id.saveBtn);
  92. }
  93. public void allListeners() {
  94. saveBtn.setOnClickListener(new View.OnClickListener() {
  95. @Override
  96. public void onClick(View v) {
  97. if (barcodeList == null) {
  98. Toast.makeText(getApplicationContext(), "条码信息不能为空",
  99. Toast.LENGTH_SHORT).show();
  100. return;
  101. } else {
  102. if (barcodeList.size() == 0) {
  103. Toast.makeText(getApplicationContext(), "条码信息不能为空",
  104. Toast.LENGTH_SHORT).show();
  105. return;
  106. }
  107. BarcodeInfo info = barcodeList.get(0);
  108. String barcode = info.getBarcode();
  109. ProcessDialogUtils.showProcessDialog(
  110. LuociRevokeActivity.this);
  111. if (saveBtn.isEnabled()) {
  112. saveBtn.setEnabled(false);
  113. thread = new HandlerThread("saveThread", 5);
  114. thread.start();
  115. mHandler = new Handler(thread.getLooper());
  116. SaveRunnable saveRunnable = new SaveRunnable(barcode,
  117. obj);
  118. mHandler.post(saveRunnable);
  119. }
  120. }
  121. }
  122. });
  123. backtext.setOnClickListener(new OnClickListener() {
  124. @Override
  125. public void onClick(View v) {
  126. finish();
  127. }
  128. });
  129. backbtn.setOnClickListener(new View.OnClickListener() {
  130. @Override
  131. public void onClick(View v) {
  132. finish();
  133. }
  134. });
  135. barcodeEdt.addTextChangedListener(new TextWatcher() {
  136. @Override
  137. public void afterTextChanged(Editable arg0) {
  138. }
  139. @Override
  140. public void beforeTextChanged(CharSequence s, int start, int count,
  141. int after) {
  142. }
  143. @Override
  144. public void onTextChanged(CharSequence s, int start, int before,
  145. int count) {
  146. barcodeUpper = barcodeEdt.getText().toString().trim();
  147. // 判断输入的文字是否是小写
  148. for (int i = 0; i < barcodeUpper.length(); i++) {
  149. if (barcodeUpper.charAt(i) - 0 >= 97
  150. && barcodeUpper.charAt(i) - 0 <= 122) {
  151. barcodeUpperH.postDelayed(UpperCase, 300);
  152. }
  153. }
  154. if (start == 0 && before == 0 && count > 1) {
  155. String barcode = barcodeEdt.getText().toString().trim();
  156. if (!TextUtils.isEmpty(barcode)) {
  157. if (barcodeList.size() > 0) {
  158. boolean b = Removeduplicate.removeBarCode(barcode,
  159. barcodeList);
  160. if (b) {
  161. barcodeEdt.setText("");
  162. barcodeEdt.setFocusable(true);
  163. barcodeEdt.requestFocus();
  164. CommonUtil.setDefault(
  165. Notification.DEFAULT_VIBRATE,
  166. getApplicationContext());
  167. Toast.makeText(getApplicationContext(),
  168. "条码" + barcode + "重复",
  169. Toast.LENGTH_SHORT).show();
  170. return;
  171. }
  172. }
  173. if (barcodeList != null && barcodeList.size() > 0) {
  174. barcodeList.removeAll(barcodeList);
  175. if (adapter != null) {
  176. adapter.notifyDataSetChanged();
  177. }
  178. }
  179. ProcessDialogUtils.showProcessDialog(
  180. LuociRevokeActivity.this);
  181. barcodeEdt.setEnabled(false);
  182. barcodeEdt.setFocusable(false);
  183. barcodeEdt.setFilters(
  184. new InputFilter[]{new InputFilter() {
  185. @Override
  186. public CharSequence filter(
  187. CharSequence source, int start,
  188. int end, Spanned dest, int dstart,
  189. int dend) {
  190. return source.length() < 1
  191. ? dest.subSequence(dstart, dend)
  192. : "";
  193. }
  194. }});
  195. thread = new HandlerThread("barcodeThread", 5);
  196. thread.start();
  197. mHandler = new Handler(thread.getLooper());
  198. BarcodeRunnable barcodeRunnable = new BarcodeRunnable(
  199. barcode, obj);
  200. mHandler.post(barcodeRunnable);
  201. }
  202. }
  203. }
  204. });
  205. barcodeEdt.setOnEditorActionListener(
  206. new TextView.OnEditorActionListener() {
  207. @Override
  208. public boolean onEditorAction(TextView v, int actionId,
  209. KeyEvent event) {
  210. if (actionId == EditorInfo.IME_ACTION_GO) {
  211. String barcode = barcodeEdt.getText().toString();
  212. if (!TextUtils.isEmpty(barcode)) {
  213. if (barcodeList.size() > 0) {
  214. boolean b = Removeduplicate.removeBarCode(
  215. barcode, barcodeList);
  216. if (b) {
  217. barcodeEdt.setText("");
  218. barcodeEdt.setFocusable(true);
  219. barcodeEdt.requestFocus();
  220. CommonUtil.setDefault(
  221. Notification.DEFAULT_VIBRATE,
  222. getApplicationContext());
  223. Toast.makeText(getApplicationContext(),
  224. "条码" + barcode + "重复",
  225. Toast.LENGTH_SHORT).show();
  226. return true;
  227. }
  228. }
  229. if (barcodeList != null
  230. && barcodeList.size() > 0) {
  231. barcodeList.removeAll(barcodeList);
  232. if (adapter != null) {
  233. adapter.notifyDataSetChanged();
  234. }
  235. }
  236. ProcessDialogUtils.showProcessDialog(
  237. LuociRevokeActivity.this);
  238. barcodeEdt.setEnabled(false);
  239. barcodeEdt.setFocusable(false);
  240. barcodeEdt.setFilters(
  241. new InputFilter[]{new InputFilter() {
  242. @Override
  243. public CharSequence filter(
  244. CharSequence source,
  245. int start, int end,
  246. Spanned dest, int dstart,
  247. int dend) {
  248. return source.length() < 1
  249. ? dest.subSequence(
  250. dstart, dend)
  251. : "";
  252. }
  253. }});
  254. thread = new HandlerThread("barcodeThread", 5);
  255. thread.start();
  256. mHandler = new Handler(thread.getLooper());
  257. BarcodeRunnable barcodeRunnable = new BarcodeRunnable(
  258. barcode, obj);
  259. mHandler.post(barcodeRunnable);
  260. return true;
  261. } else {
  262. Toast.makeText(getApplicationContext(),
  263. "产品条码不能为空", Toast.LENGTH_SHORT).show();
  264. return true;
  265. }
  266. }
  267. return false;
  268. }
  269. });
  270. }
  271. Runnable BarcodeUpperCase = new Runnable() {
  272. @Override
  273. public void run() {
  274. // 小写转大写
  275. barcodeEdt.setText(barcodeUpper.toUpperCase());
  276. // 设置EditText光标位置
  277. barcodeEdt.setSelection(barcodeUpper.length());
  278. }
  279. };
  280. Runnable UpperCase = new Runnable() {
  281. @Override
  282. public void run() {
  283. // 小写转大写
  284. barcodeEdt.setText(barcodeUpper.toUpperCase());
  285. // 设置EditText光标位置
  286. barcodeEdt.setSelection(barcodeUpper.length());
  287. }
  288. };
  289. Handler h = new Handler() {
  290. @Override
  291. public void handleMessage(Message msg) {
  292. switch (msg.what) {
  293. case 0 :
  294. Bundle b1 = msg.getData();
  295. String json1 = b1.getString("barcodeResult");
  296. ProcessDialogUtils.closeProgressDilog();
  297. try {
  298. JSONObject jo2 = new JSONObject(json1);
  299. JSONObject jo3 = jo2.optJSONObject("d");
  300. int status = jo3.optInt("Status");
  301. String message = jo3.optString("Message");
  302. if (status == 0) {
  303. String result = jo3.optString("Result");
  304. JSONObject resultObj = new JSONObject(result);
  305. JSONArray jarray = resultObj.optJSONArray("Table");
  306. if (jarray != null && jarray.length() > 0) {
  307. for (int i = 0; i < jarray.length(); i++) {
  308. JSONObject jo = jarray.optJSONObject(i);
  309. String orderNo = jo.optString("ORDERNO");
  310. String goodsCode = jo
  311. .optString("GOODSCODE");
  312. String groutingUserCode = jo
  313. .optString("GROUTINGUSERCODE");
  314. int logoId = jo.optInt("LOGOID");
  315. String logoCode = jo.optString("LOGOCODE");
  316. String logoName = jo.optString("LOGONAME");
  317. String barcode = jo.optString("BARCODE");
  318. String finishedBarcode = jo
  319. .optString("FINISHEDBARCODE");
  320. String groutingDate = jo
  321. .optString("GROUTINGDATE");
  322. String billetDate = jo
  323. .optString("DELIVERTIME");
  324. String mouldCode = jo
  325. .optString("GROUTINGMOULDCODE");
  326. BarcodeInfo info = new BarcodeInfo();
  327. info.setBarcode(barcode);
  328. info.setFinishedBarCode(finishedBarcode);
  329. info.setOrderNo(orderNo);
  330. info.setGoodsCode(goodsCode);
  331. info.setUserCode(groutingUserCode);
  332. info.setLogoId(logoId);
  333. info.setLogoCode(logoCode);
  334. info.setLogoName(logoName);
  335. info.setBanMa(
  336. (jo.optString("BANMA") == "null")
  337. ? ""
  338. : jo.optString("BANMA"));
  339. if (!TextUtils.isEmpty(groutingDate)) {
  340. if (groutingDate.contains("/")) {
  341. groutingDate = CommonUtil
  342. .dateStringConverter(
  343. groutingDate);
  344. } else if (groutingDate.contains("-")) {
  345. groutingDate = CommonUtil
  346. .commonDateConverter(
  347. groutingDate);
  348. }
  349. info.setGroutingDate(groutingDate);
  350. } else {
  351. info.setGroutingDate("");
  352. }
  353. if (!TextUtils.isEmpty(billetDate)) {
  354. if (billetDate.contains("/")) {
  355. billetDate = CommonUtil
  356. .dateStringConverter(
  357. billetDate);
  358. } else if (billetDate.contains("-")) {
  359. billetDate = CommonUtil
  360. .commonDateConverter(
  361. billetDate);
  362. }
  363. info.setDeliverTime(billetDate);
  364. } else {
  365. info.setDeliverTime("");
  366. }
  367. info.setMouldCode(mouldCode);
  368. barcodeList.add(info);
  369. }
  370. adapter = new CancelFinishedProductHandOverAdapter(
  371. LuociRevokeActivity.this,
  372. barcodeList);
  373. cancellstview.setAdapter(adapter);
  374. saveBtn.setText(
  375. "保存(" + barcodeList.size() + ")");
  376. } else {
  377. Toast.makeText(getApplicationContext(),
  378. "此条码不存在", Toast.LENGTH_SHORT).show();
  379. }
  380. barcodeEdt.setEnabled(true);
  381. barcodeEdt.setText("");
  382. barcodeEdt.setFocusable(true);
  383. barcodeEdt.setFocusableInTouchMode(true);
  384. barcodeEdt.requestFocus();
  385. barcodeEdt.findFocus();
  386. barcodeEdt.setFilters(
  387. new InputFilter[]{new InputFilter() {
  388. @Override
  389. public CharSequence filter(
  390. CharSequence source, int start,
  391. int end, Spanned dest,
  392. int dstart, int dend) {
  393. return null;
  394. }
  395. }});
  396. CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
  397. } else {
  398. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
  399. getApplicationContext());
  400. CommonUtil.showBarCodeAlertDialog(status, message,
  401. LuociRevokeActivity.this,
  402. barcodeEdt, null, null);
  403. }
  404. if (mHandler != null) {
  405. mHandler.removeCallbacksAndMessages(null);
  406. mHandler.getLooper().quit();
  407. }
  408. } catch (JSONException e1) {
  409. e1.printStackTrace();
  410. Toast.makeText(getApplicationContext(), "json数据异常",
  411. Toast.LENGTH_SHORT).show();
  412. }
  413. break;
  414. case 1 :
  415. Bundle b = msg.getData();
  416. String json = b.getString("saveResult");
  417. ProcessDialogUtils.closeProgressDilog();
  418. if (mHandler != null) {
  419. mHandler.removeCallbacksAndMessages(null);
  420. mHandler.getLooper().quit();
  421. }
  422. saveBtn.setEnabled(true);
  423. try {
  424. JSONObject jo = new JSONObject(json);
  425. JSONObject jo1 = jo.optJSONObject("d");
  426. int status = jo1.optInt("Status");
  427. String message = jo1.optString("Message");
  428. if (barcodeList != null && barcodeList.size() > 0) {
  429. barcodeList.removeAll(barcodeList);
  430. if (adapter != null) {
  431. adapter.notifyDataSetChanged();
  432. }
  433. }
  434. saveBtn.setText("保存(" + barcodeList.size() + ")");
  435. if (status == 0) {
  436. barcodeEdt.setEnabled(true);
  437. barcodeEdt.setText("");
  438. barcodeEdt.setFocusable(true);
  439. barcodeEdt.setFocusableInTouchMode(true);
  440. barcodeEdt.requestFocus();
  441. barcodeEdt.findFocus();
  442. barcodeEdt.setFilters(
  443. new InputFilter[]{new InputFilter() {
  444. @Override
  445. public CharSequence filter(
  446. CharSequence source, int start,
  447. int end, Spanned dest,
  448. int dstart, int dend) {
  449. return null;
  450. }
  451. }});
  452. CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
  453. InputMethodManager im = (InputMethodManager) barcodeEdt
  454. .getContext().getSystemService(
  455. Context.INPUT_METHOD_SERVICE);
  456. im.hideSoftInputFromWindow(
  457. LuociRevokeActivity.this
  458. .getCurrentFocus().getWindowToken(),
  459. InputMethodManager.HIDE_NOT_ALWAYS);
  460. Toast.makeText(getApplicationContext(), "上传成功",
  461. Toast.LENGTH_SHORT).show();
  462. CommonUtil.playSound(getApplicationContext());
  463. } else {
  464. CommonUtil.showBarCodeAlertDialog(status, message,
  465. LuociRevokeActivity.this,
  466. barcodeEdt, null, null);
  467. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
  468. getApplicationContext());
  469. }
  470. } catch (JSONException e) {
  471. e.printStackTrace();
  472. Toast.makeText(getApplicationContext(), "json数据异常",
  473. Toast.LENGTH_SHORT).show();
  474. }
  475. break;
  476. }
  477. }
  478. };
  479. private Handler exceptionHandler = new Handler() {
  480. @Override
  481. public void handleMessage(Message msg) {
  482. super.handleMessage(msg);
  483. switch (msg.what) {
  484. case 0 :
  485. ProcessDialogUtils.closeProgressDilog();
  486. saveBtn.setEnabled(true);
  487. if (mHandler != null) {
  488. mHandler.removeCallbacksAndMessages(null);
  489. mHandler.getLooper().quit();
  490. }
  491. Bundle b = msg.getData();
  492. String message = b.getString("message");
  493. CommonUtil.setDefault(Notification.DEFAULT_VIBRATE,
  494. getApplicationContext());
  495. Toast.makeText(getApplicationContext(), message,
  496. Toast.LENGTH_SHORT).show();
  497. barcodeEdt.setEnabled(true);
  498. barcodeEdt.setText("");
  499. barcodeEdt.setFocusable(true);
  500. barcodeEdt.setFocusableInTouchMode(true);
  501. barcodeEdt.requestFocus();
  502. barcodeEdt.findFocus();
  503. barcodeEdt.setFilters(new InputFilter[]{new InputFilter() {
  504. @Override
  505. public CharSequence filter(CharSequence source,
  506. int start, int end, Spanned dest, int dstart,
  507. int dend) {
  508. return null;
  509. }
  510. }});
  511. CommonUtil.BarcodeMaxLength(barcodeEdt, 50);
  512. break;
  513. }
  514. }
  515. };
  516. public class SaveRunnable implements Runnable {
  517. String barcode;
  518. Object obj;
  519. public SaveRunnable(String barcode, Object obj) {
  520. this.barcode = barcode;
  521. this.obj = obj;
  522. }
  523. @Override
  524. public void run() {
  525. synchronized (obj) {
  526. try {
  527. client = new WebClient();
  528. JSONObject js = new JSONObject();
  529. js.put("accountCode", accountCode);
  530. js.put("userCode", cancelPacking_userCode);
  531. js.put("userPassword", password);
  532. js.put("sessionKey", sessionkey);
  533. js.put("module", "LCFinishedProduct");
  534. js.put("action", "LCBackFinishedHandover");
  535. JSONArray barcodeArray = new JSONArray();
  536. for (int i = 0; i < barcodeList.size(); i++) {
  537. BarcodeInfo barcodeInfo = barcodeList.get(i);
  538. JSONObject jobj = new JSONObject();
  539. jobj.put("BarCode", barcodeInfo.getBarcode());
  540. jobj.put("GoodsModel", barcodeInfo.getGoodsCode());
  541. jobj.put("logoID", barcodeInfo.getLogoId());
  542. jobj.put("LogoName", barcodeInfo.getLogoName());
  543. barcodeArray.put(jobj);
  544. }
  545. JSONObject data = new JSONObject();
  546. data.put("Table", barcodeArray);
  547. js.put("jsonData", data.toString());
  548. String result = client.doPost(
  549. "http://" + ServerAddress_ip + ":"
  550. + ServerAddress_duankou
  551. + Constants.serverAction + "/DoAction",
  552. js.toString(), "application/json");
  553. Message m = new Message();
  554. m.what = 1;
  555. Bundle b = new Bundle();
  556. b.putString("saveResult", result);
  557. m.setData(b);
  558. h.sendMessage(m);
  559. } catch (Exception e) {
  560. e.printStackTrace();
  561. Message m = new Message();
  562. m.what = 0;
  563. Bundle b = new Bundle();
  564. b.putString("message", "网络连接异常");
  565. m.setData(b);
  566. exceptionHandler.sendMessage(m);
  567. return;
  568. }
  569. }
  570. }
  571. };
  572. public class BarcodeRunnable implements Runnable {
  573. String barcode;
  574. Object obj;
  575. public BarcodeRunnable(String barcode, Object obj) {
  576. this.barcode = barcode;
  577. this.obj = obj;
  578. }
  579. @Override
  580. public void run() {
  581. synchronized (obj) {
  582. try {
  583. client = new WebClient();
  584. JSONObject js = new JSONObject();
  585. js.put("accountCode", accountCode);
  586. js.put("userCode", cancelPacking_userCode);
  587. js.put("userPassword", password);
  588. js.put("sessionKey", sessionkey);
  589. js.put("module", "LCFinishedProduct");
  590. js.put("action", "LCBackFinishedHandoverCheck");
  591. JSONObject data = new JSONObject();
  592. data.put("Barcode", barcode);
  593. js.put("jsonData", data.toString());
  594. String result = client.doPost(
  595. "http://" + ServerAddress_ip + ":"
  596. + ServerAddress_duankou
  597. + Constants.serverAction + "/DoAction",
  598. js.toString(), "application/json");
  599. Message m = new Message();
  600. m.what = 0;
  601. Bundle b = new Bundle();
  602. b.putString("barcodeResult", result);
  603. m.setData(b);
  604. h.sendMessage(m);
  605. } catch (Exception e) {
  606. e.printStackTrace();
  607. Message m = new Message();
  608. m.what = 0;
  609. Bundle b = new Bundle();
  610. b.putString("message", "网络连接异常");
  611. m.setData(b);
  612. exceptionHandler.sendMessage(m);
  613. return;
  614. }
  615. }
  616. }
  617. };
  618. @Override
  619. public boolean onCreateOptionsMenu(Menu menu) {
  620. // Inflate the menu; this adds items to the action bar if it is present.
  621. getMenuInflater().inflate(R.menu.cancel_packing, menu);
  622. return true;
  623. }
  624. }