增加 配置

master
wangh 6 months ago
parent fbcb4d5c4c
commit fa86e651ce

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

@ -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<ConfigurationTable> list;
private List<ConfigurationData> 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) {
}
}

@ -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.<MyResult>post(url+"/auth/pdaLogin")
.upRequestBody(RequestBody.create(JSON, gson.toJson(loginVm)))
Map<String, String> 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.<MyResult>post(url + "/login")
.upRequestBody(RequestBody.create(JSON, gson.toJson(map)))
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> 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<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);
intent.putExtra("json",response.body());
startActivity(intent);
finish();
Toast.makeText(MainActivity.this, loginResult.getVerifyMessage(), Toast.LENGTH_SHORT).show();
}
}
});*/
});
}
}

@ -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("")
}
}

@ -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 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");

@ -31,7 +31,7 @@ public class MyRecultCall extends AbsCallback<MyResult> {
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;
}

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

@ -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 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){
//
// }
}

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

@ -7,6 +7,9 @@
<variable
name="title"
type="String" />
<variable
name="adapter"
type="com.example.jinyu_rfid.adapter.ConfigurationTableAdapter" />
</data>
<LinearLayout
@ -18,19 +21,88 @@
<include
layout="@layout/toolbar"
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
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="5dp"
android:adapter="@{adapter}"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
android:background="@color/white" />
<Button
<LinearLayout
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_margin="16dp"
android:textSize="20sp"
android:text="@string/configuration_save"/>
android:layout_height="50dp"
android:layout_margin="15dp">
<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>
</layout>

@ -32,15 +32,18 @@
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginTop="12dp"
android:layout_marginRight="20dp"
android:hint="@string/user_name">
<EditText
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}" />
</com.google.android.material.textfield.TextInputLayout>
@ -48,16 +51,16 @@
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout2"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:layout_marginTop="12dp"
android:layout_marginRight="20dp"
android:hint="@string/pass_word"
app:passwordToggleEnabled="true">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:imeOptions="actionDone"
android:inputType="textPassword"
@ -69,7 +72,7 @@
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="15dp"
android:layout_marginTop="12dp"
android:layout_marginRight="20dp">
<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="remember_me">Remember me</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="tire_number">Tire number</string>
<string name="read_epc">read epc</string>
@ -13,4 +13,5 @@
<string name="go_read">go info reading</string>
<string name="go_configuration">go configuration</string>
<string name="epc_code">epc number</string>
<string name="configuration_add">add item</string>
</resources>

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

@ -11,4 +11,9 @@
<item name="android:textSize">18sp</item>
<item name="android:gravity">center</item>
</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>
Loading…
Cancel
Save