| | |
| | | public boolean isConncet = false; |
| | | private final Timer timer = new Timer(); |
| | | |
| | | |
| | | @Override |
| | | public void onCreate() { |
| | | super.onCreate(); |
| | |
| | | isAidl = aidl; |
| | | } |
| | | |
| | | IpBean ipBean; |
| | | public IpBean ipBean; |
| | | |
| | | /** |
| | | * 初始化EasySocket |
| | |
| | | .setSocketAddress(new SocketAddress(ip, port)) |
| | | // 定义消息协议,方便解决 socket黏包、分包的问题 |
| | | .setReaderProtocol(new ScoketMessageProtocol()) |
| | | .setMaxWriteBytes(1024) |
| | | .setMaxReadBytes(1024) |
| | | .setRequestTimeout(10 * 1000) |
| | | .setMaxWriteBytes(150) |
| | | .setMaxReadBytes(150) |
| | | .setRequestTimeout(5 * 1000) |
| | | .build(); |
| | | |
| | | // 初始化 |
| | |
| | | super.onStart(); |
| | | //此处adapter需要重新获取,否则无法获取message |
| | | mNfcAdapter = NfcAdapter.getDefaultAdapter(this); |
| | | if (mNfcAdapter != null){ |
| | | mNfcAdapter.setNdefPushMessageCallback(new NfcAdapter.CreateNdefMessageCallback() { |
| | | @Override |
| | | public NdefMessage createNdefMessage(NfcEvent nfcEvent) { |
| | | // 在此处处理NFC消息的创建 |
| | | return null; |
| | | } |
| | | }, this); |
| | | |
| | | } |
| | | // mNfcAdapter.enableReaderMode(this, new NfcAdapter.ReaderCallback() { |
| | | // @Override |
| | | // public void onTagDiscovered(Tag tag) { |
| | |
| | | case 1: |
| | | TipUtil.show(MyActivity.this, "导出成功!"); |
| | | break; |
| | | case 3: |
| | | TipUtil.show(MyActivity.this, "记录为空!"); |
| | | break; |
| | | default: |
| | | TipUtil.show(MyActivity.this, "导出失败!"); |
| | | break; |
| | |
| | | } else { |
| | | listData = baseDao.userCardDao().findByTime(beginTime, endTime); |
| | | } |
| | | if (listData == null || listData.size() == 0) { |
| | | handler.sendEmptyMessage(2); |
| | | return; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | redCardBinding.redRemainderBlance.setText("剩余金额:" + MornyUtil.changeF2Y(blance) + "元"); |
| | | redCardBinding.redStatu.setText("卡状态:" + statu); |
| | | if (userCard != null) { |
| | | redCardBinding.redInitCode.setText("用户注册编号:" + userCard.getInitPeasantCode()); |
| | | redCardBinding.redInitCode.setText( userCard.getInitPeasantCode()); |
| | | Calendar calendar = userCard.getRechargeDate(); |
| | | if (calendar != null) { |
| | | int year = calendar.get(Calendar.YEAR); |
| | |
| | | |
| | | try { |
| | | stateText = new StringBuffer(); |
| | | //金额 |
| | | byte[] blanceByte = Arrays.copyOfRange(readData.getBodyBytes(), 3, 7); |
| | | int balance = SocketUtil.get16to10LowHigh(blanceByte); |
| | | //姓名 |
| | | byte[] nameByte = Arrays.copyOfRange(readData.getBodyBytes(), 7, 19); |
| | | String name = SocketUtil.fromHexString(SocketUtil.bytesToHexClean0(nameByte)); |
| | | int balance = 0; |
| | | String name = null; |
| | | try { |
| | | //金额 |
| | | byte[] blanceByte = Arrays.copyOfRange(readData.getBodyBytes(), 3, 7); |
| | | balance = SocketUtil.get16to10LowHigh(blanceByte); |
| | | //姓名 |
| | | byte[] nameByte = Arrays.copyOfRange(readData.getBodyBytes(), 7, 19); |
| | | name = SocketUtil.fromHexString(SocketUtil.bytesToHexClean0(nameByte)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | String state = BcdUtil.bcdToStr(readData.getBodyBytes()[2]); //BCD码00启用 01禁用 02隶属信息不符 03无此卡信息 04其它s |
| | | if ("00".equals(state)) { |
| | |
| | | String initCode = DeviceNumberUtils.getDeviceNumber(); |
| | | if (TextUtils.isEmpty(initCode)) { |
| | | TipUtil.show(RechargeActivity.this, "设备注册号为空,请先设置IP和管理员地址"); |
| | | return; |
| | | } |
| | | Intent intent = new Intent(RechargeActivity.this, NFCWreatActivity.class); |
| | | intent.putExtra("morny", morny); |
| | |
| | | try { |
| | | stateText = new StringBuffer(); |
| | | String state = BcdUtil.bcdToStr(readData.getBodyBytes()[2]); //BCD码00启用 01禁用 02隶属信息不符 03无此卡信息 04其它s |
| | | int balance = 0; |
| | | |
| | | //只有启动状态才能充值 |
| | | //金额 |
| | | byte[] blanceByte = Arrays.copyOfRange(readData.getBodyBytes(), 3, 7); |
| | | int balance = SocketUtil.get16to10LowHigh(blanceByte); |
| | | //姓名 |
| | | byte[] nameByte = Arrays.copyOfRange(readData.getBodyBytes(), 7, 19); |
| | | userName = SocketUtil.fromHexString(SocketUtil.bytesToHexClean0(nameByte)); |
| | | try { |
| | | //只有启动状态才能充值 |
| | | //金额 |
| | | byte[] blanceByte = Arrays.copyOfRange(readData.getBodyBytes(), 3, 7); |
| | | balance = SocketUtil.get16to10LowHigh(blanceByte); |
| | | //姓名 |
| | | byte[] nameByte = Arrays.copyOfRange(readData.getBodyBytes(), 7, 19); |
| | | userName = SocketUtil.fromHexString(SocketUtil.bytesToHexClean0(nameByte)); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | binding.rechargeLL.setVisibility(View.VISIBLE); |
| | | binding.rechargeRegistBtn.setVisibility(View.VISIBLE); |
| | | binding.rechargeReadLL.setVisibility(View.GONE); |
| | |
| | | private void setUserData(String userName, String statu) { |
| | | int balance = userCard.getBalance(); |
| | | if (!TextUtils.isEmpty(morny)) { |
| | | binding.tip.setText("充值成功!"); |
| | | balance = userCard.getBalance() + MornyUtil.changeY2F(morny); |
| | | binding.redRemainderMorny.setText("充值金额:" + morny + " 元"); |
| | | } else { |
| | | binding.tip.setText("开卡成功!"); |
| | | balance = userCard.getBalance(); |
| | | binding.redRemainderMorny.setVisibility(View.GONE); |
| | | } |
| | |
| | | new Handler().postDelayed(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | IpBean ipBean = BaseDaoSingleton.getInstance(MyApplication.myApplication).ipDao().findFirst(); |
| | | |
| | | AdminDataBean adminData = BaseDaoSingleton.getInstance(MyApplication.myApplication).adminDao().findFirst(); |
| | | if (ipBean != null && adminData != null) { |
| | | MyApplication.myApplication.initMachineRequestBean(ipBean.getIp(), ipBean.getPort(), adminData.getAddressCode()); |
| | | if (MyApplication.myApplication.ipBean != null && adminData != null) { |
| | | MyApplication.myApplication.initMachineRequestBean(MyApplication.myApplication.ipBean.getIp(), MyApplication.myApplication.ipBean.getPort(), adminData.getAddressCode()); |
| | | } |
| | | } |
| | | }, 500); |
| | |
| | | android:textSize="@dimen/text_size" /> |
| | | |
| | | <TextView |
| | | |
| | | android:id="@+id/tip" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="20dp" |
| | |
| | | android:text="用户姓名:" |
| | | android:textSize="@dimen/text_size" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/red_initCode" |
| | | <LinearLayout |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:layout_marginTop="15dp" |
| | | android:text="用户注册编号:" |
| | | android:textSize="@dimen/text_size" /> |
| | | android:orientation="horizontal"> |
| | | |
| | | <TextView |
| | | android:layout_width="wrap_content" |
| | | android:layout_height="wrap_content" |
| | | android:text="用户注册编号:" |
| | | android:textSize="@dimen/text_size" /> |
| | | |
| | | <TextView |
| | | android:id="@+id/red_initCode" |
| | | android:layout_width="match_parent" |
| | | android:layout_height="wrap_content" |
| | | android:text="" |
| | | android:textSize="@dimen/text_size" /> |
| | | </LinearLayout> |
| | | |
| | | |
| | | <TextView |