|
|
@ -61,8 +61,8 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
|
|
|
|
popupMenu = new PopupMenu(this, binding.writeMenu);
|
|
|
|
popupMenu = new PopupMenu(this, binding.writeMenu);
|
|
|
|
popupMenu.setOnMenuItemClickListener(this);
|
|
|
|
popupMenu.setOnMenuItemClickListener(this);
|
|
|
|
getMenuInflater().inflate(R.menu.activity_menu, popupMenu.getMenu());
|
|
|
|
getMenuInflater().inflate(R.menu.activity_menu, popupMenu.getMenu());
|
|
|
|
rfidModel = new C5106Device(this, this);
|
|
|
|
// rfidModel = new C5106Device(this, this);
|
|
|
|
// rfidModel = new AutoID9UDevice(this, this);
|
|
|
|
rfidModel = new AutoID9UDevice(this, this);
|
|
|
|
if (rfidModel instanceof C5106Device) {
|
|
|
|
if (rfidModel instanceof C5106Device) {
|
|
|
|
intent1 = new Intent(this, ReadActivity.class);
|
|
|
|
intent1 = new Intent(this, ReadActivity.class);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -118,11 +118,12 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
|
|
|
|
tagUserStr.append("~");
|
|
|
|
tagUserStr.append("~");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String user = ASCIIUtil.str2Hex(tagUserStr.toString());
|
|
|
|
String user = ASCIIUtil.str2Hex(tagUserStr.toString());
|
|
|
|
|
|
|
|
String tyreNo = list.get(0).getPropertyContent();
|
|
|
|
if (!writeUserState) {
|
|
|
|
if (!writeUserState) {
|
|
|
|
Log.e("TAG", "请求");
|
|
|
|
Log.e("TAG", "请求");
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
map.put("EpcCode", epcStr);
|
|
|
|
map.put("EpcCode", epcStr);
|
|
|
|
map.put("TyreNo", list.get(0).getPropertyContent());
|
|
|
|
map.put("TyreNo", tyreNo);
|
|
|
|
map.put("token", "123456");
|
|
|
|
map.put("token", "123456");
|
|
|
|
map.put("Language", SharedPreferencesUtils.getstring("languageIndex", "0"));
|
|
|
|
map.put("Language", SharedPreferencesUtils.getstring("languageIndex", "0"));
|
|
|
|
Log.e("TAG", "writeUser:" + 2);
|
|
|
|
Log.e("TAG", "writeUser:" + 2);
|
|
|
@ -136,10 +137,10 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
|
|
|
|
if (body.getSaveFlag().equals("1")) {
|
|
|
|
if (body.getSaveFlag().equals("1")) {
|
|
|
|
// Toast.makeText(WriteUserActivity.this, getString(R.string.binding_success), Toast.LENGTH_SHORT).show();
|
|
|
|
// Toast.makeText(WriteUserActivity.this, getString(R.string.binding_success), Toast.LENGTH_SHORT).show();
|
|
|
|
writeUserState = true;
|
|
|
|
writeUserState = true;
|
|
|
|
writeUser(user, epcStr);
|
|
|
|
writeUser(user, epcStr,tyreNo);
|
|
|
|
} else if (body.getSaveFlagCF().equals("0")) {// 等于0的情况属于绑定后写入失败,可重新写入
|
|
|
|
} else if (body.getSaveFlagCF().equals("0")) {// 等于0的情况属于绑定后写入失败,可重新写入
|
|
|
|
writeUserState = true;
|
|
|
|
writeUserState = true;
|
|
|
|
writeUser(user, epcStr);
|
|
|
|
writeUser(user, epcStr,tyreNo);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
tipDialog.shouDialog(false, body.getSaveMessage());
|
|
|
|
tipDialog.shouDialog(false, body.getSaveMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -148,16 +149,17 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
writeUser(user, epcStr);
|
|
|
|
writeUser(user, epcStr, tyreNo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void writeUser(String user, String epcStr) {
|
|
|
|
private void writeUser(String user, String epcStr,String tyreNo) {
|
|
|
|
Log.e("TAG", "写入");
|
|
|
|
Log.e("TAG", "写入");
|
|
|
|
var writeState = rfidModel.writeUser(validateDataLength(user), epcStr);
|
|
|
|
var writeState = rfidModel.writeUser(validateDataLength(user), epcStr);
|
|
|
|
tipDialog.shouDialog(writeState, getString(writeState ? R.string.write_success : R.string.write_failed));
|
|
|
|
tipDialog.shouDialog(writeState, getString(writeState ? R.string.write_success : R.string.write_failed));
|
|
|
|
|
|
|
|
// 成功还是失败
|
|
|
|
if (writeState) {
|
|
|
|
if (writeState) {
|
|
|
|
list.clear();
|
|
|
|
list.clear();
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
@ -165,6 +167,20 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall, P
|
|
|
|
binding.writeTire.setText(null);
|
|
|
|
binding.writeTire.setText(null);
|
|
|
|
writeUserState = false;
|
|
|
|
writeUserState = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Map backMap = new HashMap();
|
|
|
|
|
|
|
|
backMap.put("TyreNo",tyreNo);
|
|
|
|
|
|
|
|
backMap.put("Flag",writeState?1:2);
|
|
|
|
|
|
|
|
backMap.put("token","123456");
|
|
|
|
|
|
|
|
OkGo.<MyResult>post("http://" + url + "/rfid/Back")
|
|
|
|
|
|
|
|
.upRequestBody(RequestBody.create(JSON, gson.toJson(backMap)))
|
|
|
|
|
|
|
|
.execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|