完成 绑定接口
parent
0810f5ae96
commit
42d2bff843
@ -1,14 +1,43 @@
|
||||
package com.example.bgsrfidtrack;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
public class UnBindingActivity extends AppCompatActivity {
|
||||
import com.example.bgsrfidtrack.adapter.UnBindingGoodsInfoAdapter;
|
||||
import com.example.bgsrfidtrack.base.BaseActivity;
|
||||
import com.example.bgsrfidtrack.databinding.ActivityUnBindingBinding;
|
||||
import com.example.bgsrfidtrack.receiver.MyKeyInfoCall;
|
||||
import com.example.bgsrfidtrack.uitls.ASCIIUtil;
|
||||
|
||||
import cn.pda.serialport.Tools;
|
||||
|
||||
public class UnBindingActivity extends BaseActivity implements MyKeyInfoCall {
|
||||
private UnBindingGoodsInfoAdapter adapter;
|
||||
private ActivityUnBindingBinding binding;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_un_binding);
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_un_binding);
|
||||
initRFID();
|
||||
initKeyRecriver(this);
|
||||
}
|
||||
|
||||
public void unBindingSubmit(View view) {
|
||||
|
||||
}
|
||||
// 扫描RFID
|
||||
@Override
|
||||
public void onkeyDown() {
|
||||
readEPC();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sanEpcCall(String epc) {
|
||||
super.sanEpcCall(epc);
|
||||
binding.unbindingEpc.setText(epc);
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.example.bgsrfidtrack.adapter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.bgsrfidtrack.R;
|
||||
import com.example.bgsrfidtrack.databinding.ItemGoodsInfo2Binding;
|
||||
import com.example.bgsrfidtrack.databinding.ItemGoodsInfoBinding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2024/7/10 15:30
|
||||
*/
|
||||
public class UnBindingGoodsInfoAdapter extends RecyclerView.Adapter<UnBindingGoodsInfoAdapter.MyViewHolder> {
|
||||
private Context context;
|
||||
private List<String> list;
|
||||
private LayoutInflater inflater;
|
||||
private AdapterClickCall call;
|
||||
|
||||
public UnBindingGoodsInfoAdapter(Context context, AdapterClickCall call) {
|
||||
this.context = context;
|
||||
this.call = call;
|
||||
inflater = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public void setList(List<String> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
ItemGoodsInfo2Binding binding = DataBindingUtil.inflate(inflater, R.layout.item_goods_info2, parent, false);
|
||||
return new MyViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
|
||||
var binding = holder.binding;
|
||||
binding.itemCode.setText(list.get(position));
|
||||
binding.itemIndex.setText(position+1+"");
|
||||
binding.itemDelete.setOnClickListener(v -> call.deleteItem(position));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.isEmpty() ? 0 : list.size();
|
||||
}
|
||||
|
||||
static class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
private ItemGoodsInfo2Binding binding;
|
||||
|
||||
public MyViewHolder(ItemGoodsInfo2Binding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,10 +1,115 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".UnBindingActivity">
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
</LinearLayout>
|
||||
<data>
|
||||
<variable
|
||||
name="title"
|
||||
type="String" />
|
||||
|
||||
<variable
|
||||
name="adapter"
|
||||
type="com.example.bgsrfidtrack.adapter.UnBindingGoodsInfoAdapter" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
tools:context=".UnBindingActivity">
|
||||
|
||||
<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/unbinding_epc"
|
||||
style="@style/santextbg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<LinearLayout
|
||||
style="@style/layoutbg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1">
|
||||
|
||||
<TextView
|
||||
style="@style/textbg"
|
||||
android:layout_width="100dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_gravity="right"
|
||||
android:text="货物信息" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/san_text_view"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="45dp">
|
||||
|
||||
<TextView
|
||||
style="@style/textbg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_weight="1"
|
||||
android:text="序号" />
|
||||
|
||||
<TextView
|
||||
style="@style/textbg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_weight="3"
|
||||
android:text="货物条码" />
|
||||
|
||||
<TextView
|
||||
style="@style/textbg"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="45dp"
|
||||
android:text="单票解绑" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:background="#e1e1e1" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:adapter="@{adapter}"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<Button
|
||||
style="@style/buttonbg"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:onClick="unBindingSubmit"
|
||||
android:text="全部解绑" />
|
||||
</LinearLayout>
|
||||
</layout>
|
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="51dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_index"
|
||||
style="@style/textbg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="序号" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_code"
|
||||
style="@style/textbg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="3"
|
||||
android:text="货物条码" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/item_delete"
|
||||
style="@style/textbg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:padding="10dp"
|
||||
android:src="@mipmap/icon_unbind" />
|
||||
|
||||
</LinearLayout>
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1dp"
|
||||
android:layout_marginLeft="8dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:background="#e1e1e1"/>
|
||||
</LinearLayout>
|
||||
</layout>
|
Loading…
Reference in New Issue