增加 配置

master
wangh 6 months ago
parent fbcb4d5c4c
commit fa86e651ce

@ -3,7 +3,7 @@
<dbname value="rfid" /> <dbname value="rfid" />
<version value="1" /> <version value="1" />
<list> <list>
<mapping class="com.example.jinyu_rfid.been.ConfigurationTable"></mapping>
</list> </list>
</litepal> </litepal>

@ -4,16 +4,54 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil; import androidx.databinding.DataBindingUtil;
import android.os.Bundle; 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.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; 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<ConfigurationTable> list;
private List<ConfigurationData> dataList;
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(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)); 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) {
}
} }

@ -7,6 +7,7 @@ import android.os.Bundle;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.Log; import android.util.Log;
import android.view.View; import android.view.View;
import android.widget.Toast;
import androidx.databinding.DataBindingUtil; 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.BaseActivity;
import com.example.jinyu_rfid.base.MyRecultCall; import com.example.jinyu_rfid.base.MyRecultCall;
import com.example.jinyu_rfid.base.MyResult; 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.databinding.ActivityMainBinding;
import com.example.jinyu_rfid.uitls.SharedPreferencesUtils; import com.example.jinyu_rfid.uitls.SharedPreferencesUtils;
import com.example.jinyu_rfid.been.LoginVm; import com.example.jinyu_rfid.been.LoginVm;
import com.lzy.okgo.OkGo; import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response; import com.lzy.okgo.model.Response;
import org.litepal.LitePal;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -38,10 +44,11 @@ public class MainActivity extends BaseActivity {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
resources = getResources(); resources = getResources();
config = resources.getConfiguration(); 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()); resources.updateConfiguration(config, resources.getDisplayMetrics());
binding = DataBindingUtil.setContentView(this, R.layout.activity_main); binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
// binding.mainLanguage.setSelection(equals?1:0);
loginVm = new LoginVm(); loginVm = new LoginVm();
boolean isRemember = SharedPreferencesUtils.getboolean("isRemember", false); boolean isRemember = SharedPreferencesUtils.getboolean("isRemember", false);
if (isRemember) { if (isRemember) {
@ -65,37 +72,47 @@ public class MainActivity extends BaseActivity {
String name = loginVm.getUsername(); String name = loginVm.getUsername();
var selectLanguage = binding.mainLanguage.getSelectedItem().toString(); var selectLanguage = binding.mainLanguage.getSelectedItem().toString();
config.locale = selectLanguage.equals("中文") ? Locale.CHINA : Locale.ENGLISH; config.locale = selectLanguage.equals("中文") ? Locale.CHINA : Locale.ENGLISH;
SharedPreferencesUtils.putstring("language", selectLanguage);
resources.updateConfiguration(config, resources.getDisplayMetrics());
// this.recreate(); Map<String, String> map = new HashMap<>();
// Intent intent = new Intent(MainActivity.this, ConfigurationTableActivity.class); map.put("UserID", name);
Intent intent = new Intent(MainActivity.this, WriteUserActivity.class); map.put("UserPass", pass);
startActivity(intent); map.put("token", "123456");
finish(); if (pass == null || name == null || pass.isEmpty() || name.isEmpty()) return;
/* if (pass == null || name == null || pass.isEmpty() || name.isEmpty()) return; OkGo.<MyResult>post(url + "/login")
OkGo.<MyResult>post(url+"/auth/pdaLogin") .upRequestBody(RequestBody.create(JSON, gson.toJson(map)))
.upRequestBody(RequestBody.create(JSON, gson.toJson(loginVm)))
.execute(new MyRecultCall(dialog, this) { .execute(new MyRecultCall(dialog, this) {
@Override @Override
public void onSuccess(Response<MyResult> response) { public void onSuccess(Response<MyResult> response) {
super.onSuccess(response); super.onSuccess(response);
var body = response.body(); var body = response.body();
if (body.getCode() == 200) { if (body.getExcuteFlag() == 1) {
// String accessToken = JSONObject.parseObject(body.getData().toString()).get("access_token").toString(); LoginResult loginResult = gson.fromJson(body.getJson(), LoginResult.class);
// Log.e("TAG", "onSuccess:" + accessToken); if (loginResult.getVerifyFlag().equals("1")) {
// SharedPreferencesUtils.putstring("access_token",accessToken); boolean remember = loginVm.isRemember();
boolean remember = loginVm.isRemember(); if (remember) {
if (remember) { SharedPreferencesUtils.putboolean("isRemember", remember);
SharedPreferencesUtils.putboolean("isRemember", remember); SharedPreferencesUtils.putstring("user", name);
SharedPreferencesUtils.putstring("user", name); SharedPreferencesUtils.putstring("pass", pass);
SharedPreferencesUtils.putstring("pass", pass); }
SharedPreferencesUtils.putstring("language", selectLanguage);
resources.updateConfiguration(config, resources.getDisplayMetrics());
List<ConfigurationTable> 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); Toast.makeText(MainActivity.this, loginResult.getVerifyMessage(), Toast.LENGTH_SHORT).show();
intent.putExtra("json",response.body());
startActivity(intent);
finish();
} }
} }
});*/ });
} }
} }

@ -26,7 +26,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall {
binding.setTitle(getString(R.string.activity_name_configuration)); binding.setTitle(getString(R.string.activity_name_configuration));
rfidModel=new C5106Device(); rfidModel=new C5106Device();
rfidModel.openModel();
intent1=new Intent(this, ConfigurationTableActivity.class); intent1=new Intent(this, ConfigurationTableActivity.class);
intent2=new Intent(this, ConfigurationTableActivity.class); intent2=new Intent(this, ConfigurationTableActivity.class);
} }
@ -61,6 +61,7 @@ public class WriteUserActivity extends BaseActivity implements DataReturnCall {
@Override @Override
public void readerCodeInfo(String erCode) { public void readerCodeInfo(String erCode) {
binding.writeTire.setText(erCode); binding.writeTire.setText(erCode);
// OkGo.post(url+"/") // OkGo.post(url+"/readTypeNo")
// .params("")
} }
} }

@ -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<ConfigurationTableAdapter.MyViewHolder> {
private Context context;
private LayoutInflater inflater;
private ItemClickCall call;
private List<ConfigurationData> list;
public ConfigurationTableAdapter(Context context, ItemClickCall call) {
this.context = context;
this.call = call;
inflater=LayoutInflater.from(context);
}
public void setList(List<ConfigurationData> 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;
}
}
}

@ -38,9 +38,8 @@ import okhttp3.MediaType;
public class BaseActivity extends AppCompatActivity { 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://rfidtest.jinyutyres.com:8199/rfid";
// public static String url = "http://10.11.40.120:7018/dev-api";
public ProgressDialog dialog; public ProgressDialog dialog;
public Gson gson; public Gson gson;
public MediaType JSON = MediaType.parse("application/json; charset=utf-8"); public MediaType JSON = MediaType.parse("application/json; charset=utf-8");

@ -31,7 +31,7 @@ public class MyRecultCall extends AbsCallback<MyResult> {
if (body == null) return null; if (body == null) return null;
Gson gson = new Gson(); Gson gson = new Gson();
MyResult resust = gson.fromJson(body.string(), MyResult.class); MyResult resust = gson.fromJson(body.string(), MyResult.class);
resust.setData(gson.toJson(resust.getData())); resust.setJson(gson.toJson(resust.getResultData()));
return resust; return resust;
} }

@ -5,49 +5,40 @@ package com.example.jinyu_rfid.base;
* @date 2023/12/21 15:31 * @date 2023/12/21 15:31
*/ */
public class MyResult { public class MyResult {
private int code; private int ExcuteFlag;
private String msg; private String VerifyMessage;
private Object data; private Object ResultData;
private Object rows; private String json;
private int total;
public int getTotal() { public String getJson() {
return total; return json;
} }
public void setTotal(int total) { public void setJson(String json) {
this.total = total; this.json = json;
} }
public Object getRows() { public int getExcuteFlag() {
return rows; return ExcuteFlag;
} }
public void setRows(Object rows) { public void setExcuteFlag(int excuteFlag) {
this.rows = rows; ExcuteFlag = excuteFlag;
} }
public int getCode() { public String getVerifyMessage() {
return code; return VerifyMessage;
} }
public void setCode(int code) { public void setVerifyMessage(String verifyMessage) {
this.code = code; VerifyMessage = verifyMessage;
} }
public String getMsg() { public Object getResultData() {
return msg; return ResultData;
} }
public void setMsg(String msg) { public void setResultData(Object resultData) {
this.msg = msg; ResultData = resultData;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
} }
} }

@ -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;
}
}

@ -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;
}
}

@ -2,14 +2,23 @@ package com.example.jinyu_rfid.rfid;
import android.util.Log; import android.util.Log;
import com.handheld.uhfr.UHFRManager;
/** /**
* @author wanghao * @author wanghao
* @date 2024/5/16 15:12 * @date 2024/5/16 15:12
*/ */
public class C5106Device implements RFIDModel{ public class C5106Device implements RFIDModel{
private UHFRManager uhfrManager;
@Override public C5106Device() {
public void openModel() { uhfrManager=UHFRManager.getInstance();
Log.e("TAG", "openModel:" + 123);
} }
//
// public boolean getTagData(int mbank, int startaddr, int len,
// byte[] rdata, byte[] password, short timeout){
//
// }
} }

@ -5,5 +5,5 @@ package com.example.jinyu_rfid.rfid;
* @date 2024/5/16 15:12 * @date 2024/5/16 15:12
*/ */
public interface RFIDModel { public interface RFIDModel {
void openModel();
} }

@ -7,6 +7,9 @@
<variable <variable
name="title" name="title"
type="String" /> type="String" />
<variable
name="adapter"
type="com.example.jinyu_rfid.adapter.ConfigurationTableAdapter" />
</data> </data>
<LinearLayout <LinearLayout
@ -18,19 +21,88 @@
<include <include
layout="@layout/toolbar" layout="@layout/toolbar"
app:title='@{title}' /> app:title='@{title}' />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_marginTop="2dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:orientation="horizontal">
<TextView
android:id="@+id/item_index"
style="@style/item_text_style"
android:layout_width="40dp"
android:layout_height="match_parent"
android:text="索引" />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
style="@style/item_text_style"
android:layout_width="70dp"
android:layout_height="match_parent"
android:text="是否写入" />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
style="@style/item_text_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="写入项目" />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
android:id="@+id/item_config_delete"
style="@style/item_text_style"
android:layout_width="63dp"
android:layout_height="match_parent"
android:textColor="#E71717" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:padding="5dp" android:padding="5dp"
android:adapter="@{adapter}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:background="@color/white" /> android:background="@color/white" />
<Button
<LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="55dp" android:layout_height="50dp"
android:layout_margin="16dp" android:layout_margin="15dp">
android:textSize="20sp"
android:text="@string/configuration_save"/> <Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginEnd="8dp"
android:layout_weight="1"
android:textSize="18sp"
android:onClick="configurationAddItem"
android:text="@string/configuration_add" />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:textSize="18sp"
android:layout_weight="1"
android:onClick="configurationSave"
android:text="@string/configuration_save" />
</LinearLayout>
</LinearLayout> </LinearLayout>
</layout> </layout>

@ -32,15 +32,18 @@
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout" android:id="@+id/textInputLayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="55dp" android:layout_height="wrap_content"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginTop="20dp" android:layout_marginTop="12dp"
android:layout_marginRight="20dp" android:layout_marginRight="20dp"
android:hint="@string/user_name"> android:hint="@string/user_name">
<EditText <EditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center"
android:lines="1"
android:maxLines="1"
android:text="@={user.username}" /> android:text="@={user.username}" />
</com.google.android.material.textfield.TextInputLayout> </com.google.android.material.textfield.TextInputLayout>
@ -48,16 +51,16 @@
<com.google.android.material.textfield.TextInputLayout <com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout2" android:id="@+id/textInputLayout2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="55dp" android:layout_height="wrap_content"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginTop="15dp" android:layout_marginTop="12dp"
android:layout_marginRight="20dp" android:layout_marginRight="20dp"
android:hint="@string/pass_word" android:hint="@string/pass_word"
app:passwordToggleEnabled="true"> app:passwordToggleEnabled="true">
<EditText <EditText
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_gravity="center" android:layout_gravity="center"
android:imeOptions="actionDone" android:imeOptions="actionDone"
android:inputType="textPassword" android:inputType="textPassword"
@ -69,7 +72,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="55dp" android:layout_height="55dp"
android:layout_marginLeft="20dp" android:layout_marginLeft="20dp"
android:layout_marginTop="15dp" android:layout_marginTop="12dp"
android:layout_marginRight="20dp"> android:layout_marginRight="20dp">
<TextView <TextView

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="item"
type="com.example.jinyu_rfid.been.ConfigurationData" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="44dp"
android:layout_marginTop="2dp"
android:background="#DEE3E6"
android:orientation="horizontal">
<TextView
android:id="@+id/item_index"
style="@style/item_text_style"
android:layout_width="40dp"
android:layout_height="match_parent"
android:text='@{item.index+""}' />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<CheckBox
style="@style/item_text_style"
android:layout_width="70dp"
android:layout_height="match_parent"
android:checked="@={item.state}" />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
style="@style/item_text_style"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="@{item.projectName}" />
<View
android:layout_width="2dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
android:id="@+id/item_config_delete"
style="@style/item_text_style"
android:layout_width="63dp"
android:layout_height="match_parent"
android:text="删除"
android:textColor="#E71717" />
</LinearLayout>
</layout>

@ -5,7 +5,7 @@
<string name="login_button_name" >login</string> <string name="login_button_name" >login</string>
<string name="remember_me">Remember me</string> <string name="remember_me">Remember me</string>
<string name="language_select">language :</string> <string name="language_select">language :</string>
<string name="activity_name_configuration">Configuration</string> <string name="activity_name_configuration">app configuration</string>
<string name="configuration_save">save</string> <string name="configuration_save">save</string>
<string name="tire_number">Tire number</string> <string name="tire_number">Tire number</string>
<string name="read_epc">read epc</string> <string name="read_epc">read epc</string>
@ -13,4 +13,5 @@
<string name="go_read">go info reading</string> <string name="go_read">go info reading</string>
<string name="go_configuration">go configuration</string> <string name="go_configuration">go configuration</string>
<string name="epc_code">epc number</string> <string name="epc_code">epc number</string>
<string name="configuration_add">add item</string>
</resources> </resources>

@ -12,5 +12,6 @@
<string name="write_in">信息写入</string> <string name="write_in">信息写入</string>
<string name="go_read">信息读取</string> <string name="go_read">信息读取</string>
<string name="go_configuration">写入配置</string> <string name="go_configuration">写入配置</string>
<string name="epc_code">epc编码</string>> <string name="epc_code">epc编码</string>
<string name="configuration_add">添加项目</string>>
</resources> </resources>

@ -11,4 +11,9 @@
<item name="android:textSize">18sp</item> <item name="android:textSize">18sp</item>
<item name="android:gravity">center</item> <item name="android:gravity">center</item>
</style> </style>
<style name="item_text_style">
<item name="android:textColor">#666666</item>
<item name="android:gravity">center</item>
<item name="android:textSize">17sp</item>
</style>
</resources> </resources>
Loading…
Cancel
Save