Ejemplo n.º 1
0
 public void setGroupCheck(boolean isCheck, int groupPosition) {
   for (ShoppingCart.BuyCarListBean.GoodslistBean goods : getGroup(groupPosition).getGoodslist()) {
     if (isCheck) {
       goods.setIsCheck(1);
     } else {
       goods.setIsCheck(0);
     }
   }
   notifyDataSetChanged();
 }
Ejemplo n.º 2
0
 public boolean isInvalid() {
   int allSize = 0, invalidSize = 0;
   for (ShoppingCart.BuyCarListBean goods : list) {
     allSize += goods.getGoodslist().size();
     for (ShoppingCart.BuyCarListBean.GoodslistBean goodslist : goods.getGoodslist()) {
       if ("YES".equals(goodslist.getIsInvalid()) && "YES".equals(goodslist.getIsOff())) {
         invalidSize++;
       }
     }
   }
   return allSize == invalidSize;
 }
Ejemplo n.º 3
0
 public String getSelectString() {
   List<SubmitShop> selectList = new ArrayList<>();
   for (ShoppingCart.BuyCarListBean goods : list) {
     for (ShoppingCart.BuyCarListBean.GoodslistBean goodslist : goods.getGoodslist()) {
       if (1 == goodslist.getIsCheck()) {
         SubmitShop submitShop = new SubmitShop();
         submitShop.setCount(goodslist.getCount());
         submitShop.setGoodsId(goodslist.getGoodsId());
         selectList.add(submitShop);
       }
     }
   }
   if (selectList.size() > 0) return GsonUtils.toJson(selectList);
   else return "";
 }
Ejemplo n.º 4
0
  public int getSelectSize() {
    int select = 0;
    for (ShoppingCart.BuyCarListBean goods : list) {
      for (ShoppingCart.BuyCarListBean.GoodslistBean goodslist : goods.getGoodslist()) {
        if ("YES".equals(goodslist.getIsInvalid()) || "YES".equals(goodslist.getIsOff())) {

        } else {
          if (1 == goodslist.getIsCheck()) {
            select++;
          }
        }
      }
    }
    return select;
  }
Ejemplo n.º 5
0
 public void setAllGroupCheck(boolean isCheck) {
   for (ShoppingCart.BuyCarListBean goods : list) {
     goods.setSelect(isCheck);
     for (ShoppingCart.BuyCarListBean.GoodslistBean goodslist : goods.getGoodslist()) {
       if (!"YES".equals(goodslist.getIsInvalid()) && !"YES".equals(goodslist.getIsOff())) {
         if (isCheck) {
           goodslist.setIsCheck(1);
         } else {
           goodslist.setIsCheck(0);
         }
       }
     }
   }
   notifyDataSetChanged();
 }
Ejemplo n.º 6
0
  @Override
  public View getGroupView(
      final int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
    GroupHolder holder;
    if (convertView == null) {
      convertView = View.inflate(context, R.layout.adapter_shopping_cart_parent_item, null);
      holder = new GroupHolder(convertView);
      convertView.setTag(holder);
    } else {
      holder = (GroupHolder) convertView.getTag();
    }
    final ShoppingCart.BuyCarListBean buyCarListBean = getGroup(groupPosition);
    int select = 0;
    for (ShoppingCart.BuyCarListBean.GoodslistBean goodslistBean1 : buyCarListBean.getGoodslist()) {
      if ("YES".equals(goodslistBean1.getIsInvalid()) || "YES".equals(goodslistBean1.getIsOff())) {

      } else {
        if (1 == goodslistBean1.getIsCheck()) {
          select++;
        }
      }
    }

    if (select == getRealChildrenCount(groupPosition)) {
      buyCarListBean.setSelect(true);
    } else {
      buyCarListBean.setSelect(false);
    }
    holder.tvGoodsSortName.setText(buyCarListBean.getGoodscategoryName());
    holder.cbGroup.setChecked(buyCarListBean.isSelect());
    holder.cbGroup.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onGoodsSelectListener.onGroupGoodsSelect(groupPosition);
          }
        });
    return convertView;
  }
Ejemplo n.º 7
0
 public String getSelectMoney() {
   double selectMoney = 0;
   for (ShoppingCart.BuyCarListBean goods : list) {
     for (ShoppingCart.BuyCarListBean.GoodslistBean goodslist : goods.getGoodslist()) {
       if (1 == goodslist.getIsCheck()
           && !"YES".equals(goodslist.getIsInvalid())
           && !"YES".equals(goodslist.getIsOff())) {
         selectMoney += goodslist.getNewPrice() * goodslist.getCount();
       }
     }
   }
   return StringUtils.doubleTo(selectMoney);
 }
Ejemplo n.º 8
0
  public String getSaveMoney() {
    double oldMoney = 0;
    for (ShoppingCart.BuyCarListBean goods : list) {
      for (ShoppingCart.BuyCarListBean.GoodslistBean goodslist : goods.getGoodslist()) {
        if ("YES".equals(goodslist.getIsInvalid()) || "YES".equals(goodslist.getIsOff())) {

        } else {
          if (1 == goodslist.getIsCheck()) {
            oldMoney += goodslist.getOldPrice() * goodslist.getCount();
          }
        }
      }
    }
    return StringUtils.doubleTo(oldMoney - Double.valueOf(getSelectMoney()));
  }
Ejemplo n.º 9
0
  public boolean isAllChecked() {
    double allSize = 0, selectSize = 0;
    for (ShoppingCart.BuyCarListBean goods : list) {
      allSize += goods.getGoodslist().size();
      for (ShoppingCart.BuyCarListBean.GoodslistBean goodslist : goods.getGoodslist()) {

        if ("YES".equals(goodslist.getIsInvalid()) || "YES".equals(goodslist.getIsOff())) {

        } else {
          if (1 == goodslist.getIsCheck()) {
            selectSize++;
          }
        }

        if ("YES".equals(goodslist.getIsInvalid()) || "YES".equals(goodslist.getIsOff())) {
          allSize--;
        }
      }
    }
    if (allSize > 0 || selectSize > 0) return allSize == selectSize;
    else return false;
  }
Ejemplo n.º 10
0
  @Override
  public View getRealChildView(
      final int groupPosition,
      final int childPosition,
      boolean isLastChild,
      View convertView,
      ViewGroup parent) {
    ChildHolder holder;
    if (convertView == null) {
      convertView = inflater.inflate(R.layout.adapter_shopping_cart_child_item, parent, false);
      holder = new ChildHolder(convertView);
      convertView.setTag(holder);
    } else {
      holder = (ChildHolder) convertView.getTag();
    }
    final ShoppingCart.BuyCarListBean.GoodslistBean goodslistBean =
        getChild(groupPosition, childPosition);
    holder.tvGoodsName.setText(goodslistBean.getShampooName());
    holder.tvGoodsMoney.setText("¥" + goodslistBean.getNewPrice());
    holder.tvGoodsSort.setText(goodslistBean.getEfficacy());
    holder.tvGoodsOldMoney.setText("¥" + goodslistBean.getOldPrice());
    holder
        .tvGoodsOldMoney
        .getPaint()
        .setFlags(Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG); // 中划线
    holder.qvNum.setMinValue(1);
    holder.qvNum.setMaxValue(goodslistBean.getStockcount());
    holder.qvNum.setValue(StringUtils.toString(goodslistBean.getCount()));
    ImageLoader.getInstance().displayImage(goodslistBean.getImgUrl(), holder.ivGoodsImage, options);
    if ("YES".equals(goodslistBean.getIsInvalid()) || "YES".equals(goodslistBean.getIsOff())) {
      holder.tvInvalid.setVisibility(View.VISIBLE);
      holder.cbChild.setVisibility(View.INVISIBLE);
      holder.tvInvalid.setClickable(false);
      holder.cbChild.setChecked(false);
      goodslistBean.setIsCheck(0);
    } else {
      holder.tvInvalid.setVisibility(View.INVISIBLE);
      holder.cbChild.setVisibility(View.VISIBLE);
      if (goodslistBean.getIsCheck() == 0) {
        holder.cbChild.setChecked(false);
      } else {
        holder.cbChild.setChecked(true);
      }
      holder.tvInvalid.setClickable(true);
    }
    holder.cbChild.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onGoodsSelectListener.onChildGoodsSelect(groupPosition, childPosition);
          }
        });
    holder.tvGoodsDel.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            onGoodsDelListener.onGroupGoodsDel(groupPosition, childPosition);
          }
        });
    holder.qvNum.setOnValueChangeListener(
        new QuantityView.OnValueChangeListener() {
          @Override
          public void onValueChange(String value) {
            onGoodsValueChangeListener.onGroupGoodsValueChange(value, groupPosition, childPosition);
          }
        });
    holder.qvNum.setOnBtnClickListener(
        new QuantityView.OnBtnClickListener() {
          @Override
          public void onLessClick(String value) {
            if (onBtnClickListener != null) {
              onBtnClickListener.onLessClick(value, groupPosition, childPosition);
            }
          }

          @Override
          public void onPlusClick(String value) {
            if (onBtnClickListener != null) {
              onBtnClickListener.onPlusClick(value, groupPosition, childPosition);
            }
          }
        });
    holder.ivGoodsImage.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View view) {
            if (onGoodsImageClickListener != null)
              onGoodsImageClickListener.OnGoodsImageClickListener(groupPosition, childPosition);
          }
        });

    List<ShoppingCart.BuyCarListBean.GiftBean> gift = list.get(groupPosition).getGift();
    holder.llGift.removeAllViews();
    if (gift != null
        && gift.size() > 0
        && childPosition == list.get(groupPosition).getGoodslist().size() - 1) {
      for (ShoppingCart.BuyCarListBean.GiftBean giftEntity : gift) {
        View giftView = inflater.inflate(R.layout.view_gift_item, null);
        TextView tvGoodsItem = (TextView) giftView.findViewById(R.id.tvGoodsItem);
        TextView tvGoodsCount = (TextView) giftView.findViewById(R.id.tvGoodsCount);
        tvGoodsItem.setText("[赠品]" + giftEntity.getGiftName());
        tvGoodsCount.setText("X" + giftEntity.getGiftCount());
        holder.llGift.addView(giftView);
      }
    }
    return convertView;
  }