增加 RFID扫描
parent
c5f1a42159
commit
feb6624347
Binary file not shown.
Binary file not shown.
@ -0,0 +1,75 @@
|
||||
package com.example.beijing_daxing.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.beijing_daxing.R;
|
||||
import com.example.beijing_daxing.base.AdapterClickCall;
|
||||
import com.example.beijing_daxing.databinding.ItemInBinding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2024/1/16 15:26
|
||||
*/
|
||||
public class InAdapter extends RecyclerView.Adapter<InAdapter.MyViewHolder> {
|
||||
private List<String> list;
|
||||
private Context context;
|
||||
private LayoutInflater inflater;
|
||||
private AdapterClickCall adapterClickCall;
|
||||
public InAdapter(Context context) {
|
||||
this.context = context;
|
||||
inflater=LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public void setAdapterClickCall(AdapterClickCall adapterClickCall) {
|
||||
this.adapterClickCall = adapterClickCall;
|
||||
}
|
||||
|
||||
public void setList(List<String> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
ItemInBinding binding= DataBindingUtil.inflate(inflater, R.layout.item_in,parent,false);
|
||||
return new MyViewHolder(binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
|
||||
String epc=list.get(position);
|
||||
ItemInBinding binding = holder.getBinding();
|
||||
binding.setEpc(epc);
|
||||
binding.setIndex(String.valueOf(position+1));
|
||||
binding.itemButtom.setOnClickListener(v -> {
|
||||
adapterClickCall.clickItem(position);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
public class MyViewHolder extends RecyclerView.ViewHolder {
|
||||
private ItemInBinding binding;
|
||||
|
||||
public MyViewHolder( ItemInBinding binding) {
|
||||
super(binding.getRoot());
|
||||
this.binding = binding;
|
||||
}
|
||||
|
||||
public ItemInBinding getBinding() {
|
||||
return binding;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.example.beijing_daxing.base;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2024/1/16 15:42
|
||||
*/
|
||||
public interface AdapterClickCall {
|
||||
void clickItem(int index);
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.example.beijing_daxing.uitls;
|
||||
|
||||
public class HexAscii {
|
||||
// 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();
|
||||
|
||||
}
|
||||
}
|
@ -1,12 +1,76 @@
|
||||
package com.example.beijing_daxing.vm;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
|
||||
import androidx.databinding.BaseObservable;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.example.beijing_daxing.entity.BaseLocation;
|
||||
import com.example.beijing_daxing.entity.BaseManufacturer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2024/1/11 16:21
|
||||
*/
|
||||
public class InStoreVM {
|
||||
// private List<String>
|
||||
public class InStoreVM extends BaseObservable {
|
||||
private List<String> manus;
|
||||
private List<String> locations;
|
||||
private String binchCode;
|
||||
private int sanLength;
|
||||
private String selectManuText;
|
||||
private String selectLocationText;
|
||||
|
||||
public void selectManus(AdapterView<?> parent, View view, int position, long id) {
|
||||
selectManuText = manus.get(position);
|
||||
}
|
||||
|
||||
public void selectLocation(AdapterView<?> parent, View view, int position, long id) {
|
||||
selectLocationText = locations.get(position);
|
||||
}
|
||||
|
||||
public String getSelectManuText() {
|
||||
return selectManuText;
|
||||
}
|
||||
|
||||
public String getSelectLocationText() {
|
||||
return selectLocationText;
|
||||
}
|
||||
|
||||
public List<String> getManus() {
|
||||
return manus;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getLocations() {
|
||||
return locations;
|
||||
}
|
||||
|
||||
public void initSelect(List<BaseLocation> baseLocationList, List<BaseManufacturer> baseManufacturerList) {
|
||||
manus=new ArrayList<>();
|
||||
locations=new ArrayList<>();
|
||||
baseLocationList.forEach(t -> this.locations.add(t.getLocationCode()));
|
||||
baseManufacturerList.forEach(t -> this.manus.add(t.getManufacturerName()));
|
||||
notifyChange();
|
||||
}
|
||||
|
||||
public String getBinchCode() {
|
||||
return binchCode;
|
||||
}
|
||||
|
||||
public void setBinchCode(String binchCode) {
|
||||
this.binchCode = binchCode;
|
||||
}
|
||||
|
||||
public int getSanLength() {
|
||||
return sanLength;
|
||||
}
|
||||
|
||||
public void setSanLength(int sanLength) {
|
||||
this.sanLength = sanLength;
|
||||
notifyChange();
|
||||
}
|
||||
}
|
||||
|
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.
Loading…
Reference in New Issue