@Override
  public void reduceCount(int position) {
    // TODO Auto-generated method stub
    //		reducePosition=position;
    //		flagPosition=1;
    int temp = (Integer) arrayList_cart.get(position).get("count");
    if (temp > 1) {
      // 这里因为开始设计的时候不合理,所以写的比较乱
      RequestState = 3;
      tempPostionRed = position;
      int temp1 = (Integer) arrayList_cart.get(position).get("count");
      arrayList_cart.get(position).put("count", temp1 - 1);
      ApiClient.modifyCart(
          getActivity(),
          arrayList_cart.get(position).get("id") + "",
          arrayList_cart.get(position).get("count") + "",
          arrayList_cart.get(position).get("express") + "",
          arrayList_cart.get(position).get("p_id") + "",
          arrayList_cart.get(position).get("psku_id") + "",
          networkHelper);
    } else {
      Toast.makeText(getActivity(), "不能再少了", Toast.LENGTH_SHORT).show();
    }

    //		adapter.notifyDataSetChanged();

  }
Exemplo n.º 2
0
  @Override
  public void onClick(View v) {
    String mobile = etNewNumber.getText().toString();
    String checdcode = etCheckCode.getText().toString();
    // TODO Auto-generated method stub
    switch (v.getId()) {
      case R.id.btn_getcheckcode:
        if (mobile.length() != 11) {
          Toast.makeText(ActivityBind.this, "请输入正确地新手机号", Toast.LENGTH_SHORT).show();
        } else {
          requestCode = "CODE";
          ApiClient.getCheckCode(ActivityBind.this, mobile, "3", networkHelper);
        }
        break;
      case R.id.btn_sub:
        if (mobile.length() != 11) {
          Toast.makeText(ActivityBind.this, "请输入正确地新手机号", Toast.LENGTH_SHORT).show();
        } else if (checdcode.length() != 6) {
          Toast.makeText(ActivityBind.this, "请先获取验证码", Toast.LENGTH_SHORT).show();
        } else {
          requestCode = "SUB";
          ApiClient.bindPhone(
              this,
              appContext.getLoginUid() + "",
              etCheckCode.getText().toString(),
              etNewNumber.getText().toString(),
              networkHelper);
          //				requestCode="CHECK";
          //
          //	ApiClient.judgeCheckCode(ActivityBind.this,AppContext.getUsername(),etCheckCode.getText().toString(), "4", appContext.getLoginUid()+"", networkHelper);
        }
        break;
      case R.id.iv_back:
        ActivityBind.this.finish();
        overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
        break;

      default:
        break;
    }
  }
  private void initData() {
    // TODO Auto-generated method stub
    try {
      RequestState = 4;
      // Is_Internet=appContext.getCartListByPage(ShoppingCartActivity.this,
      // appContext.getLoginUid(), networkHelper);
      if (appContext.isLogin()) {
        ApiClient.getCartListByPage(getActivity(), appContext.getLoginUid(), networkHelper);
      }
      // Toast.makeText(ShoppingCartActivity.this, "请检查网络是否连接",Toast.LENGTH_SHORT).show();

    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
 @Override
 public void addCount(int position) {
   // TODO Auto-generated method stub
   //		flagPosition=2;
   //		addPosition=position;
   RequestState = 2;
   tempPostionAdd = position;
   int temp = (Integer) arrayList_cart.get(position).get("count");
   arrayList_cart.get(position).put("count", temp + 1);
   ApiClient.modifyCart(
       getActivity(),
       arrayList_cart.get(position).get("id") + "",
       arrayList_cart.get(position).get("count") + "",
       arrayList_cart.get(position).get("express") + "",
       arrayList_cart.get(position).get("p_id") + "",
       arrayList_cart.get(position).get("psku_id") + "",
       networkHelper);
   //		adapter.notifyDataSetChanged();
 }
  @Override
  public void onClick(View v) {
    // TODO Auto-generated method stub
    switch (v.getId()) {
      case R.id.btn_quguangguang:
        //			//finish();
        //			startActivity(new Intent(getActivity(),HomePageActivity.class));
        //			overridePendingTransition(R.anim.push_right_in,
        //					R.anim.push_right_out);
        //			//finish();
        break;
      case R.id.tv_title_right:
        if (EditState == 1) { // 当前为1状态被点击了
          for (int i = 0; i < arrayList_cart.size(); i++) {
            is_choice[i] = false;
            ((CheckBox) (listView_cart.getChildAt(i)).findViewById(R.id.cb_choice))
                .setChecked(false);
          }
          tv_title_right.setText("完成");
          tv_cart_buy_Ordel.setText("删除");
          EditState = 2;

          //				for (int i = 0; i < arrayList_cart.size(); i++) {
          //					((LinearLayout)
          // (listView_cart.getChildAt(i)).findViewById(R.id.ll_add_reduce)).setVisibility(View.VISIBLE);
          //					((LinearLayout)
          // (listView_cart.getChildAt(i)).findViewById(R.id.ll_cart_detail)).setVisibility(View.GONE);
          //				}
        } else { // 正在显示完成按钮
          EditState = 1;
          for (int i = 0; i < arrayList_cart.size(); i++) {
            is_choice[i] = false;
            ((CheckBox) (listView_cart.getChildAt(i)).findViewById(R.id.cb_choice))
                .setChecked(false);
          }
          is_choice = new boolean[arrayList_cart.size()];
          tv_title_right.setText("编辑");
          tv_cart_buy_Ordel.setText("结算");
        }
        break;
      case R.id.iv_back:
        //			finish();
        //			overridePendingTransition(R.anim.push_right_in,
        //					R.anim.push_right_out);
        break;
      case R.id.tv_cart_buy_or_del: // 点击结算/删除
        boolean[] is_choice_copy = is_choice;
        if (tv_cart_buy_Ordel.getText().toString().equals("删除")) {
          // 执行删除操作
          if (arrayList_cart.size() != 0) {
            for (int i = is_choice_copy.length - 1; i >= 0; i--) {
              if (is_choice_copy[i]) {
                ((CheckBox) (listView_cart.getChildAt(i)).findViewById(R.id.cb_choice))
                    .setChecked(false);
                // 删除购物车
                ApiClient.deleteCart(
                    getActivity(), arrayList_cart.get(i).get("id").toString(), networkHelper);
                arrayList_cart.remove(i);
                RequestState = 1;
                is_choice_copy = deleteByIndex(is_choice, i);
              }
            }
          }

          if (arrayList_cart.size() == 0) {
            ll_cart.setVisibility(View.VISIBLE);
          }

          //	adapter.notifyDataSetChanged();
          is_choice = new boolean[arrayList_cart.size()];
          System.out.println("此时的长度---->" + is_choice.length);
        } else {
          // 执行结算操作
          //	Toast.makeText(getActivity(), "暂时无法结算", Toast.LENGTH_SHORT).show();
          list = new ArrayList<SkuStandard>();
          int j = 0;
          for (int i = 0; i < is_choice_copy.length; i++) {
            if (is_choice_copy[i]) {
              // 讲该货物包装成数据
              SkuStandard tempSku = new SkuStandard();
              int id = (Integer) arrayList_cart.get(i).get("id");
              // int uid=(Integer) arrayList_cart.get(i).get("uid");
              double ori_price =
                  (Double.parseDouble(arrayList_cart.get(i).get("ori_price").toString()));
              double price = (Double.parseDouble(arrayList_cart.get(i).get("price").toString()));
              tempSku.setName(arrayList_cart.get(i).get("name").toString());
              tempSku.setId(id);
              tempSku.setOri_price(ori_price);
              tempSku.setPrice(price);
              tempSku.setNum(arrayList_cart.get(i).get("count").toString());
              tempSku.setCreatetime("unkown");
              tempSku.setIcon_url(arrayList_cart.get(i).get("icon_url").toString());
              tempSku.setProduct_code(arrayList_cart.get(i).get("p_id").toString());
              tempSku.setQuantity(1000);
              tempSku.setSku(arrayList_cart.get(i).get("sku_desc").toString());
              tempSku.setSku_id(arrayList_cart.get(i).get("sku_id").toString());
              tempSku.setProduct_id(arrayList_cart.get(i).get("p_id").toString());
              tempSku.setTaxrate(arrayList_cart.get(i).get("taxrate").toString());
              list.add(tempSku);
              //	j+=1;
            }
          }
          if (list.size() >= 1) {
            Intent intent = new Intent(getActivity(), ConfirmOrdersActivity.class);
            intent.putExtra("SkuStandardList", (Serializable) list);
            startActivity(intent);
            getActivity().overridePendingTransition(R.anim.push_left_in, R.anim.push_left_out);
          } else {
            Toast.makeText(getActivity(), "您还没选择商品", Toast.LENGTH_SHORT).show();
          }
        }
        break;
      default:
        break;
    }
  }