From 2b9c76ddd4e326e1a66fd8ebc9b9e728ba98e2b8 Mon Sep 17 00:00:00 2001
From: wangh <123456>
Date: Wed, 22 May 2024 11:04:00 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20menu?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/src/main/AndroidManifest.xml | 16 ++-
.../com/example/jinyu_rfid/ReadActivity.java | 14 +++
.../example/jinyu_rfid/WriteUserActivity.java | 107 ++++++++++++------
.../com/example/jinyu_rfid/base/MyResult.java | 18 +++
app/src/main/res/layout/activity_read.xml | 30 +++++
.../main/res/layout/activity_write_user.xml | 71 +++++++-----
app/src/main/res/menu/activity_menu.xml | 11 ++
app/src/main/res/mipmap-xhdpi/menu.png | Bin 0 -> 1200 bytes
app/src/main/res/values-en-rUS/strings.xml | 3 +-
app/src/main/res/values/strings.xml | 5 +-
10 files changed, 199 insertions(+), 76 deletions(-)
create mode 100644 app/src/main/java/com/example/jinyu_rfid/ReadActivity.java
create mode 100644 app/src/main/res/layout/activity_read.xml
create mode 100644 app/src/main/res/menu/activity_menu.xml
create mode 100644 app/src/main/res/mipmap-xhdpi/menu.png
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 0000000000000000000000000000000000000000..c025efdfc752c26b707c06ab967f94a6079ff409
GIT binary patch
literal 1200
zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSjKx9jP7LeL$-HD>V9D}yaSW-5
zdpkF~?}~vy%iGBZ=COQJ*`Utocc@5c+T;y$j`(=@iS$03*!j3;`K#0N5t*M}ywZQ_
ze#g@<=Neba>ld7Mj1877Kx3bA&1mmuW@y;S^z7kd28M)n4V6DE7#L<~C&=0Hkt+RQ
zse|UzWUrUSUN3|Hez#rv<@tyI+oxQrK4woE9n(zLpM(=QJPBHWdsm(|BKAkh)+~VAX_6em80lTLN9p1k*x&HLT1}g@`pTf$G(|Y|9x~sn5
zDeq29usg$c*SPK8^J#o}&1nst3+}Oev#XQkJyP)D+CB#x$(mQSwcqXb?O_fP@8Ddh
zZ|)$#-?-@Q^TZ2#Iq$yuV{RijMee)&>&%A?pBH2wFL=jx(ZuKc|9VaT-}83Oe8X_#
zRA5LSGlSO57)f@9H6nhg<_rNRpPaH_NLX5+wVScQOD+5uBZGEp@J(KZ5Tl(&d<+qq
zb57-zFV8-9y2HL#cmjCMwm0uYAw{O4B)v$DFVxam9rY2T~uZ{sWLUFqSrM88v
zyjXvIgH=SGp~n-ydyHbY{#o`tRh+=~V1rgo_bCOh!*1Ju7GK{k$gqa1E`dRVclRWl
zn`)q7)0z22$S{&Yse4LW?DxDpoVJNK@s
zJ6nTya-IGGmANJA1zel_IPL~X9Xq^$)%?2i-z8R#C0vh}PMmI5d3$>-e}Fq1h
z9z;kOO>H~+yJ@jf#JAprvtjvfSL!E7zQ5C<6B$g&xGw-@u6xurBgd#fM(2#y#>2lKXba&060UJ3V|Cf52}>
zUC~3AzRCZxU=Voy?|O}?uqrmCZH`S6LT%S=cG>|8lud?Bw=>hR!cm`T_zmzo)F(
z^Y(l-n;4$~{|-B;dDGjDCQZn6>^Q5Pw02g*>)OQo@i#0R@>lu0^D#Vg0p?ipvL;y>
ddj|6dd7oN^36+yfCIW3{@O1TaS?83{1OOFH4MP9`
literal 0
HcmV?d00001
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