private void reloadNames() { for (int i = 0; i < this.adapter.getCount(); i++) { HashMap<String, String> item = this.adapter.getItem(i); if (item.get("error") == "true") { BookAsyncProcessor p = new BookAsyncProcessor(adapter, sharedPref.getString("service_url", "")); p.execute(item); } } }
public void onNewIntent(Intent intent) { Tag tag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); byte[] id = tag.getId(); NfcV nfcMessage = NfcV.get(tag); try { nfcMessage.connect(); int resultIndex = 0; int blockIndex = 0; int blocks = 4; // 0 means 1 block, so it's +1 than 'blocks' byte[] cmd = new byte[] { (byte) 0x60, (byte) 0x23, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, // placeholder for tag UID (byte) blockIndex, (byte) blocks }; System.arraycopy(id, 0, cmd, 2, 8); byte[] data = nfcMessage.transceive(cmd); int start = 2; byte[] results = new byte[data.length]; for (int i = 0; i <= blocks; i++) { for (int b = start; b < start + 4; b++) { // First data block may contain zero bytes, which does not denote end of book code. // this caused troubles with some books if (data[b] == 0 && i > 1) { break; } results[resultIndex] = data[b]; resultIndex++; } start += 5; } nfcMessage.close(); results = ArrayUtils.subarray(results, 3, resultIndex); String res = new String(results); HashMap<String, String> temp = new HashMap<String, String>(); temp.put("sent", "false"); temp.put("to_send", "false"); temp.put("code", res); dataList.add(0, temp); adapter.notifyDataSetChanged(); this.toast.cancel(); BookAsyncProcessor p = new BookAsyncProcessor(adapter, sharedPref.getString("service_url", "")); p.execute(temp); } catch (IOException e) { this.toast.show(); } }