diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 8a080c0..75f76e2 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -13,6 +13,10 @@
android:supportsRtl="true"
android:theme="@style/Theme.JinYuRFID"
tools:targetApi="31">
+
+
+
-
-
-
-
-
+
+
+
+
+
+
diff --git a/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java b/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java
new file mode 100644
index 0000000..abeadf9
--- /dev/null
+++ b/app/src/main/java/com/example/jinyu_rfid/ReadActivity.java
@@ -0,0 +1,14 @@
+package com.example.jinyu_rfid;
+
+import androidx.appcompat.app.AppCompatActivity;
+
+import android.os.Bundle;
+
+public class ReadActivity extends AppCompatActivity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_read);
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java b/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java
index 45a10f9..3ec999e 100644
--- a/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java
+++ b/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java
@@ -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 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 optionalResult = Optional.ofNullable(list.get(i-1));
+ if (state) {
+ Optional 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 map=new HashMap<>();
+ Map 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.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 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 map = new HashMap<>();
map.put("TyreNo", erCode);
map.put("token", "123456");
- OkGo.post(url + "/readTyreNo").upRequestBody(RequestBody.create(JSON, gson.toJson(map))).execute(new MyRecultCall(dialog, this) {
- @SuppressLint("NotifyDataSetChanged")
- @Override
- public void onSuccess(Response response) {
- super.onSuccess(response);
- var body = response.body();
- if (body.getResultFlag().equals("1")) {
-
- list = gson.fromJson(body.getJson(), new TypeToken>() {
- }.getType());
- list.remove(0);
- adapter.setList(list);
- adapter.notifyDataSetChanged();
- return;
- }
- Toast.makeText(WriteUserActivity.this, body.getResultData().toString(), Toast.LENGTH_SHORT).show();
- }
- });
+ OkGo.post(url + "/readTyreNo").upRequestBody(RequestBody.create(JSON, gson.toJson(map)))
+ .execute(new MyRecultCall(dialog, this) {
+ @SuppressLint("NotifyDataSetChanged")
+ @Override
+ public void onSuccess(Response response) {
+ super.onSuccess(response);
+ var body = response.body();
+ if (body.getResultFlag().equals("1")) {
+
+ list = gson.fromJson(body.getJson(), new TypeToken>() {
+ }.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;
+
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/jinyu_rfid/base/MyResult.java b/app/src/main/java/com/example/jinyu_rfid/base/MyResult.java
index 3513bf0..6c4e096 100644
--- a/app/src/main/java/com/example/jinyu_rfid/base/MyResult.java
+++ b/app/src/main/java/com/example/jinyu_rfid/base/MyResult.java
@@ -10,8 +10,26 @@ public class MyResult {
private Object ResultData;
private String json;
private String ResultFlag;
+ private String SaveFlag;
+ private String SaveMessage;
+ public String getSaveFlag() {
+ return SaveFlag;
+ }
+
+ public void setSaveFlag(String saveFlag) {
+ SaveFlag = saveFlag;
+ }
+
+ public String getSaveMessage() {
+ return SaveMessage;
+ }
+
+ public void setSaveMessage(String saveMessage) {
+ SaveMessage = saveMessage;
+ }
+
public String getResultFlag() {
return ResultFlag;
}
diff --git a/app/src/main/res/layout/activity_read.xml b/app/src/main/res/layout/activity_read.xml
new file mode 100644
index 0000000..9a0bc41
--- /dev/null
+++ b/app/src/main/res/layout/activity_read.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_write_user.xml b/app/src/main/res/layout/activity_write_user.xml
index 3c522eb..9b9fdc4 100644
--- a/app/src/main/res/layout/activity_write_user.xml
+++ b/app/src/main/res/layout/activity_write_user.xml
@@ -8,6 +8,7 @@
+
@@ -19,9 +20,41 @@
android:orientation="vertical"
tools:context=".WriteUserActivity">
-
+
+
+
+
+
+
+
+
+
+
+
+ android:padding="5dp"
+ app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
+ android:layout_margin="10dp">
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/menu/activity_menu.xml b/app/src/main/res/menu/activity_menu.xml
new file mode 100644
index 0000000..3f69df8
--- /dev/null
+++ b/app/src/main/res/menu/activity_menu.xml
@@ -0,0 +1,11 @@
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-xhdpi/menu.png b/app/src/main/res/mipmap-xhdpi/menu.png
new file mode 100644
index 0000000..c025efd
Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/menu.png differ
diff --git a/app/src/main/res/values-en-rUS/strings.xml b/app/src/main/res/values-en-rUS/strings.xml
index 28e2a1e..cd14f12 100644
--- a/app/src/main/res/values-en-rUS/strings.xml
+++ b/app/src/main/res/values-en-rUS/strings.xml
@@ -10,7 +10,7 @@
tire number
read epc
write in
- go info reading
+ info reading
go configuration
epc number
add item
@@ -29,4 +29,5 @@
sales area
write failed
write success
+ mes binding success
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 78e7f6b..07f42d4 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -11,7 +11,7 @@
读取 epc
信息写入
信息读取
- 写入配置
+ 去配置
epc编码
添加项目
索引
@@ -28,5 +28,6 @@
扁平比
销售区域
写入失败
- 写入成功>
+ 写入成功
+ MES 绑定成功>
\ No newline at end of file