Showing
3 changed files
with
28 additions
and
26 deletions
... | @@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true | ... | @@ -5,7 +5,7 @@ android.buildFeatures.buildConfig = true |
5 | 5 | ||
6 | ext { | 6 | ext { |
7 | PUBLISH_GROUP_ID = 'ly.warp' | 7 | PUBLISH_GROUP_ID = 'ly.warp' |
8 | - PUBLISH_VERSION = '4.5.5.4p8' | 8 | + PUBLISH_VERSION = '4.5.5.4p9' |
9 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 9 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
10 | } | 10 | } |
11 | 11 | ... | ... |
... | @@ -566,34 +566,36 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -566,34 +566,36 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
566 | 566 | ||
567 | String tempCoupon = ""; | 567 | String tempCoupon = ""; |
568 | int result = 0; | 568 | int result = 0; |
569 | - if (mCoupon.getCoupon().length() == 13) { | 569 | + if (mCoupon != null) { |
570 | - tempCoupon = mCoupon.getCoupon(); | 570 | + if (!TextUtils.isEmpty(mCoupon.getCoupon()) && mCoupon.getCoupon().length() == 13) { |
571 | + tempCoupon = mCoupon.getCoupon(); | ||
571 | 572 | ||
572 | - try { | 573 | + try { |
573 | - for (int i = mCoupon.getCoupon().length() - 1; i >= 0; i--) { | 574 | + for (int i = mCoupon.getCoupon().length() - 1; i >= 0; i--) { |
574 | - result = result + Integer.parseInt(String.valueOf((mCoupon.getCoupon()).charAt(i))) * (1 + (2 * (i % 2))); | 575 | + result = result + Integer.parseInt(String.valueOf((mCoupon.getCoupon()).charAt(i))) * (1 + (2 * (i % 2))); |
576 | + } | ||
577 | + } catch (Exception e) { | ||
578 | + e.printStackTrace(); | ||
575 | } | 579 | } |
576 | - } catch (Exception e) { | 580 | + } else if (!TextUtils.isEmpty(mCoupon.getCoupon()) && mCoupon.getCoupon().length() != 13) { |
577 | - e.printStackTrace(); | 581 | + try { |
578 | - } | 582 | + tempCoupon = mCoupon.getCoupon(); |
579 | - } else { | 583 | + for (int i = 0; i < (12 - mCoupon.getCoupon().length()); i++) { |
580 | - try { | 584 | + tempCoupon += "0"; |
581 | - tempCoupon = mCoupon.getCoupon(); | 585 | + } |
582 | - for (int i = 0; i < (12 - mCoupon.getCoupon().length()); i++) { | 586 | + } catch (Exception e) { |
583 | - tempCoupon += "0"; | 587 | + e.printStackTrace(); |
584 | } | 588 | } |
585 | - } catch (Exception e) { | ||
586 | - e.printStackTrace(); | ||
587 | - } | ||
588 | 589 | ||
589 | - try { | 590 | + try { |
590 | - for (int i = mCoupon.getCoupon().length() - 1; i >= 0; i--) { | 591 | + for (int i = mCoupon.getCoupon().length() - 1; i >= 0; i--) { |
591 | - result = result + Integer.parseInt(String.valueOf((mCoupon.getCoupon()).charAt(i))) * (1 + (2 * (i % 2))); | 592 | + result = result + Integer.parseInt(String.valueOf((mCoupon.getCoupon()).charAt(i))) * (1 + (2 * (i % 2))); |
592 | - } | 593 | + } |
593 | 594 | ||
594 | - tempCoupon = tempCoupon + (10 - (result % 10)) % 10; | 595 | + tempCoupon = tempCoupon + (10 - (result % 10)) % 10; |
595 | - } catch (Exception e) { | 596 | + } catch (Exception e) { |
596 | - e.printStackTrace(); | 597 | + e.printStackTrace(); |
598 | + } | ||
597 | } | 599 | } |
598 | } | 600 | } |
599 | 601 | ... | ... |
... | @@ -160,7 +160,7 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -160,7 +160,7 @@ public class Coupon implements Parcelable, Serializable { |
160 | if (json != null) { | 160 | if (json != null) { |
161 | this.barcode = json.optString(BARCODE); | 161 | this.barcode = json.optString(BARCODE); |
162 | this.category = json.optString(CATEGORY); | 162 | this.category = json.optString(CATEGORY); |
163 | - this.coupon = json.optString(COUPON); | 163 | + this.coupon = json.optString(COUPON, ""); |
164 | this.created = json.optString(CREATED); | 164 | this.created = json.optString(CREATED); |
165 | this.description = json.optString(DESCRIPTION); | 165 | this.description = json.optString(DESCRIPTION); |
166 | this.discount = json.optString(DISCOUNT); | 166 | this.discount = json.optString(DISCOUNT); |
... | @@ -214,7 +214,7 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -214,7 +214,7 @@ public class Coupon implements Parcelable, Serializable { |
214 | e.printStackTrace(); | 214 | e.printStackTrace(); |
215 | } | 215 | } |
216 | } | 216 | } |
217 | - this.coupon = json.optString(COUPON); | 217 | + this.coupon = json.optString(COUPON, ""); |
218 | this.couponsetUuid = json.optString(COUPONSET_UUID); | 218 | this.couponsetUuid = json.optString(COUPONSET_UUID); |
219 | this.discount = json.optString(DISCOUNT); | 219 | this.discount = json.optString(DISCOUNT); |
220 | if (this.discount.contains(",")) { | 220 | if (this.discount.contains(",")) { | ... | ... |
-
Please register or login to post a comment