| | |
| | | import com.dayu.recharge.utils.MornyUtil; |
| | | import com.dayu.recharge.utils.SocketUtil; |
| | | import com.dayu.recharge.utils.TipUtil; |
| | | import com.dayu.recharge.view.ProgressDialog; |
| | | import com.tencent.bugly.crashreport.CrashReport; |
| | | |
| | | import java.util.Arrays; |
| | |
| | | this.intent = intent; |
| | | userCard = NfcReadHelper.getInstence(intent).getUserCardData(); |
| | | if (userCard != null) { |
| | | |
| | | ProgressDialog.show(this); |
| | | selectBalance(userCard.getInitPeasantCode()); |
| | | } else { |
| | | TipUtil.show(RechargeActivity.this, "卡片读取失败"); |
| | | } |
| | | |
| | | readAllData(intent); |
| | | // readAllData(intent); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | CrashReport.postCatchedException(e); |
| | |
| | | SocketNet.getInstance().sendTestMessage(requestBean.pack(), new SocketCallBack() { |
| | | @Override |
| | | public void onSocketResponse(SocketData readData) { |
| | | ProgressDialog.dismiss(); |
| | | if (CRC8.isCRC8(readData.getOriginDataBytes())) { |
| | | StringBuffer stateText = null; |
| | | try { |
| | |
| | | //姓名 |
| | | byte[] nameByte = Arrays.copyOfRange(readData.getBodyBytes(), 7, 19); |
| | | userName = SocketUtil.fromHexString(SocketUtil.bytesToHexClean0(nameByte)); |
| | | if ("00".equals(state)) { |
| | | stateText.append("启用"); |
| | | binding.rechargeReadLL.setVisibility(View.GONE); |
| | | binding.rechargeTextLL.setVisibility(View.VISIBLE); |
| | | binding.rechargeLL.setVisibility(View.VISIBLE); |
| | | binding.rechargeRegistBtn.setVisibility(View.VISIBLE); |
| | | binding.rechargeReadLL.setVisibility(View.GONE); |
| | | binding.rechargeTextLL.setVisibility(View.VISIBLE); |
| | | binding.userName.setText(userName); |
| | | binding.redRemainderBlance.setText(MornyUtil.changeF2Y(balance)); |
| | | binding.redStatu.setText(stateText.toString()); |
| | | binding.redInitCode.setText(initPeasantCode); |
| | | |
| | | binding.userName.setText(userName); |
| | | binding.redRemainderBlance.setText(MornyUtil.changeF2Y(balance)); |
| | | binding.redStatu.setText(stateText.toString()); |
| | | binding.redInitCode.setText(initPeasantCode); |
| | | if ("00".equals(state)) { |
| | | binding.rechargeRegistBtn.setVisibility(View.VISIBLE); |
| | | stateText.append("启用"); |
| | | userCard.setState("00"); |
| | | userCard.setBalance(balance); |
| | | binding.redStatu.setText(stateText.toString()); |
| | | return; |
| | | } else if ("01".equals(state)) { |
| | | stateText.append("禁用"); |
| | | stateText.append("该卡已被禁用"); |
| | | userCard.setState("01"); |
| | | userCard.setBalance(balance); |
| | | userFlag = WriteCardUtils.setUser(intent, userCard); |
| | | TipUtil.show("该卡已被禁用"); |
| | | } else if ("02".equals(state)) { |
| | | stateText.append("隶属信息不符"); |
| | | } else if ("03".equals(state)) { |
| | |
| | | } else if ("04".equals(state)) { |
| | | stateText.append("其它"); |
| | | } |
| | | binding.redStatu.setText(stateText.toString()); |
| | | binding.rechargeLL.setVisibility(View.GONE); |
| | | binding.rechargeRegistBtn.setVisibility(View.GONE); |
| | | binding.rechargeRegistBtn.setVisibility(View.GONE); |
| | | TipUtil.show(RechargeActivity.this, stateText.toString()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | |
| | | |
| | | @Override |
| | | public void onSocketError(int code, String msg) { |
| | | ProgressDialog.dismiss(); |
| | | TipUtil.show(RechargeActivity.this, msg); |
| | | } |
| | | }); |
| | |
| | | |
| | | } |
| | | |
| | | protected void onDestroy() { |
| | | super.onDestroy(); |
| | | rechargeActivity = null; |
| | | } |
| | | } |