|
|
|
@ -7,7 +7,9 @@ import android.content.Intent;
|
|
|
|
|
import android.content.IntentFilter;
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
import android.view.MenuItem;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
import android.widget.PopupMenu;
|
|
|
|
|
import android.widget.Toast;
|
|
|
|
|
|
|
|
|
|
import com.example.jinyu_rfid.adapter.ResultAdapter;
|
|
|
|
@ -35,19 +37,19 @@ import java.util.Optional;
|
|
|
|
|
|
|
|
|
|
import okhttp3.RequestBody;
|
|
|
|
|
|
|
|
|
|
public class WriteUserActivity extends BaseActivity implements DataReturnCall {
|
|
|
|
|
public class WriteUserActivity extends BaseActivity implements DataReturnCall, PopupMenu.OnMenuItemClickListener {
|
|
|
|
|
private Intent intent1;
|
|
|
|
|
private Intent intent2;
|
|
|
|
|
private RFIDModel rfidModel;
|
|
|
|
|
private ActivityWriteUserBinding binding;
|
|
|
|
|
private ResultAdapter adapter;
|
|
|
|
|
private List<ReadTyreNoResult> list;
|
|
|
|
|
private PopupMenu popupMenu;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
binding = DataBindingUtil.setContentView(this, R.layout.activity_write_user);
|
|
|
|
|
binding.setTitle(getString(R.string.activity_name_configuration));
|
|
|
|
|
rfidModel = new C5106Device(this);
|
|
|
|
|
intent1 = new Intent(this, ConfigurationTableActivity.class);
|
|
|
|
|
intent2 = new Intent(this, ConfigurationTableActivity.class);
|
|
|
|
@ -56,6 +58,9 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall {
|
|
|
|
|
adapter = new ResultAdapter(this);
|
|
|
|
|
binding.setAdapter(adapter);
|
|
|
|
|
|
|
|
|
|
popupMenu = new PopupMenu(this, binding.writeMenu);
|
|
|
|
|
popupMenu.setOnMenuItemClickListener(this);
|
|
|
|
|
getMenuInflater().inflate(R.menu.activity_menu, popupMenu.getMenu());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -67,7 +72,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall {
|
|
|
|
|
|
|
|
|
|
// 写入
|
|
|
|
|
public void writeUser(View view) {
|
|
|
|
|
/* if (list == null || list.isEmpty()) return;
|
|
|
|
|
if (list == null || list.isEmpty()) return;
|
|
|
|
|
var epcStr = binding.writeEpcCode.getText().toString();
|
|
|
|
|
if (epcStr.isEmpty()) return;
|
|
|
|
|
// EPC编码~胎号~品牌~规格~花纹~层级~轮胎名称~速度级别~负荷指数~轮辋直径~扁平比~销售区域
|
|
|
|
@ -77,13 +82,13 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall {
|
|
|
|
|
var configuration = tagList.get(i);
|
|
|
|
|
var state = configuration.isState();
|
|
|
|
|
tagUserStr.append("~");
|
|
|
|
|
*//* if (state) {
|
|
|
|
|
Optional<ReadTyreNoResult> optionalResult = Optional.ofNullable(list.get(i-1));
|
|
|
|
|
if (state) {
|
|
|
|
|
Optional<ReadTyreNoResult> optionalResult = Optional.ofNullable(list.get(i - 1));
|
|
|
|
|
String propertyContent = optionalResult.map(ReadTyreNoResult::getPropertyContent).orElse("_");
|
|
|
|
|
tagUserStr.append(propertyContent);
|
|
|
|
|
} else {
|
|
|
|
|
tagUserStr.append("_");
|
|
|
|
|
}*//*
|
|
|
|
|
}
|
|
|
|
|
if (state) {
|
|
|
|
|
try {
|
|
|
|
|
var result = list.get(i - 1);
|
|
|
|
@ -98,7 +103,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall {
|
|
|
|
|
}
|
|
|
|
|
String user = ASCIIUtil.str2Hex(tagUserStr.toString());
|
|
|
|
|
Log.e("TAG", "writeUser:" + user);
|
|
|
|
|
Log.e("TAG", "writeUser:" + user.length());*/
|
|
|
|
|
Log.e("TAG", "writeUser:" + user.length());
|
|
|
|
|
if (!writeUserState) {
|
|
|
|
|
Log.e("TAG", "writeUser:" + 1);
|
|
|
|
|
// writeUserState = rfidModel.writeUser(user, epcStr);
|
|
|
|
@ -107,31 +112,44 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (writeUserState) {
|
|
|
|
|
Map<String ,String> map=new HashMap<>();
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
map.put("EpcCode","1231");
|
|
|
|
|
map.put("TyreNo","1231");
|
|
|
|
|
map.put("token","123456");
|
|
|
|
|
map.put("EpcCode", "1231");
|
|
|
|
|
map.put("TyreNo", "1231");
|
|
|
|
|
map.put("token", "123456");
|
|
|
|
|
|
|
|
|
|
Log.e("TAG", "writeUser:" + 2);
|
|
|
|
|
OkGo.<MyResult>post(url + "/write")
|
|
|
|
|
.upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
.upRequestBody(RequestBody.create(JSON, gson.toJson(map)))
|
|
|
|
|
.execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
|
super.onSuccess(response);
|
|
|
|
|
|
|
|
|
|
var body = response.body();
|
|
|
|
|
if (body.getSaveFlag().equals("1")) {
|
|
|
|
|
list.clear();
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
binding.writeEpcCode.setText(null);
|
|
|
|
|
binding.writeTire.setText(null);
|
|
|
|
|
Toast.makeText(WriteUserActivity.this, getString(R.string.binding_success), Toast.LENGTH_SHORT).show();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Toast.makeText(WriteUserActivity.this, body.getSaveMessage(), Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// writeUserState=false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void writeGoRead(View view) {
|
|
|
|
|
startActivity(intent1);
|
|
|
|
|
public void writeGoMenu(View view){
|
|
|
|
|
popupMenu.show();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void writeGoConfiguration(View view) {
|
|
|
|
|
startActivity(intent2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void readEpcCodeInfo(String info, boolean state, String stateInfo) {
|
|
|
|
@ -155,23 +173,38 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall {
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
map.put("TyreNo", erCode);
|
|
|
|
|
map.put("token", "123456");
|
|
|
|
|
OkGo.<MyResult>post(url + "/readTyreNo").upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
|
super.onSuccess(response);
|
|
|
|
|
var body = response.body();
|
|
|
|
|
if (body.getResultFlag().equals("1")) {
|
|
|
|
|
|
|
|
|
|
list = gson.fromJson(body.getJson(), new TypeToken<List<ReadTyreNoResult>>() {
|
|
|
|
|
}.getType());
|
|
|
|
|
list.remove(0);
|
|
|
|
|
adapter.setList(list);
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Toast.makeText(WriteUserActivity.this, body.getResultData().toString(), Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
OkGo.<MyResult>post(url + "/readTyreNo").upRequestBody(RequestBody.create(JSON, gson.toJson(map)))
|
|
|
|
|
.execute(new MyRecultCall(dialog, this) {
|
|
|
|
|
@SuppressLint("NotifyDataSetChanged")
|
|
|
|
|
@Override
|
|
|
|
|
public void onSuccess(Response<MyResult> response) {
|
|
|
|
|
super.onSuccess(response);
|
|
|
|
|
var body = response.body();
|
|
|
|
|
if (body.getResultFlag().equals("1")) {
|
|
|
|
|
|
|
|
|
|
list = gson.fromJson(body.getJson(), new TypeToken<List<ReadTyreNoResult>>() {
|
|
|
|
|
}.getType());
|
|
|
|
|
list.remove(0);
|
|
|
|
|
adapter.setList(list);
|
|
|
|
|
adapter.notifyDataSetChanged();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Toast.makeText(WriteUserActivity.this, body.getResultData().toString(), Toast.LENGTH_SHORT).show();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public boolean onMenuItemClick(MenuItem item) {
|
|
|
|
|
if (item.getItemId() == R.id.menu_read) {
|
|
|
|
|
|
|
|
|
|
startActivity(intent1);
|
|
|
|
|
}else {
|
|
|
|
|
startActivity(intent2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|