GoodsItem.java
2.43 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
package com.fish.drp.div;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.drp.R;
import com.drp.mobliemall.utils.MathUtils;
import com.fish.drp.div.util.ImageLoaderUtil;
import com.xiniunet.sdk.drp.domain.OrderLine;
public class GoodsItem extends RelativeLayout {
private Context context;
private OrderLine orderLine;
ImageView ivIcon;
TextView tvDesc,tvPrice,tvCount,tv_item_spec;
public GoodsItem(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context);
}
public GoodsItem(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
public GoodsItem(Context context,OrderLine orderLine) {
super(context);
this.context = context;
this.orderLine = orderLine;
init(context);
setDate();
}
/**
* 初始化
**/
private void init(Context ct) {
View.inflate(ct, R.layout.layout_goods_item, this);
ivIcon = (ImageView) findViewById(R.id.ic_icon);
tvDesc = (TextView) findViewById(R.id.tv_desc);
tvPrice = (TextView) findViewById(R.id.tv_price);
tvCount = (TextView) findViewById(R.id.tv_count);
tv_item_spec = (TextView) findViewById(R.id.tv_item_spec);
}
private void setDate(){
// ivIcon.setImageResource(resId)
ImageLoaderUtil.loadImg(orderLine.getPictureUrl(),
ivIcon, context);
tvDesc.setText(orderLine.getItemName());
tvPrice.setText("¥ "+orderLine.getUnitPrice());
tvCount.setText("x"+orderLine.getQuantity().intValue());
StringBuffer specifAttr = new StringBuffer("");
if(orderLine.getItem() != null){
if (orderLine.getItem().getSpec1AttributeName() != null && !"".equals(orderLine.getItem().getSpec1AttributeName())){
specifAttr.append(orderLine.getItem().getSpec1AttributeName()+" "+orderLine.getItem().getSpec1ValueName());
}
if (orderLine.getItem().getSpec2AttributeName() != null && !"".equals(orderLine.getItem().getSpec2AttributeName())){
specifAttr.append(" "+orderLine.getItem().getSpec2AttributeName()+" "+orderLine.getItem().getSpec2ValueName());
}
if (orderLine.getItem().getSpec3AttributeName() != null && !"".equals(orderLine.getItem().getSpec3AttributeName())){
specifAttr.append(" "+orderLine.getItem().getSpec3AttributeName()+" "+orderLine.getItem().getSpec3ValueName());
}
tv_item_spec.setText(specifAttr.toString());
}
}
}