コード例 #1
0
  public void initView() {
    submitAreas = new ArrayList<>();
    productnameEditText.setText(productInfo.getProductName());
    phonenumberEditText.setText(productInfo.getMobile());
    mProductIntroduceString = productInfo.getIntroduction();
    // startimeText.setText(DateUtil.timestampToStr(Long.valueOf(productInfo.getStartTime()),
    // "yyyy-MM-dd"));
    // endtimeText.setText(DateUtil.timestampToStr(Long.valueOf(productInfo.getEndTime()),
    // "yyyy-MM-dd"));
    long time = DateUtil.strToTimestamp(productInfo.getEndTime(), Define.FORMAT_YMD);
    if (time > 0) {
      endtimeText.setText(DateUtil.timestampToStr(time, "yyyy-MM-dd"));
    }
    time = DateUtil.strToTimestamp(productInfo.getStartTime(), Define.FORMAT_YMD);
    if (time > 0) {
      startimeText.setText(DateUtil.timestampToStr(time, "yyyy-MM-dd"));
    }
    seeableSwitch.setChecked(productInfo.getIsPublic() == 1 ? true : false);
    putawayableSwitch.setChecked(productInfo.getStatus() == 1 ? true : false);
    numberEdit.setText(productInfo.getProductName());
    opentimeEdit.setText(productInfo.getOpenTime());
    adddressText.setText(productInfo.getAddress());
    levelsetText.setText(productInfo.getGrade() + "星");
    imageList = productInfo.getImageList();
    areaList = productInfo.areaList;
    for (String imageString : productInfo.getImageList()) {
      DeleteImageView imageView = new DeleteImageView(ProductEditActivity.this);
      imageView.showProgress();
      imageView.setLayoutParams(
          new LinearLayout.LayoutParams(pictureLayout.getHeight(), pictureLayout.getHeight()));
      imageView.setImagePath(imageString);
      imageView.setObjectList(imageList);
      imageView.setObject(imageString);
      imageView.dissProgress();
      pictureLayout.addView(imageView, 0);
    }
    mTabs = new ArrayList<String>();
    if (productInfo.getTagList() != null) {

      for (int i = 0; i < productInfo.getTagList().size(); i++) {
        String tabString = productInfo.getTagList().get(i).getName();
        mTabs.add(tabString);
      }
      String cpbqstring = "";
      if (mTabs.size() > 0) {
        for (String t : mTabs) {
          cpbqstring = cpbqstring + t + ",";
        }
        tabsText.setText(cpbqstring.substring(0, cpbqstring.length() - 1));
        tabsText.setTextColor(Color.parseColor("#16B8EB"));
      } else {
        tabsText.setText("请输入产品标签");
        tabsText.setTextColor(Color.parseColor("#d0d0d0"));
      }
    }
    addedProductResourceList = new ArrayList<ProductResource>();
    if (productInfo.getCombination() != null) {
      for (int i = 0; i < productInfo.getCombination().size(); i++) {
        ProductResource productResource = new ProductResource();
        productResource.setLogo(productInfo.getCombination().get(i).getLogo());
        productResource.setPid(productInfo.getCombination().get(i).getId());
        DeleteImageView resourceImage = new DeleteImageView(ProductEditActivity.this);
        resourceImage.setObject(productResource);
        if (addedProductResourceList.size() < 20) {
          addedProductResourceList.add(productResource);
          resourceImage.setProductResourceList(addedProductResourceList);
          resourceImage.setLayoutParams(
              new LinearLayout.LayoutParams(
                  resource_layout.getHeight(), resource_layout.getHeight() + 15));
          resourceImage.setImagePath(productResource.getLogo());
          resource_layout.addView(resourceImage, resource_layout.getChildCount() - 1);
        } else {
          showToast("产品组合最多搭配20个产品!");
          break;
        }
      }
    }
    introduceText.setText("浏览");
    introduceText.setTextColor(Color.parseColor("#16B8EB"));
    catalogList = productInfo.getCatalogList();
    if (catalogList != null) {
      if (productInfo.getCatalogList().size() > 0) {
        catalogText.setText(listCatalogTitletoString());
        catalogText.setTextColor(Color.parseColor("#16B8EB"));
      }
    }
    resetCountNum();
    // 分销
    if (productInfo.getAffiliateStatus() != 0) {
      disributenumText.setText("已设置");
      if (productInfo.getType() == 1) {
        settingWay = SettingWay.MANUAL.type;
      } else {
        settingWay = SettingWay.TEMPLATE.type;
      }
      if (productInfo.getIs_percentage() == 0) {
        paramsSetting = ParamsSetting.SUM.type;
        paramsSettingSum = productInfo.getAffiliate_commission_percentage() + "";
      } else {
        paramsSetting = ParamsSetting.PERCENT.type;
        paramsSettingSum = productInfo.getAffiliate_commission_percentage() + "";
      }
      selectTemplateId = productInfo.getCommission_theme();
    } else {
      disributenumText.setText("未设置");
    }

    if (productInfo.getWebappDefault() == 2) {
      findViewById(R.id.radio_product_context).performClick();
    }
    if (productInfo.getWebappDefault() == 3) {
      findViewById(R.id.radio_product_evaluate).performClick();
    }

    if (checkNextClickable()) {
      next_stepView.setClickable(true);
      next_stepView.setBackgroundResource(R.drawable.blue_retancle_button_selector);
    } else {
      next_stepView.setClickable(false);
      next_stepView.setBackgroundResource(R.color.vd0d0d0);
    }

    paramsMaps = new HashMap<String, String>();
    paramsMaps.put("pid", pid + "");
    paramsMaps.put("name", productnameEditText.getText().toString());
    paramsMaps.put("mobile", phonenumberEditText.getText().toString());
    paramsMaps.put("introduction", mProductIntroduceString);
    paramsMaps.put("class_0", productInfo.getProductClass_0() + "");
    paramsMaps.put("class_1", productInfo.getProductClass_1() + "");
    paramsMaps.put("class_2", productInfo.getProductClass_2() + "");
    paramsMaps.put("isShow", seeableSwitch.isChecked() ? "1" : "0");
    paramsMaps.put("status", putawayableSwitch.isChecked() ? "1" : "3");
    paramsMaps.put(
        "startTime",
        String.valueOf(DateUtil.strToTimestamp(startimeText.getText().toString(), "yyyy-MM-dd")));
    paramsMaps.put(
        "endTime",
        String.valueOf(DateUtil.strToTimestamp(endtimeText.getText().toString(), "yyyy-MM-dd")));
    paramsMaps.put("sku", numberEdit.getText().toString());
    paramsMaps.put("openTime", opentimeEdit.getText().toString());
    paramsMaps.put("address", adddressText.getText().toString());
    paramsMaps.put("webappDefault", "0");
    paramsMaps.put("copyProductId", "0");
    paramsMaps.put(
        "grade",
        levelsetText.getText().equals("未编辑") ? "0" : String.valueOf(levelsetText.getTag()));
    paramsMaps.put("catalog", listCatalogIdtoString());
    paramsMaps.put("imageList", JsonTools.listToJson(imageList));
    paramsMaps.put("tag", mTabs.size() == 0 ? null : JsonTools.listToJson(mTabs));
    paramsMaps.put("combineList", listResourcetoString());
    submitAreas = new ArrayList<>();
    for (int i = 0; i < areaList.size(); i++) {
      SubmitArea area = new SubmitArea();
      area.city_id = areaList.get(i).city_id.id;
      area.country_id = areaList.get(i).country_id.id;
      submitAreas.add(area);
    }
    paramsMaps.put("areaList", JsonTools.listToJson(submitAreas));
    paramsMaps.put("stock", productInfo.getStock() + "");
    paramsMaps.put("marketPrice", productInfo.getMarketPrice());
    paramsMaps.put("unit", productInfo.getUnit());
    paramsMaps.put("minBuy", productInfo.getMinBuy() + "");
    paramsMaps.put("isBook", productInfo.getIsBook() + "");
    paramsMaps.put("isShowStock", productInfo.getIsShowStock() + "");
    paramsMaps.put("returnStatus", productInfo.getReturnStatus() + "");
    paramsMaps.put("affiliateStatus", productInfo.getAffiliateStatus() + "");
    paramsMaps.put("pricePackage", JsonTools.listToJson(productInfo.getPackageList()));
    String commission_string =
        "{  \"type\": "
            + productInfo.getType()
            + ",    \"affiliate_commission\": "
            + productInfo.getAffiliate_commission()
            + ",    \"is_percentage\":"
            + productInfo.getIs_percentage()
            + ",     \"affiliate_commission_percentage\": "
            + productInfo.getAffiliate_commission_percentage()
            + ",     \"commission_theme\":"
            + productInfo.getCommission_theme()
            + "  }";
    paramsMaps.put("commission", commission_string);
  }
コード例 #2
0
  /** 点击下一步 */
  @Click(R.id.tv_next_step)
  void onNextClick() {
    if (productnameEditText.getText().toString().length() < 3) {
      showToast("产品名称长度不得小于3!");
      return;
    }
    if (!startimeText.getText().toString().equals("起始时间")) {
      if (ApiCaller.TimeInService
              - DateUtil.strToTimestamp(startimeText.getText().toString(), "yyyy-MM-dd")
          > 60 * 60 * 24) {
        showToast("上架时间不得小于今天!");
        return;
      }
    }
    if (!endtimeText.getText().toString().equals("结束时间")) {
      long endtime = DateUtil.strToTimestamp(endtimeText.getText().toString(), "yyyy-MM-dd");
      long starttime = DateUtil.strToTimestamp(startimeText.getText().toString(), "yyyy-MM-dd");
      if (endtime - starttime < 0) {
        showToast("下架时必须大过上架时间!");
        return;
      }
    }
    if (mProductIntroduceString == null || mProductIntroduceString.equals("")) {
      showToast("产品介绍不得为空!");
      return;
    }
    paramsMaps.put("stock", productInfo.getStock() + "");
    paramsMaps.put("name", productnameEditText.getText().toString());
    paramsMaps.put("mobile", phonenumberEditText.getText().toString());
    paramsMaps.put("introduction", mProductIntroduceString);
    paramsMaps.put("class_0", productInfo.getProductClass_0() + "");
    paramsMaps.put("class_1", productInfo.getProductClass_1() + "");
    paramsMaps.put("class_2", productInfo.getProductClass_2() + "");
    paramsMaps.put("isShow", seeableSwitch.isChecked() ? "1" : "0");
    paramsMaps.put("status", putawayableSwitch.isChecked() ? "1" : "3");
    paramsMaps.put(
        "startTime",
        String.valueOf(DateUtil.strToTimestamp(startimeText.getText().toString(), "yyyy-MM-dd")));
    paramsMaps.put(
        "endTime",
        String.valueOf(DateUtil.strToTimestamp(endtimeText.getText().toString(), "yyyy-MM-dd")));
    paramsMaps.put("sku", numberEdit.getText().toString());
    paramsMaps.put("openTime", opentimeEdit.getText().toString());
    paramsMaps.put("address", adddressText.getText().toString());
    paramsMaps.put("webappDefault", webappDefault + "");
    paramsMaps.put("copyProductId", "0");
    paramsMaps.put(
        "grade",
        levelsetText.getText().equals("未编辑") ? "0" : String.valueOf(levelsetText.getTag()));
    paramsMaps.put("catalog", listCatalogIdtoString());
    paramsMaps.put("imageList", JsonTools.listToJson(imageList));
    paramsMaps.put("tag", mTabs.size() == 0 ? null : JsonTools.listToJson(mTabs));
    paramsMaps.put("combineList", listResourcetoString());
    submitAreas = new ArrayList<>();
    for (int i = 0; i < areaList.size(); i++) {
      SubmitArea area = new SubmitArea();
      area.city_id = areaList.get(i).city_id.id;
      area.country_id = areaList.get(i).country_id.id;
      submitAreas.add(area);
    }
    paramsMaps.put("areaList", JsonTools.listToJson(submitAreas));

    showProgressDialog();
    ApiCaller.getInstance()
        .saveProductInfo(
            paramsMaps,
            new APISaveProductInfoCallback() {
              @Override
              public void result(String errMsg, int flag) {
                dissmissProgressDialog();
                if (errMsg == null) {
                  if (flag == 0) showToast("保存产品失败");
                  else {
                    showToast("保存成功");
                    setResult(RESULT_OK);
                    finish();
                  }
                } else {
                  showToast(errMsg);
                }
              }
            });
  }