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); }
public void initData() { next_stepView.setBackgroundResource(R.color.vd0d0d0); next_stepView.setClickable(false); Intent intent = getIntent(); if (intent != null) { pid = intent.getIntExtra(Define.PID, 0); showProgressDialog(); loadproductInfo(pid); } pictureLayout.addOnLayoutChangeListener( new View.OnLayoutChangeListener() { @Override public void onLayoutChange( View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { if (pictureLayout.getWidth() > hs.getWidth() && addTextView1.getVisibility() == View.VISIBLE) { pictureLayout.post( new Runnable() { @Override public void run() { addTextView1.setVisibility(View.GONE); taddTextView2.setVisibility(View.VISIBLE); imageshadowImage.setVisibility(View.VISIBLE); 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); } } }); } else if (pictureLayout.getWidth() <= hs.getWidth()) { pictureLayout.post( new Runnable() { @Override public void run() { addTextView1.setVisibility(View.VISIBLE); taddTextView2.setVisibility(View.GONE); imageshadowImage.setVisibility(View.GONE); 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); } } }); } } }); resource_layout.addOnLayoutChangeListener( new View.OnLayoutChangeListener() { @Override public void onLayoutChange( View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { if (resource_layout.getWidth() > add_resource_layout.getWidth() && add_resource_in.getVisibility() == View.VISIBLE) { resource_layout.post( new Runnable() { @Override public void run() { add_resource_in.setVisibility(View.GONE); add_resource.setVisibility(View.VISIBLE); resourceshadowImage.setVisibility(View.VISIBLE); 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); } } }); } else if (resource_layout.getWidth() <= add_resource_layout.getWidth()) { resource_layout.post( new Runnable() { @Override public void run() { add_resource_in.setVisibility(View.VISIBLE); add_resource.setVisibility(View.GONE); resourceshadowImage.setVisibility(View.GONE); 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); } } }); } } }); putawayableSwitch.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (isChecked) { String dateString = DateUtil.timestampToStr(ApiCaller.TimeInService, "yyyy-MM-dd"); startimeText.setText(dateString); } startimeText.setClickable(false); } else { // endtimeText.setText("结束时间"); // startimeText.setText("起始时间"); 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")); } startimeText.setClickable(true); } } }); putawayableSwitch.setChecked(false); productnameEditText.addTextChangedListener(mTextWatcher); productnameEditText.setOnFocusChangeListener( new OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (!hasFocus) { if (productnameEditText.getText().length() < 3) { showToast("产品名称长度必须大于3!"); } } } }); phonenumberEditText.addTextChangedListener(mTextWatcher); startimeText.addTextChangedListener(mTextWatcher); }