|
|
@@ -19,6 +19,8 @@ import com.miekir.mvp.presenter.InjectPresenter;
|
|
|
* Description: 登录界面
|
|
|
*/
|
|
|
public class AddGoodsActivity extends BaseBeiActivity implements View.OnClickListener, IAddGoodsView {
|
|
|
+ public static final String KEY_MODIFY_GOODS = "key_modify_goods";
|
|
|
+
|
|
|
private TextInputEditText et_goods_title;
|
|
|
private TextInputEditText et_cover_url;
|
|
|
private TextInputEditText et_desc;
|
|
|
@@ -35,6 +37,8 @@ public class AddGoodsActivity extends BaseBeiActivity implements View.OnClickLis
|
|
|
private CheckBox cb_self;
|
|
|
private CheckBox cb_enable;
|
|
|
|
|
|
+ private GoodsBean mGoodsBean;
|
|
|
+
|
|
|
@InjectPresenter
|
|
|
AddGoodsPresenter presenter;
|
|
|
|
|
|
@@ -62,6 +66,29 @@ public class AddGoodsActivity extends BaseBeiActivity implements View.OnClickLis
|
|
|
cb_self = findViewById(R.id.cb_self);
|
|
|
cb_enable = findViewById(R.id.cb_enable);
|
|
|
ViewTool.setOnClickListener(this, this, new int[]{R.id.btn_add_goods});
|
|
|
+
|
|
|
+ mGoodsBean = (GoodsBean) getIntent().getSerializableExtra(KEY_MODIFY_GOODS);
|
|
|
+ if (mGoodsBean != null) {
|
|
|
+ initGoods();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initGoods() {
|
|
|
+ et_goods_title.setText(mGoodsBean.title);
|
|
|
+ et_cover_url.setText(mGoodsBean.coverImageUrl);
|
|
|
+ et_desc.setText(mGoodsBean.description);
|
|
|
+ et_reason.setText(mGoodsBean.reason);
|
|
|
+ et_old_price.setText(String.valueOf(mGoodsBean.oldPrice));
|
|
|
+ et_now_price.setText(String.valueOf(mGoodsBean.nowPrice));
|
|
|
+ et_province.setText(mGoodsBean.province);
|
|
|
+ et_coupon.setText(mGoodsBean.couponInfo);
|
|
|
+ et_goods_url.setText(mGoodsBean.goodsUrl);
|
|
|
+ et_sales_per_month.setText(String.valueOf(mGoodsBean.salesPerMonth));
|
|
|
+ et_good_comment_percent.setText(String.valueOf(mGoodsBean.goodCommentPercent));
|
|
|
+ et_shop_name.setText(mGoodsBean.shopName);
|
|
|
+ et_comment_num.setText(String.valueOf(mGoodsBean.commentNum));
|
|
|
+ cb_self.setChecked(mGoodsBean.isSelfBusiness);
|
|
|
+ cb_enable.setChecked(mGoodsBean.enable);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -85,27 +112,29 @@ public class AddGoodsActivity extends BaseBeiActivity implements View.OnClickLis
|
|
|
boolean isSelf = cb_self.isChecked();
|
|
|
boolean isEnable = cb_enable.isChecked();
|
|
|
|
|
|
- GoodsBean goodsBean = new GoodsBean();
|
|
|
- goodsBean.title = title;
|
|
|
- goodsBean.coverImageUrl = coverUrl;
|
|
|
- goodsBean.description = description;
|
|
|
- goodsBean.reason = reason;
|
|
|
- goodsBean.oldPrice = oldPrice;
|
|
|
- goodsBean.nowPrice = nowPrice;
|
|
|
- goodsBean.rebate = rebate;
|
|
|
- goodsBean.province = province;
|
|
|
- goodsBean.shopName = shopName;
|
|
|
- goodsBean.couponInfo = coupon;
|
|
|
- goodsBean.goodsUrl = goodsUrl;
|
|
|
- goodsBean.salesPerMonth = Long.parseLong(salesPerMonth);
|
|
|
- goodsBean.goodCommentPercent = Double.parseDouble(goodCommentPercent);
|
|
|
- goodsBean.commentNum = Long.parseLong(commentNum);
|
|
|
- goodsBean.isSelfBusiness = isSelf;
|
|
|
- goodsBean.enable = isEnable;
|
|
|
- goodsBean.hasCoupon = !TextUtils.isEmpty(coupon);
|
|
|
+ if (mGoodsBean == null) {
|
|
|
+ mGoodsBean = new GoodsBean();
|
|
|
+ }
|
|
|
+ mGoodsBean.title = title;
|
|
|
+ mGoodsBean.coverImageUrl = coverUrl;
|
|
|
+ mGoodsBean.description = description;
|
|
|
+ mGoodsBean.reason = reason;
|
|
|
+ mGoodsBean.oldPrice = oldPrice;
|
|
|
+ mGoodsBean.nowPrice = nowPrice;
|
|
|
+ mGoodsBean.rebate = rebate;
|
|
|
+ mGoodsBean.province = province;
|
|
|
+ mGoodsBean.shopName = shopName;
|
|
|
+ mGoodsBean.couponInfo = coupon;
|
|
|
+ mGoodsBean.goodsUrl = goodsUrl;
|
|
|
+ mGoodsBean.salesPerMonth = Long.parseLong(salesPerMonth);
|
|
|
+ mGoodsBean.goodCommentPercent = Double.parseDouble(goodCommentPercent);
|
|
|
+ mGoodsBean.commentNum = Long.parseLong(commentNum);
|
|
|
+ mGoodsBean.isSelfBusiness = isSelf;
|
|
|
+ mGoodsBean.enable = isEnable;
|
|
|
+ mGoodsBean.hasCoupon = !TextUtils.isEmpty(coupon);
|
|
|
|
|
|
showLoading();
|
|
|
- presenter.addGoods(goodsBean);
|
|
|
+ presenter.addGoods(mGoodsBean);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
@@ -117,6 +146,7 @@ public class AddGoodsActivity extends BaseBeiActivity implements View.OnClickLis
|
|
|
dismissLoading();
|
|
|
ToastTool.showShort(message);
|
|
|
if (success) {
|
|
|
+ setResult(RESULT_OK);
|
|
|
finish();
|
|
|
}
|
|
|
}
|