Bläddra i källkod

[주모] 회원가입 유효성 검증 오류 수정

yeongyun 6 år sedan
förälder
incheckning
72ed5dac2c

+ 21 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/util/StringUtil.java

@@ -8,6 +8,7 @@ import android.support.annotation.Nullable;
 import android.telephony.PhoneNumberUtils;
 import android.text.Html;
 import android.text.Spanned;
+import android.util.Log;
 
 import java.io.UnsupportedEncodingException;
 import java.security.MessageDigest;
@@ -817,7 +818,8 @@ public class StringUtil {
    */
   public static String checkName(String name) {
     if (!StringUtil.isEmpty(name)) {
-      if(name.getBytes().length > 20) {
+      if(StringUtil.getByteLength(name) > 20) {
+//      if(name.getBytes().length > 20) {
         return "한글 10자, 영문 20자까지 입력 가능합니다.";
       } else {
         return "";
@@ -837,4 +839,22 @@ public class StringUtil {
     String regexStr = "^[0-9]*$";
     return str.matches(regexStr);
   }
+
+  /**
+   * 문자열의 바이트 길이
+   * 인코딩 문자셋에 따라 바이트 길이 달라짐
+   *
+   * @param str
+   * @return
+   */
+  public static int getByteLength(String str) {
+    if (str != null) {
+      try {
+        return str.getBytes("KSC5601").length;
+      } catch (UnsupportedEncodingException e) {
+//        Log.e(getClass().getSimpleName(), "UnsupportedEncodingException");
+      }
+    }
+    return 0;
+  }
 }

+ 5 - 3
app/src/main/java/kr/co/zumo/app/lifeplus/zumo/screen/SignUpPresenter.java

@@ -37,9 +37,11 @@ public class SignUpPresenter extends BasePresenter<SignUpModel, SignUpView> {
      * 저장 된 임시 데이터 호출
      */
     private void getTempData() {
-        userInfoDeliveryBean = SignUpModelHelper.getInstance().getTempMemberDataBean();
-        if (userInfoDeliveryBean == null) {
-            userInfoDeliveryBean = new UserInfoDeliveryBean();
+        if(userInfoDeliveryBean == null) {
+            userInfoDeliveryBean = SignUpModelHelper.getInstance().getTempMemberDataBean();
+            if (userInfoDeliveryBean == null) {
+                userInfoDeliveryBean = new UserInfoDeliveryBean();
+            }
         }
     }