diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 1274ecf..97c7f0e 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -13,6 +13,15 @@
android:supportsRtl="true"
android:theme="@style/Theme.JinYuRFID"
tools:targetApi="31">
+
+
+
+
+
+
diff --git a/app/src/main/java/com/example/jinyu_rfid/ConfigurationTableActivity.java b/app/src/main/java/com/example/jinyu_rfid/ConfigurationTableActivity.java
index 0a756aa..d29d1c9 100644
--- a/app/src/main/java/com/example/jinyu_rfid/ConfigurationTableActivity.java
+++ b/app/src/main/java/com/example/jinyu_rfid/ConfigurationTableActivity.java
@@ -3,7 +3,9 @@ package com.example.jinyu_rfid;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
+import android.content.Intent;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
import com.example.jinyu_rfid.adapter.ConfigurationTableAdapter;
@@ -18,9 +20,9 @@ import org.litepal.LitePal;
import java.util.ArrayList;
import java.util.List;
-public class ConfigurationTableActivity extends BaseActivity implements ItemClickCall {
+public class ConfigurationTableActivity extends BaseActivity {
private ConfigurationTableAdapter adapter;
- private List list;
+
private List dataList;
@Override
@@ -28,30 +30,43 @@ public class ConfigurationTableActivity extends BaseActivity implements ItemClic
super.onCreate(savedInstanceState);
ActivityConfigurationTableBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_configuration_table);
binding.setTitle(getString(R.string.activity_name_configuration));
- adapter = new ConfigurationTableAdapter(this, this);
- list = LitePal.findAll(ConfigurationTable.class);
- dataList = new ArrayList<>();
- if (list != null || !list.isEmpty()) {
- list.forEach(t->{
- ConfigurationData data=new ConfigurationData(t.getIndex(),t.getProjectName(),false);
- dataList.add(data);
- });
+ adapter = new ConfigurationTableAdapter(this);
+ var stringArray = getResources().getStringArray(R.array.project_list);
+ var length = stringArray.length;
+ dataList = new ArrayList<>(length);
+ for (int i = 0; i < length; i++) {
+ dataList.add(new ConfigurationData(i, stringArray[i], findStateByIndex(i)));
}
adapter.setList(dataList);
binding.setAdapter(adapter);
}
- @Override
- public void onClick(int position) {
- }
+/* public void configurationAddItem(View view) {
- public void configurationAddItem(View view) {
-
- }
+ }*/
public void configurationSave(View view) {
+ Log.e("TAG", "configurationSave:" + dataList.toString());
+ LitePal.deleteAll(ConfigurationTable.class);
+ dataList.forEach(t->{
+ ConfigurationTable configurationTable=new ConfigurationTable();
+ configurationTable.setIndex(t.getIndex());
+ configurationTable.setState(t.isState());
+ configurationTable.save();
+ });
+ var intent = new Intent(this, WriteUserActivity.class);
+ intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
+ startActivity(intent);
+ finish();
+ }
+ private boolean findStateByIndex(int index) {
+ var list = LitePal.where("index = "+ index).limit(1).find(ConfigurationTable.class);
+ if (list==null||list.isEmpty()){
+ return false;
+ }
+ return list.get(0).isState();
}
}
\ 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 d135a43..9de9bf9 100644
--- a/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java
+++ b/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java
@@ -1,56 +1,73 @@
package com.example.jinyu_rfid;
-import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import android.content.Intent;
+import android.content.IntentFilter;
import android.os.Bundle;
import android.view.View;
+import android.widget.Toast;
import com.example.jinyu_rfid.base.BaseActivity;
+import com.example.jinyu_rfid.base.MyRecultCall;
+import com.example.jinyu_rfid.base.MyResult;
+import com.example.jinyu_rfid.been.ReadTyreNoResult;
+import com.example.jinyu_rfid.broadcast.ScanERCodeReceiver;
import com.example.jinyu_rfid.callback.DataReturnCall;
import com.example.jinyu_rfid.databinding.ActivityWriteUserBinding;
import com.example.jinyu_rfid.rfid.C5106Device;
import com.example.jinyu_rfid.rfid.RFIDModel;
+import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
+import com.lzy.okgo.model.Response;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import okhttp3.RequestBody;
public class WriteUserActivity extends BaseActivity implements DataReturnCall {
private Intent intent1;
private Intent intent2;
private RFIDModel rfidModel;
private ActivityWriteUserBinding binding;
+
@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();
+ intent1 = new Intent(this, ConfigurationTableActivity.class);
+ intent2 = new Intent(this, ConfigurationTableActivity.class);
+ ScanERCodeReceiver scanERCodeReceiver = new ScanERCodeReceiver(this);
+ registerReceiver(scanERCodeReceiver, new IntentFilter("com.rfid.SCAN"));
- rfidModel=new C5106Device();
- intent1=new Intent(this, ConfigurationTableActivity.class);
- intent2=new Intent(this, ConfigurationTableActivity.class);
}
- public void writeReadEPC(View view){
+ public void writeReadEPC(View view) {
}
- public void writeUser(View view){
- }
+ public void writeUser(View view) {
+ }
- public void writeGoRead(View view){
+ public void writeGoRead(View view) {
startActivity(intent1);
}
- public void writeGoConfiguration(View view){
+
+ public void writeGoConfiguration(View view) {
startActivity(intent2);
}
@Override
public void readEpcCodeInfo(String epc) {
- binding.writeEpcCode.setText(epc);
+ binding.writeEpcCode.setText(epc);
}
@Override
@@ -61,7 +78,22 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall {
@Override
public void readerCodeInfo(String erCode) {
binding.writeTire.setText(erCode);
- // OkGo.post(url+"/readTypeNo")
- // .params("")
+ 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) {
+ @Override
+ public void onSuccess(Response response) {
+ super.onSuccess(response);
+ var body = response.body();
+ if (body.getResultFlag().equals("1")){
+ List list=gson.fromJson(body.getJson(),new TypeToken>(){}.getType());
+ return;
+ }
+ Toast.makeText(WriteUserActivity.this, body.getResultData().toString(), Toast.LENGTH_SHORT).show();
+ }
+ });
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/jinyu_rfid/adapter/ConfigurationTableAdapter.java b/app/src/main/java/com/example/jinyu_rfid/adapter/ConfigurationTableAdapter.java
index 9a7f074..ad1b083 100644
--- a/app/src/main/java/com/example/jinyu_rfid/adapter/ConfigurationTableAdapter.java
+++ b/app/src/main/java/com/example/jinyu_rfid/adapter/ConfigurationTableAdapter.java
@@ -25,11 +25,11 @@ import java.util.List;
public class ConfigurationTableAdapter extends RecyclerView.Adapter {
private Context context;
private LayoutInflater inflater;
- private ItemClickCall call;
+
private List list;
- public ConfigurationTableAdapter(Context context, ItemClickCall call) {
+ public ConfigurationTableAdapter(Context context) {
this.context = context;
- this.call = call;
+
inflater=LayoutInflater.from(context);
}
diff --git a/app/src/main/java/com/example/jinyu_rfid/base/MyApplication.java b/app/src/main/java/com/example/jinyu_rfid/base/MyApplication.java
index 7821cdd..96178be 100644
--- a/app/src/main/java/com/example/jinyu_rfid/base/MyApplication.java
+++ b/app/src/main/java/com/example/jinyu_rfid/base/MyApplication.java
@@ -34,7 +34,7 @@ public class MyApplication extends Application {
application = this;
SharedPreferencesUtils.init(getApplicationContext(), "myapp");
okGoBase();
-
+ LitePal.initialize(this);
}
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 59fb00b..3513bf0 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
@@ -9,6 +9,16 @@ public class MyResult {
private String VerifyMessage;
private Object ResultData;
private String json;
+ private String ResultFlag;
+
+
+ public String getResultFlag() {
+ return ResultFlag;
+ }
+
+ public void setResultFlag(String resultFlag) {
+ ResultFlag = resultFlag;
+ }
public String getJson() {
return json;
diff --git a/app/src/main/java/com/example/jinyu_rfid/been/ConfigurationData.java b/app/src/main/java/com/example/jinyu_rfid/been/ConfigurationData.java
index 519efaa..d4d1010 100644
--- a/app/src/main/java/com/example/jinyu_rfid/been/ConfigurationData.java
+++ b/app/src/main/java/com/example/jinyu_rfid/been/ConfigurationData.java
@@ -46,4 +46,13 @@ public class ConfigurationData extends BaseObservable {
public void setState(boolean state) {
this.state = state;
}
+
+ @Override
+ public String toString() {
+ return "ConfigurationData{" +
+ "index=" + index +
+ ", projectName='" + projectName + '\'' +
+ ", state=" + state +
+ '}';
+ }
}
diff --git a/app/src/main/java/com/example/jinyu_rfid/been/ConfigurationTable.java b/app/src/main/java/com/example/jinyu_rfid/been/ConfigurationTable.java
index c1faf0a..e8ce3f2 100644
--- a/app/src/main/java/com/example/jinyu_rfid/been/ConfigurationTable.java
+++ b/app/src/main/java/com/example/jinyu_rfid/been/ConfigurationTable.java
@@ -43,4 +43,14 @@ public class ConfigurationTable extends LitePalSupport {
public void setState(boolean state) {
this.state = state;
}
+
+ @Override
+ public String toString() {
+ return "ConfigurationTable{" +
+ "id=" + id +
+ ", index=" + index +
+ ", projectName='" + projectName + '\'' +
+ ", state=" + state +
+ '}';
+ }
}
diff --git a/app/src/main/java/com/example/jinyu_rfid/been/ReadTyreNoResult.java b/app/src/main/java/com/example/jinyu_rfid/been/ReadTyreNoResult.java
new file mode 100644
index 0000000..9b00254
--- /dev/null
+++ b/app/src/main/java/com/example/jinyu_rfid/been/ReadTyreNoResult.java
@@ -0,0 +1,40 @@
+package com.example.jinyu_rfid.been;
+
+/**
+ * @author wanghao
+ * @date 2024/5/20 16:33
+ */
+public class ReadTyreNoResult {
+ /**
+ *
+ "PropertyName": "胎号",
+ "PropertyContent": "32432040640",
+ "PropertyIndex": 1
+ */
+ private String PropertyName, PropertyContent;
+ private int PropertyIndex;
+
+ public String getPropertyName() {
+ return PropertyName;
+ }
+
+ public void setPropertyName(String propertyName) {
+ PropertyName = propertyName;
+ }
+
+ public String getPropertyContent() {
+ return PropertyContent;
+ }
+
+ public void setPropertyContent(String propertyContent) {
+ PropertyContent = propertyContent;
+ }
+
+ public int getPropertyIndex() {
+ return PropertyIndex;
+ }
+
+ public void setPropertyIndex(int propertyIndex) {
+ PropertyIndex = propertyIndex;
+ }
+}
diff --git a/app/src/main/java/com/example/jinyu_rfid/broadcast/ScanERCodeReceiver.java b/app/src/main/java/com/example/jinyu_rfid/broadcast/ScanERCodeReceiver.java
new file mode 100644
index 0000000..4f6328f
--- /dev/null
+++ b/app/src/main/java/com/example/jinyu_rfid/broadcast/ScanERCodeReceiver.java
@@ -0,0 +1,29 @@
+package com.example.jinyu_rfid.broadcast;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import com.example.jinyu_rfid.callback.DataReturnCall;
+
+public class ScanERCodeReceiver extends BroadcastReceiver {
+ private DataReturnCall call;
+
+ public ScanERCodeReceiver() {
+ }
+
+ public ScanERCodeReceiver(DataReturnCall call) {
+ this.call = call;
+ }
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ byte[] data = intent.getByteArrayExtra("data");
+ if (data != null) {
+ String barcode = new String(data);
+ Log.e("", "onReceive, data:" + barcode);
+ call.readerCodeInfo(barcode);
+ }
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_configuration_table.xml b/app/src/main/res/layout/activity_configuration_table.xml
index 39b043e..2064209 100644
--- a/app/src/main/res/layout/activity_configuration_table.xml
+++ b/app/src/main/res/layout/activity_configuration_table.xml
@@ -32,9 +32,9 @@
+ android:text="@string/write_index" />
+ android:text="@string/write_state" />
+ android:text="@string/write_project" />
-
-
-
+ android:text="@string/configuration_add" />-->
@@ -29,7 +29,7 @@
@@ -45,17 +45,8 @@
android:layout_weight="1"
android:text="@{item.projectName}" />
-
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-en-rUS/strings.xml b/app/src/main/res/values-en-rUS/strings.xml
index f7274a5..32f882e 100644
--- a/app/src/main/res/values-en-rUS/strings.xml
+++ b/app/src/main/res/values-en-rUS/strings.xml
@@ -3,15 +3,28 @@
login name
pass word
login
- Remember me
+ remember me
language :
app configuration
save
- Tire number
+ tire number
read epc
write in
go info reading
go configuration
epc number
add item
+ index
+ write or not
+ write project
+ brand
+ specifications
+ pattern
+ hierarchy
+ tire name
+ speed level
+ load index
+ rim diameter
+ flat ratio
+ sales area
\ No newline at end of file
diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml
index 6270c73..d7ebc94 100644
--- a/app/src/main/res/values/arrays.xml
+++ b/app/src/main/res/values/arrays.xml
@@ -4,4 +4,19 @@
- English
- 中文
+
+ - @string/epc_code
+ - @string/tire_number
+ - @string/project_list_brand
+ - @string/project_list_specifications
+ - @string/project_list_pattern
+ - @string/project_list_hierarchy
+ - @string/project_list_name
+ - @string/project_list_speed
+ - @string/project_list_load
+ - @string/project_list_rim
+ - @string/project_list_flat
+ - @string/project_list_area
+
+
\ 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 8b5e863..f3a52f3 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -13,5 +13,18 @@
信息读取
写入配置
epc编码
- 添加项目>
+ 添加项目
+ 索引
+ 是否写入
+ 写入项目
+ 品牌
+ 规格
+ 花纹
+ 层级
+ 轮胎名称
+ 速度级别
+ 负荷指数
+ 轮辋直径
+ 扁平比
+ 销售区域>
\ No newline at end of file