|
|
@ -44,6 +44,8 @@ import java.util.Set;
|
|
|
|
public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback, Rfly.ReadTagDataCallback {
|
|
|
|
public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback, Rfly.ReadTagDataCallback {
|
|
|
|
private Rfly hbtReader;
|
|
|
|
private Rfly hbtReader;
|
|
|
|
private ObservableBoolean state;
|
|
|
|
private ObservableBoolean state;
|
|
|
|
|
|
|
|
private ObservableBoolean readstate1;
|
|
|
|
|
|
|
|
private ObservableBoolean readstate2;
|
|
|
|
private ActivityRflyBinding binding;
|
|
|
|
private ActivityRflyBinding binding;
|
|
|
|
private List<String> tagList;
|
|
|
|
private List<String> tagList;
|
|
|
|
private GoodsInfoAdapter adapter1;
|
|
|
|
private GoodsInfoAdapter adapter1;
|
|
|
@ -126,12 +128,21 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
|
|
|
|
list2 = new ArrayList<>();
|
|
|
|
list2 = new ArrayList<>();
|
|
|
|
adapter2.setList(list2);
|
|
|
|
adapter2.setList(list2);
|
|
|
|
binding.setAdapter2(adapter2);
|
|
|
|
binding.setAdapter2(adapter2);
|
|
|
|
|
|
|
|
readstate1=new ObservableBoolean();
|
|
|
|
|
|
|
|
readstate1.set(false);
|
|
|
|
|
|
|
|
binding.setReadstate1(readstate1);
|
|
|
|
|
|
|
|
readstate2=new ObservableBoolean();
|
|
|
|
|
|
|
|
readstate2.set(false);
|
|
|
|
|
|
|
|
binding.setReadstate2(readstate2);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 返回RFID
|
|
|
|
// 返回RFID
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void ReadTagDataCallback(EpcBean epcBean) {
|
|
|
|
public void ReadTagDataCallback(EpcBean epcBean) {
|
|
|
|
|
|
|
|
|
|
|
|
var strepc = epcBean.strepc;
|
|
|
|
var strepc = epcBean.strepc;
|
|
|
|
|
|
|
|
Log.e("TAG", "ReadTagDataCallback:" +strepc );
|
|
|
|
Message message = new Message();
|
|
|
|
Message message = new Message();
|
|
|
|
strepc = ASCIIUtil.hex2Str(strepc);
|
|
|
|
strepc = ASCIIUtil.hex2Str(strepc);
|
|
|
|
message.what=0;
|
|
|
|
message.what=0;
|
|
|
@ -148,10 +159,17 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
|
|
|
|
public void handleMessage(@NonNull Message msg) {
|
|
|
|
public void handleMessage(@NonNull Message msg) {
|
|
|
|
super.handleMessage(msg);
|
|
|
|
super.handleMessage(msg);
|
|
|
|
int what = msg.what;
|
|
|
|
int what = msg.what;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (what==100){
|
|
|
|
|
|
|
|
readstate1.set(false);
|
|
|
|
|
|
|
|
readstate2.set(false);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
var str = msg.obj.toString();
|
|
|
|
var str = msg.obj.toString();
|
|
|
|
if (str.contains("DB")) {
|
|
|
|
if (str.contains("DB")) {
|
|
|
|
if (what==0){
|
|
|
|
if (what==0){
|
|
|
|
binding.ledgerDb.setText(str);
|
|
|
|
binding.ledgerDb.setText(str);
|
|
|
|
|
|
|
|
readstate2.set(true);
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
// 地标
|
|
|
|
// 地标
|
|
|
|
list2.add(0, str);
|
|
|
|
list2.add(0, str);
|
|
|
@ -161,6 +179,7 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
|
|
|
|
} else if (str.contains("HK")) {
|
|
|
|
} else if (str.contains("HK")) {
|
|
|
|
if (what==0){
|
|
|
|
if (what==0){
|
|
|
|
binding.ledgerHk.setText(str);
|
|
|
|
binding.ledgerHk.setText(str);
|
|
|
|
|
|
|
|
readstate1.set(true);
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
list1.add(str);
|
|
|
|
list1.add(str);
|
|
|
|
var length = str.length();
|
|
|
|
var length = str.length();
|
|
|
@ -178,9 +197,11 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
|
|
|
|
if (state.get()) {
|
|
|
|
if (state.get()) {
|
|
|
|
hbtReader.ScanTags();
|
|
|
|
hbtReader.ScanTags();
|
|
|
|
state.set(false);
|
|
|
|
state.set(false);
|
|
|
|
|
|
|
|
startTask();//开始定时清理
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
hbtReader.StopScan();
|
|
|
|
hbtReader.StopScan();
|
|
|
|
state.set(true);
|
|
|
|
state.set(true);
|
|
|
|
|
|
|
|
stopTask();//停止-在停止读取的时候
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (ReaderException e) {
|
|
|
|
} catch (ReaderException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
e.printStackTrace();
|
|
|
@ -263,8 +284,8 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
|
|
|
|
// 提交
|
|
|
|
// 提交
|
|
|
|
public void blueToothSubmit(View view) {
|
|
|
|
public void blueToothSubmit(View view) {
|
|
|
|
if (!state.get()) {
|
|
|
|
if (!state.get()) {
|
|
|
|
Toast.makeText(context, "先停止读取RFID", Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.makeText(context, "已停止读取", Toast.LENGTH_SHORT).show();
|
|
|
|
return;
|
|
|
|
blueToothSanRFID(null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (list1.isEmpty() || list2.isEmpty()) return;
|
|
|
|
if (list1.isEmpty() || list2.isEmpty()) return;
|
|
|
|
OkGo.<MyResult>post("http://" + SharedPreferencesUtils.getstring("ip", "") + "/api/blueToothSubmit")
|
|
|
|
OkGo.<MyResult>post("http://" + SharedPreferencesUtils.getstring("ip", "") + "/api/blueToothSubmit")
|
|
|
@ -288,4 +309,32 @@ public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Runnable task;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 开启定时任务
|
|
|
|
|
|
|
|
private void startTask() {
|
|
|
|
|
|
|
|
stopTask();
|
|
|
|
|
|
|
|
handler.postDelayed(task = new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
// 在这里执行具体的任务
|
|
|
|
|
|
|
|
Log.d("HandlerTask", "run");
|
|
|
|
|
|
|
|
Message message = new Message();
|
|
|
|
|
|
|
|
message.what=100;
|
|
|
|
|
|
|
|
handler.sendMessage(message);
|
|
|
|
|
|
|
|
// 任务执行完后再次调用postDelayed开启下一次任务
|
|
|
|
|
|
|
|
handler.postDelayed(this, 500);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 停止定时任务
|
|
|
|
|
|
|
|
private void stopTask() {
|
|
|
|
|
|
|
|
if (task != null) {
|
|
|
|
|
|
|
|
handler.removeCallbacks(task);
|
|
|
|
|
|
|
|
task = null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
readstate1.set(false);
|
|
|
|
|
|
|
|
readstate2.set(false);
|
|
|
|
|
|
|
|
}}
|