package com.exmyth.ui.model; import java.util.ArrayList;
import java.util.List; public class ProductItem{
//-------------------------以下字段在扫描中需要额外用到-------------------------
protected String productId = ""; //产品id,扫描标签时候会返回该字段
protected String brandName = "";
//-------------------------以上字段在扫描中需要额外用到------------------------- protected String productName = "";
protected String standard = "";
protected String featureDesc = "";
protected String[] productUrls;
protected List<Entry> params = new ArrayList<Entry>(); public ProductItem() {
super();
} public String getProductId() {
return productId;
}
public void setProductId(String productId) {
this.productId = productId;
}
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
} public String getProductName() {
return productName;
} public void setProductName(String productName) {
this.productName = productName;
} public String getStandard() {
return standard;
} public void setStandard(String standard) {
this.standard = standard;
} public String getFeatureDesc() {
return featureDesc;
} public void setFeatureDesc(String featureDesc) {
this.featureDesc = featureDesc;
} public String[] getProductUrls() {
return productUrls;
} public void setProductUrls(String[] productUrls) {
this.productUrls = productUrls;
} public List<Entry> getParams() {
return params;
} public void setParams(List<Entry> params) {
this.params = params;
}
}
package com.exmyth.ui.model; import java.util.ArrayList;
import java.util.List; import android.os.Parcel;
import android.os.Parcelable; public class GoodsItem extends ProductItem implements Parcelable{
private String bindId;
private String produceDate = ""; public GoodsItem() {
super();
} public String getBindId() {
return bindId;
} public void setBindId(String bindId) {
this.bindId = bindId;
} public String getProduceDate() {
return produceDate;
} public void setProduceDate(String produceDate) {
this.produceDate = produceDate;
} @Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
} @Override
public void writeToParcel(Parcel dest, int flags) {
// TODO Auto-generated method stub
dest.writeString(bindId);
dest.writeString(productId);
dest.writeString(standard);
dest.writeString(productName);
dest.writeString(featureDesc);
dest.writeString(brandName);
dest.writeString(produceDate); if(null == productUrls){
dest.writeInt(0);
}else{
dest.writeInt(productUrls.length);
dest.writeStringArray(productUrls);
}
if(null == params || 0 == params.size()){
dest.writeInt(0);
}
else{
dest.writeInt(params.size());
// dest.writeList(params);
dest.writeTypedList(params);
}
} public static final Parcelable.Creator<GoodsItem> CREATOR = new Creator<GoodsItem>() { @Override
public GoodsItem createFromParcel(Parcel source) {
GoodsItem goodsItem = new GoodsItem();
goodsItem.bindId = source.readString();
goodsItem.productId = source.readString();
goodsItem.standard = source.readString();
goodsItem.productName = source.readString();
goodsItem.featureDesc = source.readString();
goodsItem.brandName = source.readString();
goodsItem.produceDate = source.readString(); int length = source.readInt();
String[] productUrls = new String[length];
if(length > 0){
source.readStringArray(productUrls);
}
goodsItem.productUrls = productUrls; int size = source.readInt();
List<Entry> params = new ArrayList<Entry>(size);
if(size > 0){
// source.readList(params, GoodsItem.class.getClassLoader());
source.readTypedList(params, Entry.CREATOR);
}
goodsItem.params = params; return goodsItem;
} @Override
public GoodsItem[] newArray(int size) {
// TODO Auto-generated method stub
return new GoodsItem[size];
}
};
}
package com.exmyth.ui.model; import android.os.Parcel;
import android.os.Parcelable; /*
featureDesc: 产品特色描述
productName: 产品名称
standard:产品规格
type:
name:参数名称
value:参数值
showOrder:显示顺序
*/
public class Entry implements Parcelable{ public static final String PARAM_TYPE_COMBO = "1";
public static final String PARAM_TYPE_TEXT = "2";
public static final String PARAM_TYPE_CONTACT = "3";
public static final String PARAM_TYPE_HYPERLINK = "4";
private String type; // 参数类型 1-下拉 2-文本 3-联系电话 4-链接地址
private String name = ""; // 参数名称
private String[] value; // 参数值
private String showOrder = "0"; // 显示顺序
// public ViewType viewType = ViewType.TEXT; // 控件类型
private int index = 0; // 文本,电话,链接地址的类型为0;控件类型为combo的,默认第一项
private boolean isShow = false; // public enum ViewType {
// COMBO("1"), TEXT("2"), CONTACT("3"), HYPERLINK("4");
//
// String value;
//
// private ViewType(String value) {
// this.value = value;
// }
// } public Entry() {
super();
} public Entry(String type, String name, String[] value, String showOrder) {
this(type, name, value, showOrder, 0);
} public Entry(String type, String name, String[] value, String showOrder,
int index) {
super();
this.type = type;
this.name = name;
this.value = value;
this.showOrder = showOrder;
this.index = index;
} public String getType() {
return type;
} public void setType(String type) {
this.type = type;
} public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public String[] getValue() {
return value;
} public void setValue(String[] value) {
this.value = value;
} public String getShowOrder() {
return showOrder;
} public void setShowOrder(String showOrder) {
this.showOrder = showOrder;
} public int getIndex() {
return index;
} public void setIndex(int index) {
this.index = index;
} public boolean isShow() {
return isShow;
} public void setShow(boolean isShow) {
this.isShow = isShow;
} @Override
public String toString() {
return "Entry [type=" + type + ", name=" + name + ", value="
+ (null == value ? "" : value[index]) + ", index=" + index + "]";
} @Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
} @Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(type);
dest.writeString(name); if(null == value){
dest.writeInt(0);
}else{
dest.writeInt(value.length);
dest.writeStringArray(value);
} dest.writeString(showOrder);
dest.writeInt(index);
} public static final Parcelable.Creator<Entry> CREATOR = new Creator<Entry>() {
@Override
public Entry[] newArray(int size) {
return new Entry[size];
} //将Parcel对象反序列化为UserInfo
@Override
public Entry createFromParcel(Parcel source) {
Entry entry = new Entry();
entry.type = source.readString();
entry.name = source.readString(); int length = source.readInt();
String[] value = new String[length];
if(length > 0){
source.readStringArray(value);
}
entry.value = value; entry.showOrder = source.readString();
entry.index = source.readInt();
return entry;
}
};
}