Bladeren bron

新增字段,统一加载框

詹子聪 5 jaren geleden
bovenliggende
commit
1079748199

+ 3 - 2
app/src/main/java/com/miekir/ym/ui/home/coupon/CouponBean.java

@@ -44,11 +44,12 @@ public class CouponBean implements Serializable {
     /**
      * 模板类型
      */
-    public int couponType;
+    public int couponType = TYPE_ALL;
     /**
      * 模板名称
      */
     public String couponName;
+    public String couponContent;
     /**
      * 点击之后跳转的链接
      */
@@ -73,11 +74,11 @@ public class CouponBean implements Serializable {
      * 当前是否被收藏
      */
     public boolean isFavorite;
-    public int couponTypeId = TYPE_ALL;
 
     public void updateData(CouponBean couponBean) {
         this.couponType = couponBean.couponType;
         this.couponName = couponBean.couponName;
+        this.couponContent = couponBean.couponContent;
         this.coverUrl = couponBean.coverUrl;
         this.jumpUrl = couponBean.jumpUrl;
         this.actionEnable = couponBean.actionEnable;

+ 24 - 9
app/src/main/java/com/miekir/ym/ui/home/more/add/AddCouponActivity.java

@@ -2,6 +2,7 @@ package com.miekir.ym.ui.home.more.add;
 
 import android.content.Intent;
 import android.os.Bundle;
+import android.text.TextUtils;
 import android.view.View;
 import android.widget.Button;
 import android.widget.CheckBox;
@@ -22,9 +23,11 @@ import com.miekir.ym.ui.home.coupon.CouponBean;
 public class AddCouponActivity extends YangActivity implements View.OnClickListener, IAddCouponView {
     public static final String KEY_MODIFY_COUPON = "key_modify_coupon";
 
-    private TextInputEditText et_coupon_title;
+    private TextInputEditText et_coupon_name;
+    private TextInputEditText et_coupon_content;
     private TextInputEditText et_cover_url;
     private TextInputEditText et_jump_url;
+    private TextInputEditText et_coupon_type;
 
     private CheckBox cb_enable;
 
@@ -41,12 +44,14 @@ public class AddCouponActivity extends YangActivity implements View.OnClickListe
     @Override
     public void initViews(Bundle savedInstanceState) {
 
-        et_coupon_title = findViewById(R.id.et_coupon_title);
+        et_coupon_name = findViewById(R.id.et_coupon_name);
+        et_coupon_content = findViewById(R.id.et_coupon_content);
         et_cover_url = findViewById(R.id.et_cover_url);
         et_jump_url = findViewById(R.id.et_jump_url);
         cb_enable = findViewById(R.id.cb_enable);
-        ViewTool.setOnClickListener(this, this, new int[]{R.id.btn_add_goods});
-        Button btn_add_goods = findViewById(R.id.btn_add_goods);
+        et_coupon_type = findViewById(R.id.et_coupon_type);
+        ViewTool.setOnClickListener(this, this, new int[]{R.id.btn_add_coupon});
+        Button btn_add_goods = findViewById(R.id.btn_add_coupon);
 
         couponBean = (CouponBean) getIntent().getSerializableExtra(KEY_MODIFY_COUPON);
         if (couponBean != null) {
@@ -59,30 +64,41 @@ public class AddCouponActivity extends YangActivity implements View.OnClickListe
     }
 
     private void initCoupon() {
-        et_coupon_title.setText(couponBean.couponName);
+        et_coupon_name.setText(couponBean.couponName);
+        et_coupon_content.setText(couponBean.couponContent);
         et_cover_url.setText(couponBean.coverUrl);
         et_jump_url.setText(couponBean.jumpUrl);
         cb_enable.setChecked(couponBean.actionEnable);
+        et_coupon_type.setText(String.valueOf(couponBean.couponType));
     }
 
     @Override
     public void onClick(View v) {
         switch (v.getId()) {
-            case R.id.btn_add_goods:
-                String title = et_coupon_title.getEditableText().toString();
+            case R.id.btn_add_coupon:
+                String title = et_coupon_name.getEditableText().toString();
+                String content = et_coupon_content.getEditableText().toString();
                 String coverUrl = et_cover_url.getEditableText().toString();
                 String jumpUrl = et_jump_url.getEditableText().toString();
+                String type = et_coupon_type.getEditableText().toString();
+
+                if (TextUtils.isEmpty(title) || TextUtils.isEmpty(jumpUrl) || TextUtils.isEmpty(type)) {
+                    ToastTool.showLong("标题、跳转的URL和类型不能为空");
+                    return;
+                }
+
                 boolean isEnable = cb_enable.isChecked();
 
                 if (couponBean == null) {
                     couponBean = new CouponBean();
                 }
                 couponBean.couponName = title;
+                couponBean.couponContent = content;
                 couponBean.coverUrl = coverUrl;
                 couponBean.jumpUrl = jumpUrl;
                 couponBean.actionEnable = isEnable;
+                couponBean.couponType = Integer.parseInt(type);
 
-                showLoading();
                 presenter.addCoupon(couponBean);
                 break;
             default:
@@ -92,7 +108,6 @@ public class AddCouponActivity extends YangActivity implements View.OnClickListe
 
     @Override
     public void onAddCouponResult(boolean success, String message) {
-        hideLoading();
         ToastTool.showShort(message);
         if (success) {
             Intent intent = getIntent();

+ 1 - 1
app/src/main/java/com/miekir/ym/ui/home/more/add/AddCouponPresenter.java

@@ -19,7 +19,7 @@ import io.reactivex.schedulers.Schedulers;
 public class AddCouponPresenter extends BasePresenter<IAddCouponView> {
 
     public void addCoupon(CouponBean couponBean) {
-        NetMvpObserver<String> observer = new NetMvpObserver<String>() {
+        NetMvpObserver<String> observer = new NetMvpObserver<String>(this) {
             @Override
             public void onSuccess(int code, String result) {
                 post(view -> view.onAddCouponResult(true, result));

+ 0 - 4
app/src/main/java/com/miekir/ym/ui/home/more/forget/ForgetActivity.java

@@ -64,7 +64,6 @@ public class ForgetActivity extends YangActivity implements View.OnClickListener
                     return;
                 }
 
-                showLoading();
                 mCodePresenter.getCode(email);
                 break;
             case R.id.btn_reset_password:
@@ -97,7 +96,6 @@ public class ForgetActivity extends YangActivity implements View.OnClickListener
                     ToastTool.showShort("该手机不支持加密算法");
                     return;
                 }
-                showLoading();
                 mForgetPresenter.submitReset(email, code, encodePassword);
                 break;
             default:
@@ -107,7 +105,6 @@ public class ForgetActivity extends YangActivity implements View.OnClickListener
 
     @Override
     public void onGetCode(boolean isSuccess, String message) {
-        hideLoading();
         if (isSuccess) {
             ToastTool.showShort("验证码发送成功");
         } else {
@@ -117,7 +114,6 @@ public class ForgetActivity extends YangActivity implements View.OnClickListener
 
     @Override
     public void onForgetResult(BeiUser user, String message) {
-        hideLoading();
         if (user != null) {
             UserInfoManager.getInstance().setBeiUser(user);
             ToastTool.showShort("重设密码成功");

+ 1 - 1
app/src/main/java/com/miekir/ym/ui/home/more/forget/ForgetPresenter.java

@@ -22,7 +22,7 @@ import io.reactivex.schedulers.Schedulers;
 public class ForgetPresenter extends BasePresenter<IForgetView> {
 
     public void submitReset(String email, String code, String password) {
-        NetMvpObserver<BeiUser> observer = new NetMvpObserver<BeiUser>() {
+        NetMvpObserver<BeiUser> observer = new NetMvpObserver<BeiUser>(this) {
             @Override
             public void onSuccess(int code, BeiUser result) {
                 post(view -> view.onForgetResult(result, null));

+ 0 - 2
app/src/main/java/com/miekir/ym/ui/home/more/login/LoginActivity.java

@@ -112,7 +112,6 @@ public class LoginActivity extends YangActivity implements View.OnClickListener,
                     ToastTool.showShort("该手机不支持加密算法");
                     return;
                 }
-                showLoading();
                 presenter.submitLogin(email, password);
                 break;
             default:
@@ -122,7 +121,6 @@ public class LoginActivity extends YangActivity implements View.OnClickListener,
 
     @Override
     public void onLoginResult(BeiUser user, String message) {
-        hideLoading();
         if (user != null) {
             UserInfoManager.getInstance().setBeiUser(user);
             ToastTool.showShort("登录成功");

+ 0 - 2
app/src/main/java/com/miekir/ym/ui/home/more/register/RegisterActivity.java

@@ -127,7 +127,6 @@ public class RegisterActivity extends YangActivity implements View.OnClickListen
                     ToastTool.showShort("邮箱不能为空");
                     return;
                 }
-                showLoading();
                 presenter.getCode(email);
                 break;
             default:
@@ -137,7 +136,6 @@ public class RegisterActivity extends YangActivity implements View.OnClickListen
 
     @Override
     public void onGetCode(boolean isSuccess, String message) {
-        hideLoading();
         if (isSuccess) {
             ToastTool.showShort("验证码发送成功");
             btn_get_code.setEnabled(false);

+ 0 - 2
app/src/main/java/com/miekir/ym/ui/home/more/register/fill/FillDataActivity.java

@@ -75,13 +75,11 @@ public class FillDataActivity extends YangActivity implements IRegisterView {
         mBeiUser.password = encodeString;
         mBeiUser.nickName = nickname;
         mBeiUser.cashAccount = cashAccount;
-        showLoading();
         presenter.submitRegister(mBeiUser, code);
     }
 
     @Override
     public void onRegisterResult(BeiUser user, String message) {
-        hideLoading();
         if (user != null) {
             // 保存到本地
             UserInfoManager.getInstance().setBeiUser(user);

+ 0 - 4
app/src/main/java/com/miekir/ym/ui/home/search/SearchActivity.java

@@ -85,7 +85,6 @@ public class SearchActivity extends YangActivity implements View.OnClickListener
             public void onBottom() {
                 super.onBottom();
                 // 如果到底部了,而且不是正在加载状态,就变为正在加载状态,并及时去加载数据
-                showLoading();
                 mIsRefresh = false;
                 searchPresenter.searchByKeyword(mKeyword, mCurrentPage, PAGE_SIZE);
             }
@@ -106,7 +105,6 @@ public class SearchActivity extends YangActivity implements View.OnClickListener
                     ToastTool.showShort("请输入关键字或链接");
                     return;
                 }
-                showLoading();
                 mCurrentPage = PAGE_START;
                 mCouponList.clear();
                 mAdapter.notifyDataSetChanged();
@@ -179,8 +177,6 @@ public class SearchActivity extends YangActivity implements View.OnClickListener
 
     @Override
     public void onSearchKeywordResult(boolean success, String message, List<CouponBean> goodsList) {
-        hideLoading();
-
         if (!success) {
             ToastTool.showShort(message);
             return;

+ 1 - 1
app/src/main/java/com/miekir/ym/ui/home/search/SearchPresenter.java

@@ -23,7 +23,7 @@ import io.reactivex.schedulers.Schedulers;
 public class SearchPresenter extends BasePresenter<ISearchView> {
 
     public void searchByKeyword(String keyword, int pageNum, int pageSize) {
-        NetMvpObserver<List<CouponBean>> observer = new NetMvpObserver<List<CouponBean>>() {
+        NetMvpObserver<List<CouponBean>> observer = new NetMvpObserver<List<CouponBean>>(this) {
             @Override
             public void onSuccess(int code, List<CouponBean> result) {
                 post(view -> view.onSearchKeywordResult(true, "", result));

+ 51 - 3
app/src/main/res/layout/activity_coupon_add.xml

@@ -39,12 +39,60 @@
                 app:boxStrokeWidthFocused="@dimen/width_stroke">
 
                 <com.google.android.material.textfield.TextInputEditText
-                    android:id="@+id/et_coupon_title"
+                    android:id="@+id/et_coupon_name"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
                     android:textSize="@dimen/text_normal_s" />
             </com.google.android.material.textfield.TextInputLayout>
 
+            <com.google.android.material.textfield.TextInputLayout
+                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginStart="@dimen/margin_default"
+                android:layout_marginTop="@dimen/margin_default"
+                android:layout_marginEnd="@dimen/margin_default"
+                android:hint="优惠券描述"
+                app:boxBackgroundMode="outline"
+                app:boxCornerRadiusBottomEnd="4dp"
+                app:boxCornerRadiusBottomStart="4dp"
+                app:boxCornerRadiusTopEnd="4dp"
+                app:boxCornerRadiusTopStart="4dp"
+                app:boxStrokeWidth="@dimen/width_stroke"
+                app:boxStrokeWidthFocused="@dimen/width_stroke">
+
+                <com.google.android.material.textfield.TextInputEditText
+                    android:id="@+id/et_coupon_content"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:textSize="@dimen/text_normal_s" />
+            </com.google.android.material.textfield.TextInputLayout>
+
+            <com.google.android.material.textfield.TextInputLayout
+                style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:layout_marginStart="@dimen/margin_default"
+                android:layout_marginTop="@dimen/margin_default"
+                android:layout_marginEnd="@dimen/margin_default"
+                android:hint="优惠券类型[1美食 2数码 3衣服 4生活 5其他]"
+                app:boxBackgroundMode="outline"
+                app:boxCornerRadiusBottomEnd="4dp"
+                app:boxCornerRadiusBottomStart="4dp"
+                app:boxCornerRadiusTopEnd="4dp"
+                app:boxCornerRadiusTopStart="4dp"
+                app:boxStrokeWidth="@dimen/width_stroke"
+                app:boxStrokeWidthFocused="@dimen/width_stroke">
+
+                <com.google.android.material.textfield.TextInputEditText
+                    android:id="@+id/et_coupon_type"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:textSize="@dimen/text_normal_s"
+                    android:inputType="number"
+                    android:maxLength="1"
+                    android:text="0"/>
+            </com.google.android.material.textfield.TextInputLayout>
 
             <com.google.android.material.textfield.TextInputLayout
                 style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
@@ -53,7 +101,7 @@
                 android:layout_marginStart="@dimen/margin_default"
                 android:layout_marginTop="@dimen/margin_default"
                 android:layout_marginEnd="@dimen/margin_default"
-                android:hint="封面URL"
+                android:hint="Logo URL"
                 app:boxBackgroundMode="outline"
                 app:boxCornerRadiusBottomEnd="4dp"
                 app:boxCornerRadiusBottomStart="4dp"
@@ -102,7 +150,7 @@
                 android:checked="true"/>
 
             <android.widget.Button
-                android:id="@+id/btn_add_goods"
+                android:id="@+id/btn_add_coupon"
                 style="?android:attr/borderlessButtonStyle"
                 android:layout_width="match_parent"
                 android:layout_height="wrap_content"