Przeglądaj źródła

[공통][Bug] String null check

hyodong.min 6 lat temu
rodzic
commit
015aaf0ee8

+ 5 - 1
app/src/main/java/kr/co/zumo/app/lifeplus/bean/api/CoinInfoBean.java

@@ -6,6 +6,7 @@ package kr.co.zumo.app.lifeplus.bean.api;
 import com.google.gson.annotations.SerializedName;
 
 import kr.co.zumo.app.lifeplus.bean.JsonBeanBase;
+import kr.co.zumo.app.lifeplus.util.StringUtil;
 
 /**
  * CoinInfoBean
@@ -35,7 +36,7 @@ public class CoinInfoBean extends JsonBeanBase {
   @SerializedName("purcDate") // 20181010
   private String date;
 
-  private /*transient*/ int limitDays = 7;
+  private transient int limitDays = 7;
 
   public CoinInfoBean(int limitDays) {
     this.limitDays = limitDays;
@@ -50,6 +51,9 @@ public class CoinInfoBean extends JsonBeanBase {
   }
 
   public String getGoodsAmount() {
+    if (StringUtil.isEmpty(goodsAmount)) {
+      goodsAmount = "0";
+    }
     return goodsAmount;
   }
 

+ 9 - 0
app/src/main/java/kr/co/zumo/app/lifeplus/util/StringUtil.java

@@ -267,6 +267,9 @@ public class StringUtil {
    * @return String
    */
   public static String underline(String string) {
+    if (isEmpty(string)) {
+      return "";
+    }
     return new StringBuilder().append("<u>").append(string).append("</u>").toString();
   }
 
@@ -277,6 +280,9 @@ public class StringUtil {
    * @return String
    */
   public static String bold(String string) {
+    if (isEmpty(string)) {
+      return "";
+    }
     return new StringBuilder().append("<b>").append(string).append("</b>").toString();
   }
 
@@ -297,6 +303,9 @@ public class StringUtil {
    * @return "1,000"
    */
   public static String toComma(String s) {
+    if (isEmpty(s)) {
+      return "0";
+    }
     DecimalFormat decimalFormat = new DecimalFormat("#,##0");
     return decimalFormat.format(Integer.parseInt(s));
   }