ReceiptDetailView.java
2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package com.huaheng.mobilewms.refactor;
import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.LinearLayout;
import android.widget.ListPopupWindow;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.huaheng.mobilewms.R;
import com.huaheng.mobilewms.bean.ReceiptDetail;
public class ReceiptDetailView extends LinearLayout {
private Context context;
TextView materialNameView;
TextView materialCodeView;
TextView materialQtyView;
private ReceiptDetail receiptDetail;
private String materialCode;
private String materialName;
private String materialQty;
public ReceiptDetailView(Context context) {
super(context, null);
this.context = context;
LayoutInflater.from(context).inflate(R.layout.view_receipt_detail, this);
materialNameView = findViewById(R.id.materialName);
materialCodeView = findViewById(R.id.materialCode);
materialQtyView = findViewById(R.id.materialQty);
}
public ReceiptDetailView(Context context, AttributeSet attrs) {
super(context, attrs);
this.context = context;
}
public void init(ReceiptDetail receiptDetail) {
this.receiptDetail = receiptDetail;
materialNameView.setText(receiptDetail.getMaterialName());
materialCodeView.setText(receiptDetail.getMaterialCode());
String qty = String.valueOf(receiptDetail.getQty());
if (receiptDetail.getUnit() != null) {
qty = qty + receiptDetail.getUnit();
}
setViewSelected(receiptDetail.isSelected());
materialQtyView.setText(qty);
}
public void viewClicked() {
System.out.println("=========================----" + receiptDetail.getMaterialName());
// this.setBackgroundColor(Color.rgb(125, 125, 125));
if (receiptDetail.isSelected()) {
setViewSelected(false);
} else {
setViewSelected(true);
}
}
public void setViewSelected(boolean selected) {
receiptDetail.setSelected(selected);
if(receiptDetail.getQty() == 30){
System.out.println("==");
}
if (selected) {
this.setBackgroundResource(R.color.tobe_color);
} else {
this.setBackgroundResource(R.color.white);
}
}
public boolean isSelected() {
return this.receiptDetail.isSelected();
}
public void viewLongClicked() {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle("请选择收货数量");
builder.setView(new ReceiptQtySelectorView(context, receiptDetail));
builder.show();
}
}