增加 - 绑定查询物料名称
parent
48c3b9619d
commit
2f266b78f3
@ -0,0 +1,78 @@
|
||||
package com.example.aucma_mes.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.aucma_mes.BR;
|
||||
import com.example.aucma_mes.R;
|
||||
import com.example.aucma_mes.databinding.ItemLayoutBinding;
|
||||
import com.example.aucma_mes.databinding.ItemRepairBinding;
|
||||
import com.example.aucma_mes.entity.DefectBeen;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2023/11/17 17:15
|
||||
*/
|
||||
public class RepairAdapter extends RecyclerView.Adapter<RepairAdapter.CheckAdapterVH> {
|
||||
private Context context;
|
||||
private List<DefectBeen> list;
|
||||
private LayoutInflater from;
|
||||
|
||||
|
||||
public RepairAdapter(Context context) {
|
||||
this.context = context;
|
||||
from = LayoutInflater.from(context);
|
||||
}
|
||||
|
||||
public void setList(List<DefectBeen> list) {
|
||||
this.list = list;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public CheckAdapterVH onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
ItemRepairBinding inflate1 = DataBindingUtil.inflate(from, R.layout.item_repair, parent, false);
|
||||
return new CheckAdapterVH(inflate1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CheckAdapterVH holder, int position) {
|
||||
DefectBeen defectBeen = list.get(position);
|
||||
defectBeen.setIndex(position + 1);
|
||||
ItemRepairBinding databing = holder.getInflate1();
|
||||
databing.setVariable(BR.item, defectBeen);
|
||||
databing.executePendingBindings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list == null ? 0 : list.size();
|
||||
}
|
||||
|
||||
static class CheckAdapterVH extends RecyclerView.ViewHolder {
|
||||
private ItemRepairBinding inflate1;
|
||||
|
||||
public ItemRepairBinding getInflate1() {
|
||||
return inflate1;
|
||||
}
|
||||
|
||||
public CheckAdapterVH(ItemRepairBinding inflate1) {
|
||||
super(inflate1.getRoot());
|
||||
this.inflate1 = inflate1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public interface CheckItemClickCall {
|
||||
void onClick(int positon);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.example.aucma_mes.entity;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2023/11/23 9:57
|
||||
*/
|
||||
public class RepairMeasures {
|
||||
// "repairCode": "6001",
|
||||
//"repairName": "返回生产线"
|
||||
private String repairCode;
|
||||
private String repairName;
|
||||
|
||||
public String getRepairCode() {
|
||||
return repairCode;
|
||||
}
|
||||
|
||||
public void setRepairCode(String repairCode) {
|
||||
this.repairCode = repairCode;
|
||||
}
|
||||
|
||||
public String getRepairName() {
|
||||
return repairName;
|
||||
}
|
||||
|
||||
public void setRepairName(String repairName) {
|
||||
this.repairName = repairName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RepairMeasures{" +
|
||||
"repairCode='" + repairCode + '\'' +
|
||||
", repairName='" + repairName + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.example.aucma_mes.vm;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
|
||||
import androidx.databinding.BaseObservable;
|
||||
|
||||
import com.example.aucma_mes.adapter.CheckAdapter;
|
||||
import com.example.aucma_mes.entity.RepairMeasures;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wanghao
|
||||
* @date 2023/11/23 10:01
|
||||
*/
|
||||
public class RepairVm extends BaseObservable {
|
||||
public String code;//扫描条码
|
||||
private String repairCode;//处理措施
|
||||
|
||||
public List<String> stringList;
|
||||
private List<RepairMeasures> repairList;
|
||||
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
Log.e("TAG", "返修选中措施:" + position);
|
||||
this.repairCode = repairList.get(position).getRepairCode();
|
||||
}
|
||||
public void setRepairList(List<RepairMeasures> repairList) {
|
||||
this.repairList = repairList;
|
||||
stringList = new ArrayList<>(repairList.size());
|
||||
repairList.forEach(t -> stringList.add(t.getRepairName()));
|
||||
notifyChange();
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
notifyChange();
|
||||
}
|
||||
|
||||
public String getRepairCode() {
|
||||
return repairCode;
|
||||
}
|
||||
|
||||
public void setRepairCode(String name) {
|
||||
int i = stringList.indexOf(name);
|
||||
this.repairCode = repairList.get(i).getRepairCode();
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
<variable
|
||||
name="item"
|
||||
type="com.example.aucma_mes.entity.DefectBeen" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginTop="2dp"
|
||||
android:background="#DEE3E6"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/item_index"
|
||||
style="@style/item_text_style"
|
||||
android:layout_width="51dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text='@{item.index+""}' />
|
||||
|
||||
<View
|
||||
android:layout_width="2dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white" />
|
||||
|
||||
<TextView
|
||||
style="@style/item_text_style"
|
||||
android:layout_width="80dp"
|
||||
android:layout_height="match_parent"
|
||||
android:text="@{item.qualityDefectCode}" />
|
||||
|
||||
<View
|
||||
android:layout_width="2dp"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white" />
|
||||
|
||||
<TextView
|
||||
style="@style/item_text_style"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:text="@{item.qualityDefectName}" />
|
||||
|
||||
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
Loading…
Reference in New Issue