private void addToCarOrder(Good g) { CarOrder o = CarOrder.getCarOrder(context); String shopId = Constants.seller.getShopId(); try { if (!shopId.equals(o.getShopId())) { o = new CarOrder(); } } catch (Exception e) { e.printStackTrace(); } o.setBuyerName(Constants.seller.getShopName()); o.setShopId(shopId); o.setBuyerName(Constants.user.getUserName()); o.setShopKeeperName(Constants.seller.getShopName()); o.setUserId(Constants.user.getUserId()); Integer shopType = Constants.seller.getShopType(); if (shopType != null) { o.setSeaRecordId( shopType.intValue() == Seller.TYPE_FARMER ? null : ((Fisherman) Constants.seller).getSeaRecordId()); } List<Good> goods = o.getOrdersDetail(); if (goods == null) { goods = new ArrayList<Good>(); } g.setNumber(1); goods.add(g); o.setOrdersDetail(goods); CarOrder.saveCarOrder(o, context); }
@Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder vh; if (convertView == null) { convertView = inflater.inflate(R.layout.seller_detail_goods_listview_item, null); vh = new ViewHolder(); vh.image = (ImageView) convertView.findViewById(R.id.id_seller_detail_goods_listview_item_image); vh.goodName = (TextView) convertView.findViewById(R.id.id_seller_detail_goods_listview_item_seaFoodName); vh.specification = (TextView) convertView.findViewById(R.id.seller_detail_goods_listview_item_specification); vh.sellNumber = (TextView) convertView.findViewById(R.id.id_seller_detail_goods_listview_item_salesValue); vh.moneyPer = (TextView) convertView.findViewById(R.id.seller_detail_goods_listview_item_perWeight); vh.addToCarBtn = (Button) convertView.findViewById(R.id.id_seller_detail_goods_listview_item_add_to_car); convertView.setTag(vh); } else { vh = (ViewHolder) convertView.getTag(); } Good g = goods.get(position); IC.getInstance().setForegound(g.getGoodsPhoto(), vh.image); vh.goodName.setText(g.getGoodsName()); vh.specification.setText(g.getSkuString()); vh.sellNumber.setText(g.getSellNumber() + ""); vh.moneyPer.setText(g.getPrice() + "/" + g.getUnit()); vh.addToCarBtn.setOnClickListener(new MyOnClickListener(g)); return convertView; }