完成 手动地标绑定

master
wangh 6 months ago
parent 42d2bff843
commit 464bcfa2bf

@ -39,6 +39,7 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation files('libs\\SerialPort.jar')
implementation files('libs\\uhfcom13_v15.jar')
implementation files('libs\\RflyBlue-1.0.0.aar')
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'

Binary file not shown.

@ -1,6 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<!-- 先前的蓝牙权限需求 -->
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application
android:name=".base.MyApplication"
@ -14,6 +22,12 @@
android:theme="@style/Theme.BGSRFIDTrack"
android:usesCleartextTraffic="true"
tools:targetApi="31">
<activity
android:name=".BindingDBActivity"
android:exported="false" />
<activity
android:name=".RflyActivity"
android:exported="true"></activity>
<activity
android:name=".UnBindingActivity"
android:exported="false" />

@ -82,6 +82,8 @@ public class BindingActivity extends BaseActivity implements MyKeyInfoCall, Adap
// 提交
public void bindingSubmit(View view) {
model.setWatBills(codeList);
model.setUser(SharedPreferencesUtils.getstring("user",""));
OkGo.<MyResult>post("http://"+ SharedPreferencesUtils.getstring("ip","")+
"/api/bindingSubmit")
.upRequestBody(RequestBody.create(JSON, gson.toJson(model)))

@ -0,0 +1,76 @@
package com.example.bgsrfidtrack;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;
import androidx.databinding.DataBindingUtil;
import com.example.bgsrfidtrack.base.BaseActivity;
import com.example.bgsrfidtrack.base.MyRecultCall;
import com.example.bgsrfidtrack.base.MyResult;
import com.example.bgsrfidtrack.base.SharedPreferencesUtils;
import com.example.bgsrfidtrack.databinding.ActivityBindingDbBinding;
import com.example.bgsrfidtrack.receiver.MyKeyInfoCall;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
public class BindingDBActivity extends BaseActivity implements MyKeyInfoCall {
private ActivityBindingDbBinding binding;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_binding_db);
initRFID();
initKeyRecriver(this);
}
public void binddingDbClear1(View view) {
binding.hkEpc.setText(null);
}
public void binddingDbClear2(View view) {
binding.dbEpc.setText(null);
}
public void bindingDbSubmit(View view) {
var hkEpcCode = binding.hkEpc.getText().toString();
var dbEpcCode = binding.dbEpc.getText().toString();
if (hkEpcCode.isEmpty() || dbEpcCode.isEmpty()) {
return;
}
OkGo.<MyResult>post("http://"
+ SharedPreferencesUtils.getstring("ip", "")
+ "/api/blueToothSubmit")
.params("locationCode", dbEpcCode)
.params("hkCode", hkEpcCode)
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
if (response.body().getCode() == 0) {
binding.hkEpc.setText(null);
binding.dbEpc.setText(null);
}
Toast.makeText(context, response.body().getMsg(), Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onkeyDown() {
readEPC();
}
@Override
public void sanEpcCall(String epc) {
super.sanEpcCall(epc);
if (binding.hkEpc.getText().toString().isEmpty()) {
binding.hkEpc.setText(epc);
} else {
binding.dbEpc.setText(epc);
}
}
}

@ -19,13 +19,20 @@ public class HomePageActivity extends BaseActivity {
ActivityHomePageBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_home_page);
Intent intent = new Intent(this, BindingActivity.class);
Intent intent2 = new Intent(this, UnBindingActivity.class);
binding.binding.setOnClickListener(v -> {
Intent intent3 = new Intent(this, BindingDBActivity.class);
Intent intent4 = new Intent(this, UnBindingActivity.class);
binding.homeIn.setOnClickListener(v -> {
startActivity(intent);
});
binding.unBinding.setOnClickListener(v -> {
startActivity(intent2);
});
binding.binding.setOnClickListener(v -> {
startActivity(intent3);
});
binding.homeJiaojie.setOnClickListener(v -> {
startActivity(intent4);
});
}

@ -2,16 +2,21 @@ package com.example.bgsrfidtrack;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableBoolean;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import com.example.bgsrfidtrack.base.BaseActivity;
import com.example.bgsrfidtrack.base.MyRecultCall;
import com.example.bgsrfidtrack.base.MyResult;
import com.example.bgsrfidtrack.base.SharedPreferencesUtils;
import com.example.bgsrfidtrack.databinding.ActivityMain1Binding;
import com.example.bgsrfidtrack.databinding.ActivityMainBinding;
import com.example.bgsrfidtrack.model.LoginModel;
import com.lzy.okgo.OkGo;
@ -21,12 +26,18 @@ import okhttp3.RequestBody;
public class MainActivity extends BaseActivity {
private LoginModel login;
private ObservableBoolean configState;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
// ActivityMain1Binding binding = DataBindingUtil.setContentView(this, R.layout.activity_main1);
login = new LoginModel();
configState=new ObservableBoolean();
configState.set(true);
binding.setConfigState(configState);
boolean isRemember = SharedPreferencesUtils.getboolean("isRemember", false);
if (isRemember) {
login.setUsername(SharedPreferencesUtils.getstring("user", ""));
@ -58,11 +69,17 @@ public class MainActivity extends BaseActivity {
SharedPreferencesUtils.putstring("pass", pass);
SharedPreferencesUtils.putstring("ip", ip);
}
Intent intent = new Intent(MainActivity.this, HomePageActivity.class);
// Intent intent = new Intent(MainActivity.this, RflyActivity.class);
startActivity(intent);
finish();
}
}
});
}
// 改变配置ip栏显示
public void loginConfigChange(View view){
configState.set(!configState.get());
}
}

@ -0,0 +1,231 @@
package com.example.bgsrfidtrack;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableBoolean;
import android.Manifest;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.Rfly.bluereader.ReaderDevice.Rfly;
import com.Rfly.bluereader.exception.ReaderException;
import com.Rfly.bluereader.type.EpcBean;
import com.example.bgsrfidtrack.adapter.AdapterClickCall;
import com.example.bgsrfidtrack.adapter.GoodsInfoAdapter;
import com.example.bgsrfidtrack.base.BaseActivity;
import com.example.bgsrfidtrack.base.MyRecultCall;
import com.example.bgsrfidtrack.base.MyResult;
import com.example.bgsrfidtrack.base.SharedPreferencesUtils;
import com.example.bgsrfidtrack.databinding.ActivityRflyBinding;
import com.example.bgsrfidtrack.uitls.ASCIIUtil;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
public class RflyActivity extends BaseActivity implements Rfly.ConnectCallback, Rfly.ReadTagDataCallback {
private Rfly hbtReader;
private ObservableBoolean state;
private ActivityRflyBinding binding;
private List<String> tagList;
private GoodsInfoAdapter adapter1;
private List<String> list1;
private List<String> listVis;
private GoodsInfoAdapter adapter2;
private List<String> list2;
@SuppressLint("MissingPermission")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_rfly);
checkPermissions();
state = new ObservableBoolean();
state.set(true);
binding.setState(state);
// 初始化
hbtReader = new Rfly(this);
tagList = new ArrayList<>();
// 注册蓝牙扫描
hbtReader.setDeviceCallback(new Rfly.DeviceCallback() {
@Override
public void DeviceCallback(BluetoothDevice bluetoothDevice, String s) {
if (bluetoothDevice != null) {
if (bluetoothDevice.getBondState() == BluetoothDevice.BOND_BONDED && bluetoothDevice.getName() != null &&
bluetoothDevice.getName().equals("RFly-IV166-837248")) {
hbtReader.connect(bluetoothDevice, RflyActivity.this);
}else {
Toast.makeText(context, "扫描不到设备", Toast.LENGTH_SHORT).show();
}
}else {
Toast.makeText(context, "蓝牙扫描失败", Toast.LENGTH_SHORT).show();
}
}
});
hbtReader.setreadTagDataCallback(this);
try {
// 开始扫描
dialog.show();
hbtReader.searchDevice();
} catch (ReaderException e) {
throw new RuntimeException(e);
}
adapter1 = new GoodsInfoAdapter(this, new AdapterClickCall() {
@Override
public void deleteItem(int index) {
list1.remove(index);
listVis.remove(index);
adapter1.notifyDataSetChanged();
}
});
list1 = new ArrayList<>();
listVis = new ArrayList<>();
adapter1.setList(listVis);
binding.setAdapter1(adapter1);
adapter2 = new GoodsInfoAdapter(this, new AdapterClickCall() {
@Override
public void deleteItem(int index) {
list2.remove(index);
adapter2.notifyDataSetChanged();
}
});
list2 = new ArrayList<>();
adapter2.setList(list2);
binding.setAdapter2(adapter2);
}
// 返回RFID
@Override
public void ReadTagDataCallback(EpcBean epcBean) {
var strepc = epcBean.strepc;
if (tagList.contains(strepc)) {
return;
}
tagList.add(strepc);
Log.e("TAG", "ReadTagDataCallback1:" + strepc);
strepc = ASCIIUtil.hex2Str(strepc);
Log.e("TAG", "ReadTagDataCallback2:" + strepc);
Message message = new Message();
message.obj = strepc;
handler.sendMessage(message);
}
private Handler handler = new Handler() {
@Override
public void handleMessage(@NonNull Message msg) {
super.handleMessage(msg);
var str = msg.obj.toString();
if (str.contains("DB")) {
// 地标
list2.add(str);
adapter2.notifyDataSetChanged();
} else if (str.contains("HK")) {
list1.add(str);
var length = str.length();
listVis.add(str.substring(length -4,length));
adapter1.notifyDataSetChanged();
}
}
};
// 读取按钮
public void blueToothSanRFID(View view) {
try {
if (state.get()) {
hbtReader.ScanTags();
state.set(false);
} else {
hbtReader.StopScan();
state.set(true);
}
} catch (ReaderException e) {
e.printStackTrace();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
try {
hbtReader.disconnect();
} catch (ReaderException e) {
throw new RuntimeException(e);
}
hbtReader.destroy();
}
@Override
public void ConnectCallback(boolean b) {
Log.e("TAG", "连接状态:" + b);
dialog.dismiss();
if (b) {
Toast.makeText(context, "连接成功", Toast.LENGTH_SHORT).show();
return;
}
Toast.makeText(context, "蓝牙没有配对", Toast.LENGTH_SHORT).show();
}
/**
*
*/
private void checkPermissions() {
String[] permissions = {android.Manifest.permission.BLUETOOTH_SCAN, android.Manifest.permission.BLUETOOTH_ADVERTISE, android.Manifest.permission.BLUETOOTH_CONNECT, android.Manifest.permission.ACCESS_FINE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.BLUETOOTH};
// List<String> permissionsToRequest = new ArrayList<>();
// for (String permission : permissions) {
// if (ContextCompat.checkSelfPermission(this, permission) != PackageManager.PERMISSION_GRANTED) {
// permissionsToRequest.add(permission);
// }
// }
// if (!permissionsToRequest.isEmpty()) {
ActivityCompat.requestPermissions(this, permissions, 1);
// }
}
// 提交
public void blueToothSubmit(View view) {
if (!state.get()){
Toast.makeText(context, "先停止读取RFID", Toast.LENGTH_SHORT).show();
return;
}
if (list1.isEmpty()||list2.isEmpty()) return;
OkGo.<MyResult>post("http://"+ SharedPreferencesUtils.getstring("ip","") +"/api/blueToothSubmit")
.params("locationCode", list2.get(0))
.params("hkCode", list1.get(0))
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
if (response.body().getCode()==0){
tagList.clear();
list1.clear();
listVis.clear();
list2.clear();
adapter1.notifyDataSetChanged();
adapter2.notifyDataSetChanged();
}
Toast.makeText(RflyActivity.this, response.body().getMsg(), Toast.LENGTH_SHORT).show();
}
});
}
}

@ -6,29 +6,60 @@ import androidx.databinding.DataBindingUtil;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Toast;
import com.example.bgsrfidtrack.adapter.AdapterClickCall;
import com.example.bgsrfidtrack.adapter.UnBindingGoodsInfoAdapter;
import com.example.bgsrfidtrack.base.BaseActivity;
import com.example.bgsrfidtrack.base.MyRecultCall;
import com.example.bgsrfidtrack.base.MyResult;
import com.example.bgsrfidtrack.base.SharedPreferencesUtils;
import com.example.bgsrfidtrack.databinding.ActivityUnBindingBinding;
import com.example.bgsrfidtrack.receiver.MyKeyInfoCall;
import com.example.bgsrfidtrack.uitls.ASCIIUtil;
import com.google.gson.reflect.TypeToken;
import com.lzy.okgo.OkGo;
import com.lzy.okgo.model.Response;
import java.util.List;
import cn.pda.serialport.Tools;
public class UnBindingActivity extends BaseActivity implements MyKeyInfoCall {
public class UnBindingActivity extends BaseActivity implements MyKeyInfoCall, AdapterClickCall {
private UnBindingGoodsInfoAdapter adapter;
private ActivityUnBindingBinding binding;
private List<String> list;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
binding = DataBindingUtil.setContentView(this, R.layout.activity_un_binding);
initRFID();
initKeyRecriver(this);
adapter = new UnBindingGoodsInfoAdapter(this, this);
binding.setAdapter(adapter);
}
// 删除全部
public void unBindingSubmit(View view) {
OkGo.<MyResult>post("http://" + SharedPreferencesUtils.getstring("ip", "") +
"/api/deleteBindingList")
.params("epc", binding.unbindingEpc.getText().toString())
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
var body = response.body();
if (body.getCode() == 0) {
list.clear();
adapter.notifyDataSetChanged();
}
Toast.makeText(UnBindingActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
}
});
}
// 扫描RFID
@Override
public void onkeyDown() {
@ -39,5 +70,52 @@ public class UnBindingActivity extends BaseActivity implements MyKeyInfoCall {
public void sanEpcCall(String epc) {
super.sanEpcCall(epc);
binding.unbindingEpc.setText(epc);
OkGo.<MyResult>post("http://" + SharedPreferencesUtils.getstring("ip", "") +
"/api/findBindingList")
.params("epc", epc)
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
var body = response.body();
if (body.getCode() == 0) {
list = gson.fromJson(body.getData().toString(), new TypeToken<List<String>>() {
}.getType());
adapter.setList(list);
adapter.notifyDataSetChanged();
}else {
if (list!=null){
list.clear();
adapter.notifyDataSetChanged();
}
}
Toast.makeText(UnBindingActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void deleteItem(int index) {
var code = list.get(index);
// 删除一条
OkGo.<MyResult>post("http://" + SharedPreferencesUtils.getstring("ip", "") +
"/api/deleteBindingItem")
.params("epc", binding.unbindingEpc.getText().toString())
.params("code", code)
.execute(new MyRecultCall(dialog, this) {
@Override
public void onSuccess(Response<MyResult> response) {
super.onSuccess(response);
var body = response.body();
if (body.getCode() == 0) {
list.remove(index);
adapter.notifyDataSetChanged();
}
Toast.makeText(UnBindingActivity.this, body.getMsg(), Toast.LENGTH_SHORT).show();
}
});
}
}

@ -52,7 +52,7 @@ public class UnBindingGoodsInfoAdapter extends RecyclerView.Adapter<UnBindingGoo
@Override
public int getItemCount() {
return list.isEmpty() ? 0 : list.size();
return list==null||list.isEmpty() ? 0 : list.size();
}
static class MyViewHolder extends RecyclerView.ViewHolder {

@ -91,7 +91,7 @@ public class BaseActivity extends AppCompatActivity {
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCanceledOnTouchOutside(false);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setMessage("请求网络中...");
dialog.setMessage("loading...");
}
public void initSan() {

@ -15,6 +15,16 @@ public class BindingModel extends BaseObservable {
private String number;
private String weight;
private List<String> watBills;
private String user;
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public List<String> getWatBills() {
return watBills;

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="title"
type="String" />
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".BindingDBActivity">
<include
layout="@layout/title_bar"
app:title='@{title??"地标绑定"}' />
<LinearLayout
style="@style/layoutbg"
android:layout_width="match_parent"
android:layout_height="45dp">
<TextView
style="@style/textbg"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="货框RFID" />
<TextView
android:id="@+id/hk_epc"
style="@style/santextbg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableRight="@mipmap/icon_delete"
android:onClick="binddingDbClear1"
android:paddingRight="5dp" />
</LinearLayout>
<LinearLayout
style="@style/layoutbg"
android:layout_width="match_parent"
android:layout_height="45dp">
<TextView
style="@style/textbg"
android:layout_width="100dp"
android:layout_height="match_parent"
android:text="地标RFID" />
<TextView
android:id="@+id/db_epc"
style="@style/santextbg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableRight="@mipmap/icon_delete"
android:onClick="binddingDbClear2"
android:paddingRight="5dp" />
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="200dp"
android:text="提交"
style="@style/buttonbg"
android:onClick="bindingDbSubmit"/>
</LinearLayout>
</layout>

@ -27,15 +27,15 @@
android:orientation="horizontal">
<RadioButton
android:id="@+id/binding"
android:id="@+id/home_in"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@mipmap/bind"
android:drawableTop="@mipmap/icon_in"
android:drawablePadding="8dp"
android:gravity="center"
android:text="绑定"
android:text="货物入框"
android:textSize="20sp" />
@ -52,6 +52,38 @@
android:textSize="20sp" />
</RadioGroup>
<RadioGroup
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<RadioButton
android:id="@+id/binding"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@mipmap/bind"
android:drawablePadding="8dp"
android:gravity="center"
android:text="绑定地标"
android:textSize="20sp" />
<RadioButton
android:id="@+id/home_jiaojie"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:button="@null"
android:drawableTop="@mipmap/icon_jiaojie"
android:drawablePadding="8dp"
android:gravity="center"
android:text="交接"
android:textSize="20sp" />
</RadioGroup>
</LinearLayout>
</layout>

@ -8,6 +8,11 @@
<variable
name="user"
type="com.example.bgsrfidtrack.model.LoginModel" />
<import type="android.view.View"/>
<variable
name="configState"
type="androidx.databinding.ObservableBoolean" />
</data>
<LinearLayout
@ -15,12 +20,13 @@
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
android:animateLayoutChanges="true"
tools:context=".MainActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="50dp"
android:layout_marginTop="20dp"
android:src="@mipmap/logo" />
<TextView
@ -38,15 +44,15 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginTop="8dp"
android:layout_marginRight="20dp"
android:gravity="center"
android:visibility="@{configState?View.GONE:View.VISIBLE}"
android:hint="请求接口ip:端口">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@={user.ip}" />
@ -57,7 +63,7 @@
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginTop="8dp"
android:layout_marginRight="20dp"
android:hint="用户名">
@ -73,7 +79,7 @@
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginTop="8dp"
android:layout_marginRight="20dp"
android:hint="密码"
app:passwordToggleEnabled="true">
@ -92,7 +98,6 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:checked="@={user.remember}"
android:text="记住我" />
@ -101,13 +106,22 @@
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:letterSpacing="1"
android:onClick="login_click"
android:text="登录"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginRight="20dp"
android:layout_marginTop="8dp"
android:text='@{configState?"配置>>>":"关闭配置"}'
android:gravity="right|center"
android:onClick="loginConfigChange"
android:textSize="18sp"
android:layout_gravity="right"
android:textColor="@color/blue"/>
</LinearLayout>
</layout>

@ -0,0 +1,116 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="user"
type="com.example.bgsrfidtrack.model.LoginModel" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="410dp"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="MissingConstraints">
<TextView
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:gravity="left|center"
android:text="登录RFID辅助追踪系统"
android:textColor="@color/black"
android:textSize="22sp" />
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:gravity="center"
android:hint="请求接口ip:端口">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@={user.ip}" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:hint="用户名">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@={user.username}" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textInputLayout2"
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:hint="密码"
app:passwordToggleEnabled="true">
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:imeOptions="actionDone"
android:inputType="textPassword"
android:text="@={user.password}" />
</com.google.android.material.textfield.TextInputLayout>
<CheckBox
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:checked="@={user.remember}"
android:text="记住我" />
<Button
android:layout_width="match_parent"
android:layout_height="55dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="20dp"
android:letterSpacing="1"
android:onClick="login_click"
android:text="登录"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="title"
type="String" />
<variable
name="state"
type="androidx.databinding.ObservableBoolean" />
<variable
name="adapter1"
type="com.example.bgsrfidtrack.adapter.GoodsInfoAdapter" />
<variable
name="adapter2"
type="com.example.bgsrfidtrack.adapter.GoodsInfoAdapter" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RflyActivity">
<include
android:id="@+id/include"
layout="@layout/title_bar"
app:layout_constraintTop_toTopOf="parent"
app:title='@{title??"叉车车载程序"}' />
<LinearLayout
android:id="@+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="45dp"
app:layout_constraintTop_toBottomOf="@+id/include">
<TextView
style="@style/textbg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="货框RFID" />
<View
android:layout_width="10dp"
android:layout_height="match_parent"
android:background="@color/white" />
<TextView
style="@style/textbg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="地标RFID" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="10dp"
app:layout_constraintBottom_toTopOf="@+id/linearLayout2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout">
<androidx.recyclerview.widget.RecyclerView
style="@style/santextbg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:adapter="@{adapter1}"
android:text="货框RFID"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
<androidx.recyclerview.widget.RecyclerView
style="@style/santextbg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:layout_weight="1"
android:adapter="@{adapter2}"
android:text="地标RFID"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</LinearLayout>
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="10dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<Button
android:id="@+id/button"
style="@style/buttonbg1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="20dp"
android:layout_weight="1"
android:backgroundTint="@{state?@color/blue:@color/yellow}"
android:onClick="blueToothSanRFID"
android:text='@{state?"扫描":"停止"}' />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:onClick="blueToothSubmit"
android:text="提交"
android:layout_weight="1"
style="@style/buttonbg1"/>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

@ -37,5 +37,11 @@
<item name="android:layout_marginRight">16dp</item>
<item name="android:layout_marginBottom">8dp</item>
</style>
<style name="buttonbg1">
<item name="android:textSize">18sp</item>
<item name="android:letterSpacing">1</item>
<item name="android:textStyle">bold</item>
</style>
</resources>
Loading…
Cancel
Save