Ejemplo n.º 1
0
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
      case Const.REQUEST_CODE_CAMERA:
        if (Bimp.drr.size() < 3 && resultCode == -1) {
          Bimp.drr.add(Const.phoneName);
          mAdapter.notifyDataSetChanged();
        }
        break;

      case Const.ADDRESS_CODE:
        if (resultCode == RESULT_OK) {
          mLocation = (Location) data.getSerializableExtra("location");
          tvGoodsAddress.setText(mLocation.getLocation());
        }
        break;
    }
  }
Ejemplo n.º 2
0
  /** 提交商品信息 */
  public void submit() {
    if (tvName.getText().toString().equals("")) {
      MyToast.showToast(this, "请填写水果名称", 2);
      return;
    }

    if (tvDescription.getText().toString().equals("")) {
      MyToast.showToast(this, "请填写描述信息", 2);
      return;
    }
    if (tvPrice.getText().toString().equals("")) {
      MyToast.showToast(this, "请填写价格信息", 2);
      return;
    }
    if (tvOldPrice.getText().toString().equals("")) {
      MyToast.showToast(this, "请填写原价格信息", 2);
      return;
    }
    if (tvAddress.getText().toString().equals("")) {
      MyToast.showToast(this, "请填写水果产地", 2);
      return;
    }
    if (tvSpecifications.getText().toString().equals("")) {
      MyToast.showToast(this, "请填写水果规格信息", 2);
      return;
    }
    if (tvGoodsAddress.getText().toString().equals("")) {
      MyToast.showToast(this, "请选择供货点", 2);
      return;
    }

    if (Float.parseFloat(tvOldPrice.getText().toString())
        > Float.parseFloat(tvPrice.getText().toString())) {
      MyToast.showToast(this, "原价格不能大于现价格", 2);
      return;
    }
    if (Bimp.drr.size() == 0) {
      MyToast.showToast(this, "请至少选择一张图片", 2);
      return;
    }

    RequestParams params = new RequestParams();
    params.addBodyParameter("productname", tvName.getText().toString());
    params.addBodyParameter("originPrice", tvOldPrice.getText().toString());
    params.addBodyParameter("preferentPrice", tvPrice.getText().toString());
    params.addBodyParameter("productContent", tvDescription.getText().toString());
    params.addBodyParameter("productAdress", tvAddress.getText().toString());
    params.addBodyParameter("standard", tvSpecifications.getText().toString());
    params.addBodyParameter("pickupLocationId", mLocation.getLocationId() + "");
    params.addBodyParameter("dealerId", PrefsUtil.getInt(this, "userId") + "");
    String[] images = new String[] {};
    String[] is = Bimp.drr.toArray(images);

    for (int i = 0; i < is.length; i++) {
      try {
        Bimp.saveBitmap(
            Bimp.revitionImageSize(is[i]),
            Bimp.FRIENDSPHOTO + is[i].substring(is[i].lastIndexOf("/")));
      } catch (IOException e) {
        e.printStackTrace();
      }
      params.addBodyParameter(
          "browsePicture" + (int) (i + 1),
          new File(Bimp.FRIENDSPHOTO + is[i].substring(is[i].lastIndexOf("/"))));
    }
    loading.setVisibility(View.VISIBLE);
    HttpHelp.getInstance()
        .send(
            HttpMethod.POST,
            UrlContents.URL_ADD_PRODUCT,
            params,
            new RequestCallBack<String>() {

              @Override
              public void onFailure(HttpException arg0, String arg1) {}

              @Override
              public void onSuccess(ResponseInfo<String> responseInfo) {
                loading.setVisibility(View.GONE);
                JSONObject jsonObject = JSONObject.parseObject(responseInfo.result);
                if (jsonObject.getIntValue("status_code") == 0) {
                  MyToast.showToast(PublishFruitActivity.this, "上传添加成功", 2);
                } else {
                  MyToast.showToast(
                      PublishFruitActivity.this, "上传失败," + jsonObject.getIntValue("msg"), 2);
                }
              }
            });
  }