Преглед на файлове

[이벤트][New] 응모형 유효성 검사 완료

hyodong.min преди 6 години
родител
ревизия
a2eb3cdac5

+ 10 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/bean/api/EventPolicyBean.java

@@ -42,6 +42,16 @@ public class EventPolicyBean extends JsonBeanBase {
   @SerializedName("cmngCten")
   private String contents;
 
+  private boolean isChecked = false;
+
+  public boolean isChecked() {
+    return isChecked;
+  }
+
+  public void setChecked(boolean checked) {
+    isChecked = checked;
+  }
+
   public String getPolicyNo() {
     return policyNo;
   }

+ 2 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/Event.java

@@ -149,6 +149,7 @@ public class Event {
   public static final int TEXT = 121;
   public static final int PHOTO = 122;
   public static final int PERMISSION_GRANTED = 123;
+  public static final int SUBMIT = 124;
 
   @Retention(RetentionPolicy.SOURCE)
   @IntDef({
@@ -162,7 +163,7 @@ public class Event {
     MY_FAQ, UPDATE, FILTER, CLOSE, HELP, CONTENTS, MORE, BANNER, RECOMMEND, KAKAO_TALK, FACE_BOOK, CODE_COPY, EVENT, TAG, BOOKMARK, ORDER, DEFAULT, COMPLETE_BUCKET,
     LIKE, FRAGMENT_STACK_EMPTY, OVER_VIEW, SHARE, CALL_INFO, LINK, HOME_PAGE, INSTAGRAM, ADDRESS, SCROLL, SORT, TUTORIAL, CLICK_HTML, LAST, PREV, NEXT, REFRESH, MY_EVENT,
     ING_EVENT, WINNER_ANNOUNCEMENT, COUPON, TODAY, RECT, VOTE, MAIN, SEARCH, COIN, ENTRY, IMAGE, DIALOG, URI, AGREE, PUSH, NEWS, WITH_SHOWN, POINT, FOCUS, TEXT,
-    PHOTO, PERMISSION_GRANTED
+    PHOTO, PERMISSION_GRANTED, SUBMIT
   })
   public @interface ID {}
 

+ 1 - 2
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/event/question/EventQuestionFragment.java

@@ -196,7 +196,6 @@ public class EventQuestionFragment extends FragmentBase<EventQuestionPresenter>
           }
         };
       }
-
       eventQuestionViewHolders.add(eventQuestionViewHolder);
 
       if (null != questionItemView) {
@@ -216,7 +215,7 @@ public class EventQuestionFragment extends FragmentBase<EventQuestionPresenter>
     layoutSubmit = buttonView.findViewById(R.id.layout_button);
     layoutSubmit.setOnClickListener(view -> {
       //참여하기 버튼 클릭함
-      presenter.onEvent(new Event.Builder(Event.CLICK).build());
+      presenter.onEvent(new Event.Builder(Event.SUBMIT).build());
     });
     layoutContainer.addView(buttonView);
     setEnabledSubmitButton(false);

+ 11 - 4
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/event/question/EventQuestionModel.java

@@ -69,6 +69,10 @@ public class EventQuestionModel extends Model implements IUriListProvider {
 
   }
 
+  public void submit() {
+    Log.d("APP# EventQuestionModel | submit", "|" + "-----------------------------------------------------------");
+  }
+
   public int getRequestIndex() {
     return requestIndex;
   }
@@ -93,6 +97,7 @@ public class EventQuestionModel extends Model implements IUriListProvider {
     }
     Log.d("APP# EventQuestionModel | addUri", "|" + " index: " + index + " key: " + key + ", add: " + uri.getPath());
     list.put(key, uri);
+    Log.d("APP# EventQuestionModel | addUri", "|" + list.size());
   }
 
   public void removeUri(int index, int key) {
@@ -103,6 +108,7 @@ public class EventQuestionModel extends Model implements IUriListProvider {
     }
     Log.d("APP# EventQuestionModel | removeUri", "|" + " index: " + index + " key: " + key + ", remove......");
     list.remove(key);
+    Log.d("APP# EventQuestionModel | removeUri", "|" + list.size());
   }
 
   public void prepareVerify() {
@@ -133,7 +139,7 @@ public class EventQuestionModel extends Model implements IUriListProvider {
     }
 
     // 약관 유효성 검사 객채 셍성.
-    verifiers.add(new EventQuestionVerifierPolicy());
+    verifiers.add(new EventQuestionVerifierPolicy(eventDetailBean.getEventPolicyList()));
   }
 
   public void verify(int index, int subIndex, boolean checked) {
@@ -168,11 +174,12 @@ public class EventQuestionModel extends Model implements IUriListProvider {
   }
 
   public boolean getValidationAll() {
-    boolean isValidate = true;
     for (EventQuestionVerifier verifier : verifiers) {
-      isValidate &= verifier.isValidate();
+      if (false == verifier.isValidate()) {
+        return false;
+      }
     }
-    return isValidate;
+    return true;
   }
 
   /***********************************

+ 8 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/event/question/EventQuestionPresenter.java

@@ -137,11 +137,16 @@ public class EventQuestionPresenter extends Presenter<EventQuestionModel, IEvent
       case Event.DELETE:
         // integer => key
         model.removeUri(index, integer);
+        model.verify(index);
+        setSubmitButton();
         break;
       case Event.AGREE: //약관동의 상세 클릭
         String contents = model.getEventDetailBean().getEventPolicyList().get(event.getIndex()).getContents();
         showPolicyDetail(contents);
         break;
+      case Event.SUBMIT:
+        model.submit();
+        break;
       default:
         break;
     }
@@ -221,10 +226,12 @@ public class EventQuestionPresenter extends Presenter<EventQuestionModel, IEvent
     Log.d("APP# EventQuestionPresenter | onImageReceived", "| file path: " + uri.getPath());
     int index = model.getRequestIndex();
     int key = uri.hashCode();
-    model.addUri(index, key, uri);
     view.putAlbumImage(index, key, image);
+
+    model.addUri(index, key, uri);
     model.verify(index);
     setSubmitButton();
+
     view.validate(index, model.getValidation(index));
   }
 }

+ 23 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/view/screen/event/question/EventQuestionVerifierPolicy.java

@@ -3,6 +3,11 @@
  */
 package kr.co.zumo.app.lifeplus.view.screen.event.question;
 
+import java.util.List;
+
+import kr.co.zumo.app.lifeplus.bean.api.APIData;
+import kr.co.zumo.app.lifeplus.bean.api.EventPolicyBean;
+
 /**
  * EventQuestionVerifierPolicy
  * <pre>
@@ -14,23 +19,38 @@ package kr.co.zumo.app.lifeplus.view.screen.event.question;
  * @since 2019. 2. 12.
  */
 public class EventQuestionVerifierPolicy extends EventQuestionVerifier {
+  private List<EventPolicyBean> eventPolicyList;
+  private boolean isValidate = false;
+
+  public EventQuestionVerifierPolicy(List<EventPolicyBean> eventPolicyList) {
+    this.eventPolicyList = eventPolicyList;
+  }
+
   @Override
   public void verify(int subIndex, boolean checked) {
+    EventPolicyBean eventPolicyBean = eventPolicyList.get(subIndex);
+    eventPolicyBean.setChecked(checked);
 
+    isValidate = true;
+    for (EventPolicyBean policyBean : eventPolicyList) {
+      if (APIData.isTrue(policyBean.getMandatory())) {
+        isValidate &= policyBean.isChecked();
+      }
+    }
   }
 
   @Override
   public void verify(String text) {
-
+    // nothing
   }
 
   @Override
   public void verify() {
-
+    // nothing
   }
 
   @Override
   public boolean isValidate() {
-    return false;
+    return isValidate;
   }
 }

+ 10 - 0
app/src/main/res/drawable/black_grey_background.xml

@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+  <item
+    android:drawable="@color/C999999"
+    android:state_enabled="false"/>
+  <item
+    android:drawable="@color/C000000"
+    android:state_enabled="true"/>
+
+</selector>

+ 10 - 21
app/src/main/res/layout/event_participation_item_button.xml

@@ -9,29 +9,18 @@
   android:paddingBottom="19dp"
   >
 
-  <android.support.constraint.ConstraintLayout
+  <Button
     android:id="@+id/layout_button"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:layout_height="42dp"
     android:layout_marginStart="25dp"
     android:layout_marginEnd="25dp"
-    android:background="@color/C000000">
-
-    <TextView
-      android:layout_width="wrap_content"
-      android:layout_height="wrap_content"
-      android:layout_marginTop="10dp"
-      android:layout_marginBottom="10dp"
-      android:gravity="center_horizontal"
-      android:lineSpacingExtra="6sp"
-      android:text="@string/participation"
-      android:textColor="@color/CFFFFFF"
-      android:textSize="16sp"
-      app:layout_constraintBottom_toBottomOf="parent"
-      app:layout_constraintEnd_toEndOf="parent"
-      app:layout_constraintStart_toStartOf="parent"
-      app:layout_constraintTop_toTopOf="parent"
-      />
-
-  </android.support.constraint.ConstraintLayout>
+    android:background="@drawable/black_grey_background"
+    android:text="@string/participation"
+    android:textColor="@color/CFFFFFF"
+    android:textSize="16sp"
+    app:layout_constraintBottom_toBottomOf="parent"
+    app:layout_constraintEnd_toEndOf="parent"
+    app:layout_constraintStart_toStartOf="parent"
+    app:layout_constraintTop_toTopOf="parent"/>
 </android.support.constraint.ConstraintLayout>