From fa86e651cea3fbe2edd88ddc93a07a2ab4cc4812 Mon Sep 17 00:00:00 2001
From: wangh <123456>
Date: Fri, 17 May 2024 17:12:57 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=20=E9=85=8D=E7=BD=AE?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/src/main/assets/litepal.xml | 2 +-
.../ConfigurationTableActivity.java | 42 +++++++++-
.../com/example/jinyu_rfid/MainActivity.java | 69 ++++++++++------
.../example/jinyu_rfid/WriteUserActivity.java | 5 +-
.../adapter/ConfigurationTableAdapter.java | 70 ++++++++++++++++
.../example/jinyu_rfid/base/BaseActivity.java | 5 +-
.../example/jinyu_rfid/base/MyRecultCall.java | 2 +-
.../com/example/jinyu_rfid/base/MyResult.java | 49 +++++------
.../jinyu_rfid/been/ConfigurationData.java | 49 +++++++++++
.../example/jinyu_rfid/been/LoginResult.java | 26 ++++++
.../example/jinyu_rfid/rfid/C5106Device.java | 15 +++-
.../example/jinyu_rfid/rfid/RFIDModel.java | 2 +-
.../layout/activity_configuration_table.xml | 82 +++++++++++++++++--
app/src/main/res/layout/activity_main.xml | 17 ++--
.../main/res/layout/item_configuration.xml | 61 ++++++++++++++
app/src/main/res/values-en-rUS/strings.xml | 3 +-
app/src/main/res/values/strings.xml | 3 +-
app/src/main/res/values/themes.xml | 5 ++
18 files changed, 425 insertions(+), 82 deletions(-)
create mode 100644 app/src/main/java/com/example/jinyu_rfid/adapter/ConfigurationTableAdapter.java
create mode 100644 app/src/main/java/com/example/jinyu_rfid/been/ConfigurationData.java
create mode 100644 app/src/main/java/com/example/jinyu_rfid/been/LoginResult.java
create mode 100644 app/src/main/res/layout/item_configuration.xml
diff --git a/app/src/main/assets/litepal.xml b/app/src/main/assets/litepal.xml
index 066cab4..4b3dda0 100644
--- a/app/src/main/assets/litepal.xml
+++ b/app/src/main/assets/litepal.xml
@@ -3,7 +3,7 @@
-
+
\ No newline at end of file
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 b3f4834..0a756aa 100644
--- a/app/src/main/java/com/example/jinyu_rfid/ConfigurationTableActivity.java
+++ b/app/src/main/java/com/example/jinyu_rfid/ConfigurationTableActivity.java
@@ -4,16 +4,54 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
+import android.view.View;
+import com.example.jinyu_rfid.adapter.ConfigurationTableAdapter;
import com.example.jinyu_rfid.base.BaseActivity;
+import com.example.jinyu_rfid.been.ConfigurationData;
+import com.example.jinyu_rfid.been.ConfigurationTable;
+import com.example.jinyu_rfid.callback.ItemClickCall;
import com.example.jinyu_rfid.databinding.ActivityConfigurationTableBinding;
-public class ConfigurationTableActivity extends BaseActivity {
+import org.litepal.LitePal;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class ConfigurationTableActivity extends BaseActivity implements ItemClickCall {
+ private ConfigurationTableAdapter adapter;
+ private List list;
+ private List dataList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- ActivityConfigurationTableBinding binding=DataBindingUtil. setContentView(this,R.layout.activity_configuration_table);
+ 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.setList(dataList);
+ binding.setAdapter(adapter);
}
+
+ @Override
+ public void onClick(int position) {
+
+ }
+
+ public void configurationAddItem(View view) {
+
+ }
+
+ public void configurationSave(View view) {
+
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/example/jinyu_rfid/MainActivity.java b/app/src/main/java/com/example/jinyu_rfid/MainActivity.java
index 0e29350..6505836 100644
--- a/app/src/main/java/com/example/jinyu_rfid/MainActivity.java
+++ b/app/src/main/java/com/example/jinyu_rfid/MainActivity.java
@@ -7,6 +7,7 @@ import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
+import android.widget.Toast;
import androidx.databinding.DataBindingUtil;
@@ -14,13 +15,18 @@ import androidx.databinding.DataBindingUtil;
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.ConfigurationTable;
+import com.example.jinyu_rfid.been.LoginResult;
import com.example.jinyu_rfid.databinding.ActivityMainBinding;
import com.example.jinyu_rfid.uitls.SharedPreferencesUtils;
import com.example.jinyu_rfid.been.LoginVm;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
+import org.litepal.LitePal;
+
import java.util.HashMap;
+import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -38,10 +44,11 @@ public class MainActivity extends BaseActivity {
super.onCreate(savedInstanceState);
resources = getResources();
config = resources.getConfiguration();
- config.locale = SharedPreferencesUtils.getstring("language","English").equals("中文") ? Locale.CHINA : Locale.ENGLISH;
+ var equals = SharedPreferencesUtils.getstring("language", "English").equals("中文");
+ config.locale = equals ? Locale.CHINA : Locale.ENGLISH;
resources.updateConfiguration(config, resources.getDisplayMetrics());
binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
-
+ // binding.mainLanguage.setSelection(equals?1:0);
loginVm = new LoginVm();
boolean isRemember = SharedPreferencesUtils.getboolean("isRemember", false);
if (isRemember) {
@@ -65,37 +72,47 @@ public class MainActivity extends BaseActivity {
String name = loginVm.getUsername();
var selectLanguage = binding.mainLanguage.getSelectedItem().toString();
config.locale = selectLanguage.equals("中文") ? Locale.CHINA : Locale.ENGLISH;
- SharedPreferencesUtils.putstring("language", selectLanguage);
- resources.updateConfiguration(config, resources.getDisplayMetrics());
- // this.recreate();
- // Intent intent = new Intent(MainActivity.this, ConfigurationTableActivity.class);
- Intent intent = new Intent(MainActivity.this, WriteUserActivity.class);
- startActivity(intent);
- finish();
- /* if (pass == null || name == null || pass.isEmpty() || name.isEmpty()) return;
- OkGo.post(url+"/auth/pdaLogin")
- .upRequestBody(RequestBody.create(JSON, gson.toJson(loginVm)))
+
+
+ Map map = new HashMap<>();
+ map.put("UserID", name);
+ map.put("UserPass", pass);
+ map.put("token", "123456");
+ if (pass == null || name == null || pass.isEmpty() || name.isEmpty()) return;
+ OkGo.post(url + "/login")
+ .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.getCode() == 200) {
- // String accessToken = JSONObject.parseObject(body.getData().toString()).get("access_token").toString();
- // Log.e("TAG", "onSuccess:" + accessToken);
- // SharedPreferencesUtils.putstring("access_token",accessToken);
- boolean remember = loginVm.isRemember();
- if (remember) {
- SharedPreferencesUtils.putboolean("isRemember", remember);
- SharedPreferencesUtils.putstring("user", name);
- SharedPreferencesUtils.putstring("pass", pass);
+ if (body.getExcuteFlag() == 1) {
+ LoginResult loginResult = gson.fromJson(body.getJson(), LoginResult.class);
+ if (loginResult.getVerifyFlag().equals("1")) {
+ boolean remember = loginVm.isRemember();
+ if (remember) {
+ SharedPreferencesUtils.putboolean("isRemember", remember);
+ SharedPreferencesUtils.putstring("user", name);
+ SharedPreferencesUtils.putstring("pass", pass);
+ }
+ SharedPreferencesUtils.putstring("language", selectLanguage);
+ resources.updateConfiguration(config, resources.getDisplayMetrics());
+ List list = LitePal.findAll(ConfigurationTable.class);
+ Intent intent;
+ if (list==null||list.isEmpty()){
+ intent = new Intent(MainActivity.this, ConfigurationTableActivity.class);
+ }else {
+ intent = new Intent(MainActivity.this, WriteUserActivity.class);
+ }
+ startActivity(intent);
+ finish();
+
}
- Intent intent=new Intent(MainActivity.this, HomePageActivity.class);
- intent.putExtra("json",response.body());
- startActivity(intent);
- finish();
+ Toast.makeText(MainActivity.this, loginResult.getVerifyMessage(), Toast.LENGTH_SHORT).show();
}
+
+
}
- });*/
+ });
}
}
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 5fcbcd5..d135a43 100644
--- a/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java
+++ b/app/src/main/java/com/example/jinyu_rfid/WriteUserActivity.java
@@ -26,7 +26,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall {
binding.setTitle(getString(R.string.activity_name_configuration));
rfidModel=new C5106Device();
- rfidModel.openModel();
+
intent1=new Intent(this, ConfigurationTableActivity.class);
intent2=new Intent(this, ConfigurationTableActivity.class);
}
@@ -61,6 +61,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall {
@Override
public void readerCodeInfo(String erCode) {
binding.writeTire.setText(erCode);
- // OkGo.post(url+"/")
+ // OkGo.post(url+"/readTypeNo")
+ // .params("")
}
}
\ 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
new file mode 100644
index 0000000..9a7f074
--- /dev/null
+++ b/app/src/main/java/com/example/jinyu_rfid/adapter/ConfigurationTableAdapter.java
@@ -0,0 +1,70 @@
+package com.example.jinyu_rfid.adapter;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+
+import androidx.annotation.NonNull;
+import androidx.databinding.DataBindingUtil;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.example.jinyu_rfid.BR;
+import com.example.jinyu_rfid.R;
+import com.example.jinyu_rfid.been.ConfigurationData;
+import com.example.jinyu_rfid.been.ConfigurationTable;
+import com.example.jinyu_rfid.callback.ItemClickCall;
+import com.example.jinyu_rfid.databinding.ItemConfigurationBinding;
+
+import java.util.List;
+
+/**
+ * @author wanghao
+ * @date 2024/5/17 15:35
+ */
+public class ConfigurationTableAdapter extends RecyclerView.Adapter {
+ private Context context;
+ private LayoutInflater inflater;
+ private ItemClickCall call;
+ private List list;
+ public ConfigurationTableAdapter(Context context, ItemClickCall call) {
+ this.context = context;
+ this.call = call;
+ inflater=LayoutInflater.from(context);
+ }
+
+ public void setList(List list) {
+ this.list = list;
+ }
+
+ @NonNull
+ @Override
+ public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
+ ItemConfigurationBinding binding= DataBindingUtil.inflate(inflater, R.layout.item_configuration,parent,false);
+ return new MyViewHolder(binding);
+ }
+
+ @Override
+ public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
+ var item = list.get(position);
+ holder.binding.setVariable(BR.item,item);
+ holder.binding.executePendingBindings();
+ }
+
+ @Override
+ public int getItemCount() {
+ return list==null?0:list.size();
+ }
+
+ class MyViewHolder extends RecyclerView.ViewHolder {
+ private ItemConfigurationBinding binding;
+
+ public MyViewHolder(ItemConfigurationBinding binding) {
+ super(binding.getRoot());
+ this.binding = binding;
+ }
+
+
+ }
+
+}
diff --git a/app/src/main/java/com/example/jinyu_rfid/base/BaseActivity.java b/app/src/main/java/com/example/jinyu_rfid/base/BaseActivity.java
index 21acb2a..7118e3b 100644
--- a/app/src/main/java/com/example/jinyu_rfid/base/BaseActivity.java
+++ b/app/src/main/java/com/example/jinyu_rfid/base/BaseActivity.java
@@ -38,9 +38,8 @@ import okhttp3.MediaType;
public class BaseActivity extends AppCompatActivity {
- public static final int CAMERA_PHOTO = 1;
- public static String url = "http://175.27.215.92:7018/prod-api";
- // public static String url = "http://10.11.40.120:7018/dev-api";
+
+ public static String url = "http://rfidtest.jinyutyres.com:8199/rfid";
public ProgressDialog dialog;
public Gson gson;
public MediaType JSON = MediaType.parse("application/json; charset=utf-8");
diff --git a/app/src/main/java/com/example/jinyu_rfid/base/MyRecultCall.java b/app/src/main/java/com/example/jinyu_rfid/base/MyRecultCall.java
index 5cf3766..afc3b9f 100644
--- a/app/src/main/java/com/example/jinyu_rfid/base/MyRecultCall.java
+++ b/app/src/main/java/com/example/jinyu_rfid/base/MyRecultCall.java
@@ -31,7 +31,7 @@ public class MyRecultCall extends AbsCallback {
if (body == null) return null;
Gson gson = new Gson();
MyResult resust = gson.fromJson(body.string(), MyResult.class);
- resust.setData(gson.toJson(resust.getData()));
+ resust.setJson(gson.toJson(resust.getResultData()));
return resust;
}
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 a1f5098..59fb00b 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
@@ -5,49 +5,40 @@ package com.example.jinyu_rfid.base;
* @date 2023/12/21 15:31
*/
public class MyResult {
- private int code;
- private String msg;
- private Object data;
- private Object rows;
- private int total;
+ private int ExcuteFlag;
+ private String VerifyMessage;
+ private Object ResultData;
+ private String json;
- public int getTotal() {
- return total;
+ public String getJson() {
+ return json;
}
- public void setTotal(int total) {
- this.total = total;
+ public void setJson(String json) {
+ this.json = json;
}
- public Object getRows() {
- return rows;
+ public int getExcuteFlag() {
+ return ExcuteFlag;
}
- public void setRows(Object rows) {
- this.rows = rows;
+ public void setExcuteFlag(int excuteFlag) {
+ ExcuteFlag = excuteFlag;
}
- public int getCode() {
- return code;
+ public String getVerifyMessage() {
+ return VerifyMessage;
}
- public void setCode(int code) {
- this.code = code;
+ public void setVerifyMessage(String verifyMessage) {
+ VerifyMessage = verifyMessage;
}
- public String getMsg() {
- return msg;
+ public Object getResultData() {
+ return ResultData;
}
- public void setMsg(String msg) {
- this.msg = msg;
- }
-
- public Object getData() {
- return data;
- }
-
- public void setData(Object data) {
- this.data = data;
+ public void setResultData(Object resultData) {
+ ResultData = resultData;
}
}
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
new file mode 100644
index 0000000..519efaa
--- /dev/null
+++ b/app/src/main/java/com/example/jinyu_rfid/been/ConfigurationData.java
@@ -0,0 +1,49 @@
+package com.example.jinyu_rfid.been;
+
+import androidx.databinding.BaseObservable;
+
+import org.litepal.crud.LitePalSupport;
+
+/**
+ * @author wanghao
+ * @date 2024/5/15 15:02
+ */
+public class ConfigurationData extends BaseObservable {
+
+ private int index;
+ private String projectName;
+ private boolean state;
+
+ public ConfigurationData(int index, String projectName, boolean state) {
+ this.index = index;
+ this.projectName = projectName;
+ this.state = state;
+ }
+
+ public ConfigurationData() {
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public void setIndex(int index) {
+ this.index = index;
+ }
+
+ public String getProjectName() {
+ return projectName;
+ }
+
+ public void setProjectName(String projectName) {
+ this.projectName = projectName;
+ }
+
+ public boolean isState() {
+ return state;
+ }
+
+ public void setState(boolean state) {
+ this.state = state;
+ }
+}
diff --git a/app/src/main/java/com/example/jinyu_rfid/been/LoginResult.java b/app/src/main/java/com/example/jinyu_rfid/been/LoginResult.java
new file mode 100644
index 0000000..fa85685
--- /dev/null
+++ b/app/src/main/java/com/example/jinyu_rfid/been/LoginResult.java
@@ -0,0 +1,26 @@
+package com.example.jinyu_rfid.been;
+
+/**
+ * @author wanghao
+ * @date 2024/5/17 14:18
+ */
+public class LoginResult {
+
+ private String VerifyMessage,VerifyFlag;
+
+ public String getVerifyMessage() {
+ return VerifyMessage;
+ }
+
+ public void setVerifyMessage(String verifyMessage) {
+ VerifyMessage = verifyMessage;
+ }
+
+ public String getVerifyFlag() {
+ return VerifyFlag;
+ }
+
+ public void setVerifyFlag(String verifyFlag) {
+ VerifyFlag = verifyFlag;
+ }
+}
diff --git a/app/src/main/java/com/example/jinyu_rfid/rfid/C5106Device.java b/app/src/main/java/com/example/jinyu_rfid/rfid/C5106Device.java
index b5e3593..97953b8 100644
--- a/app/src/main/java/com/example/jinyu_rfid/rfid/C5106Device.java
+++ b/app/src/main/java/com/example/jinyu_rfid/rfid/C5106Device.java
@@ -2,14 +2,23 @@ package com.example.jinyu_rfid.rfid;
import android.util.Log;
+import com.handheld.uhfr.UHFRManager;
+
/**
* @author wanghao
* @date 2024/5/16 15:12
*/
public class C5106Device implements RFIDModel{
+ private UHFRManager uhfrManager;
- @Override
- public void openModel() {
- Log.e("TAG", "openModel:" + 123);
+ public C5106Device() {
+ uhfrManager=UHFRManager.getInstance();
}
+ //
+ // public boolean getTagData(int mbank, int startaddr, int len,
+ // byte[] rdata, byte[] password, short timeout){
+ //
+ // }
+
+
}
diff --git a/app/src/main/java/com/example/jinyu_rfid/rfid/RFIDModel.java b/app/src/main/java/com/example/jinyu_rfid/rfid/RFIDModel.java
index 864d566..d634ba3 100644
--- a/app/src/main/java/com/example/jinyu_rfid/rfid/RFIDModel.java
+++ b/app/src/main/java/com/example/jinyu_rfid/rfid/RFIDModel.java
@@ -5,5 +5,5 @@ package com.example.jinyu_rfid.rfid;
* @date 2024/5/16 15:12
*/
public interface RFIDModel {
- void openModel();
+
}
diff --git a/app/src/main/res/layout/activity_configuration_table.xml b/app/src/main/res/layout/activity_configuration_table.xml
index 61500a7..39b043e 100644
--- a/app/src/main/res/layout/activity_configuration_table.xml
+++ b/app/src/main/res/layout/activity_configuration_table.xml
@@ -7,6 +7,9 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ android:layout_height="50dp"
+ android:layout_margin="15dp">
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index f19aead..1c25fd2 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -32,15 +32,18 @@
@@ -48,16 +51,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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 e92963a..f7274a5 100644
--- a/app/src/main/res/values-en-rUS/strings.xml
+++ b/app/src/main/res/values-en-rUS/strings.xml
@@ -5,7 +5,7 @@
login
Remember me
language :
- Configuration
+ app configuration
save
Tire number
read epc
@@ -13,4 +13,5 @@
go info reading
go configuration
epc number
+ add item
\ 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 0674ede..8b5e863 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -12,5 +12,6 @@
信息写入
信息读取
写入配置
- epc编码>
+ epc编码
+ 添加项目>
\ No newline at end of file
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 37b988a..17f7c55 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -11,4 +11,9 @@
- 18sp
- center
+
\ No newline at end of file