完成 绑定
parent
f7b1ea50aa
commit
0810f5ae96
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,14 @@
|
||||
package com.example.bgsrfidtrack;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
public class UnBindingActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_un_binding);
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.example.bgsrfidtrack.adapter;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2024/7/10 9:39
|
||||
*/
|
||||
public interface AdapterClickCall {
|
||||
void deleteItem(int index);
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package com.example.bgsrfidtrack.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.bgsrfidtrack.R;
|
||||
import com.example.bgsrfidtrack.databinding.ItemGoodsInfoBinding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2024/7/10 15:30
|
||||
*/
|
||||
public class GoodsInfoAdapter extends RecyclerView.Adapter<GoodsInfoAdapter.MyViewHolder> {
|
||||
private Context context;
|
||||
private List<String> list;
|
||||
private LayoutInflater inflater;
|
||||
private AdapterClickCall call;
|
||||
|
||||
public GoodsInfoAdapter(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) {
|
||||
ItemGoodsInfoBinding binding = DataBindingUtil.inflate(inflater, R.layout.item_goods_info, 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 ItemGoodsInfoBinding binding;
|
||||
|
||||
public MyViewHolder(ItemGoodsInfoBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.example.bgsrfidtrack.model;
|
||||
|
||||
import androidx.databinding.BaseObservable;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2024/7/10 15:12
|
||||
*/
|
||||
public class BindingModel extends BaseObservable {
|
||||
private String barCode;
|
||||
private String epc;
|
||||
private String localtion;
|
||||
private String number;
|
||||
private String weight;
|
||||
|
||||
|
||||
public String getLocaltion() {
|
||||
return localtion;
|
||||
}
|
||||
|
||||
public void setLocaltion(String localtion) {
|
||||
this.localtion = localtion;
|
||||
notifyChange();
|
||||
}
|
||||
|
||||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(String number) {
|
||||
this.number = number;
|
||||
notifyChange();
|
||||
}
|
||||
|
||||
public String getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public void setWeight(String weight) {
|
||||
this.weight = weight;
|
||||
notifyChange();
|
||||
}
|
||||
|
||||
public String getBarCode() {
|
||||
return barCode;
|
||||
}
|
||||
|
||||
public void setBarCode(String barCode) {
|
||||
this.barCode = barCode;
|
||||
notifyChange();
|
||||
}
|
||||
|
||||
public String getEpc() {
|
||||
return epc;
|
||||
}
|
||||
|
||||
public void setEpc(String epc) {
|
||||
this.epc = epc;
|
||||
notifyChange();
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package com.example.bgsrfidtrack.uitls;
|
||||
|
||||
/**
|
||||
* @author: wangh
|
||||
* @description: Ass
|
||||
* @date: 2019/06/20-15:18
|
||||
*/
|
||||
public class ASCIIUtil {
|
||||
|
||||
// String明文转ASCII码hex字符串,一个明文字符生成两个字符表示的16进制ASCII码
|
||||
public static String str2Hex(String str) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
char c = str.charAt(i);
|
||||
// 这里的第二个参数16表示十六进制
|
||||
sb.append(Integer.toString(c, 16));
|
||||
// 或用toHexString方法直接转成16进制
|
||||
// sb.append(Integer.toHexString(c));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// ASCII码hex字符串转String明文
|
||||
public static String hex2Str(String hex) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < hex.length() - 1; i += 2) {
|
||||
String h = hex.substring(i, (i + 2));
|
||||
int decimal = Integer.parseInt(h, 16);
|
||||
sb.append((char) decimal);
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
public static String hexTo4ZN(String hex) throws Exception {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < hex.length() - 1; i += 4) {
|
||||
String h = hex.substring(i, (i + 4));
|
||||
|
||||
sb.append((char) Integer.parseInt(h, 16));
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static String str4Hex(String str) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
String s = Integer.toString(str.charAt(i), 16);
|
||||
sb.append(s.length()==2?"00"+s:s);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
public static String convertToAscii(String chineseText) {
|
||||
StringBuilder asciiText = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < chineseText.length(); i++) {
|
||||
char c = chineseText.charAt(i);
|
||||
int asciiValue = (int) c;
|
||||
|
||||
asciiText.append(asciiValue).append(" ");
|
||||
}
|
||||
|
||||
return asciiText.toString().trim();
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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">
|
||||
|
||||
</LinearLayout>
|
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:orientation="horizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="50dp">
|
||||
|
||||
<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_delete" />
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
Binary file not shown.
After Width: | Height: | Size: 1.0 KiB |
Binary file not shown.
Loading…
Reference in New Issue