完成 手动地标绑定
parent
42d2bff843
commit
464bcfa2bf
Binary file not shown.
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
@ -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 |
Loading…
Reference in New Issue