Showing
10 changed files
with
239 additions
and
64 deletions
... | @@ -5,13 +5,17 @@ import android.content.Context; | ... | @@ -5,13 +5,17 @@ import android.content.Context; |
5 | import android.content.Intent; | 5 | import android.content.Intent; |
6 | import android.graphics.Bitmap; | 6 | import android.graphics.Bitmap; |
7 | import android.graphics.Color; | 7 | import android.graphics.Color; |
8 | +import android.os.Build; | ||
8 | import android.os.Bundle; | 9 | import android.os.Bundle; |
10 | +import android.text.Html; | ||
9 | import android.text.TextUtils; | 11 | import android.text.TextUtils; |
10 | import android.view.View; | 12 | import android.view.View; |
11 | import android.widget.ImageView; | 13 | import android.widget.ImageView; |
12 | import android.widget.LinearLayout; | 14 | import android.widget.LinearLayout; |
13 | import android.widget.TextView; | 15 | import android.widget.TextView; |
14 | 16 | ||
17 | +import androidx.core.content.ContextCompat; | ||
18 | + | ||
15 | import com.bumptech.glide.Glide; | 19 | import com.bumptech.glide.Glide; |
16 | import com.bumptech.glide.load.engine.DiskCacheStrategy; | 20 | import com.bumptech.glide.load.engine.DiskCacheStrategy; |
17 | import com.google.zxing.BarcodeFormat; | 21 | import com.google.zxing.BarcodeFormat; |
... | @@ -41,10 +45,12 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -41,10 +45,12 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
41 | // =========================================================== | 45 | // =========================================================== |
42 | 46 | ||
43 | private ImageView mIvBack, mIvCouponPhoto, mIvBarcode; | 47 | private ImageView mIvBack, mIvCouponPhoto, mIvBarcode; |
44 | - private TextView mTvTerms, mTvCouponCode, mTvCouponTitle, mTvCouponSubtitle, mTvCouponDate; | 48 | + private TextView mTvTerms, mTvCouponCode, mTvCouponTitle, mTvCouponSubtitle, mTvCouponDate, |
45 | - private LinearLayout mLlGiftIt, mLlShops; | 49 | + mTvTermsValue; |
50 | + private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms; | ||
46 | private Coupon mCoupon; | 51 | private Coupon mCoupon; |
47 | private Couponset mCouponset; | 52 | private Couponset mCouponset; |
53 | + private boolean mIsBarcodeShown = false, mIsTermsShown = false; | ||
48 | 54 | ||
49 | // =========================================================== | 55 | // =========================================================== |
50 | // Methods for/from SuperClass/Interfaces | 56 | // Methods for/from SuperClass/Interfaces |
... | @@ -67,6 +73,10 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -67,6 +73,10 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
67 | mIvCouponPhoto = findViewById(R.id.imageView6); | 73 | mIvCouponPhoto = findViewById(R.id.imageView6); |
68 | mIvBarcode = findViewById(R.id.iv_barcode); | 74 | mIvBarcode = findViewById(R.id.iv_barcode); |
69 | mLlShops = findViewById(R.id.ll_shops); | 75 | mLlShops = findViewById(R.id.ll_shops); |
76 | + mLlBarcodeShown = findViewById(R.id.ll_show_barcode); | ||
77 | + mLlBarcodeContainer = findViewById(R.id.ll_barcode_container_items); | ||
78 | + mLlTerms = findViewById(R.id.ll_terms_inner); | ||
79 | + mTvTermsValue = findViewById(R.id.tv_terms_value); | ||
70 | 80 | ||
71 | initViews(); | 81 | initViews(); |
72 | } | 82 | } |
... | @@ -92,6 +102,38 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -92,6 +102,38 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
92 | Intent intent = new Intent(CouponInfoActivity.this, ShopsActivity.class); | 102 | Intent intent = new Intent(CouponInfoActivity.this, ShopsActivity.class); |
93 | intent.putExtra("couponset", (Serializable) mCouponset); | 103 | intent.putExtra("couponset", (Serializable) mCouponset); |
94 | startActivity(intent); | 104 | startActivity(intent); |
105 | + return; | ||
106 | + } | ||
107 | + if (view.getId() == R.id.ll_show_barcode) { | ||
108 | + if (mIsBarcodeShown) { | ||
109 | + mLlBarcodeContainer.setVisibility(View.GONE); | ||
110 | + TextView barcodeButtonTitle = mLlBarcodeShown.findViewById(R.id.tv_barcode); | ||
111 | + ImageView barcodeButtonArrow = mLlBarcodeShown.findViewById(R.id.iv_barcode_arrow); | ||
112 | + barcodeButtonTitle.setText(getString(R.string.cos_show_barcode)); | ||
113 | + barcodeButtonArrow.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_arrow_down_dark)); | ||
114 | + mIsBarcodeShown = false; | ||
115 | + } else { | ||
116 | + mLlBarcodeContainer.setVisibility(View.VISIBLE); | ||
117 | + TextView barcodeButtonTitle = mLlBarcodeShown.findViewById(R.id.tv_barcode); | ||
118 | + ImageView barcodeButtonArrow = mLlBarcodeShown.findViewById(R.id.iv_barcode_arrow); | ||
119 | + barcodeButtonTitle.setText(getString(R.string.cos_hide_barcode)); | ||
120 | + barcodeButtonArrow.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_arrow_up_dark)); | ||
121 | + mIsBarcodeShown = true; | ||
122 | + } | ||
123 | + return; | ||
124 | + } | ||
125 | + if (view.getId() == R.id.ll_terms_inner) { | ||
126 | + if (mIsTermsShown) { | ||
127 | + mTvTermsValue.setVisibility(View.GONE); | ||
128 | + ImageView termsButtonArrow = mLlTerms.findViewById(R.id.iv_terms_arrow); | ||
129 | + termsButtonArrow.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_arrow_down_dark)); | ||
130 | + mIsTermsShown = false; | ||
131 | + } else { | ||
132 | + mTvTermsValue.setVisibility(View.VISIBLE); | ||
133 | + ImageView termsButtonArrow = mLlTerms.findViewById(R.id.iv_terms_arrow); | ||
134 | + termsButtonArrow.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_arrow_up_dark)); | ||
135 | + mIsTermsShown = true; | ||
136 | + } | ||
95 | } | 137 | } |
96 | } | 138 | } |
97 | 139 | ||
... | @@ -118,6 +160,14 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -118,6 +160,14 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
118 | } | 160 | } |
119 | } | 161 | } |
120 | 162 | ||
163 | + if (mCouponset != null) { | ||
164 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | ||
165 | + mTvTermsValue.setText(Html.fromHtml(mCouponset.getTerms(), Html.FROM_HTML_MODE_COMPACT)); | ||
166 | + } else { | ||
167 | + mTvTermsValue.setText(Html.fromHtml(mCouponset.getTerms())); | ||
168 | + } | ||
169 | + } | ||
170 | + | ||
121 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); | 171 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); |
122 | Date newDate = new Date(); | 172 | Date newDate = new Date(); |
123 | try { | 173 | try { |
... | @@ -146,6 +196,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -146,6 +196,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
146 | // mTvTerms.setPaintFlags(mTvTerms.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); | 196 | // mTvTerms.setPaintFlags(mTvTerms.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); |
147 | mLlGiftIt.setOnClickListener(this); | 197 | mLlGiftIt.setOnClickListener(this); |
148 | mLlShops.setOnClickListener(this); | 198 | mLlShops.setOnClickListener(this); |
199 | + mLlBarcodeShown.setOnClickListener(this); | ||
200 | + mLlTerms.setOnClickListener(this); | ||
149 | 201 | ||
150 | String tempCoupon = mCoupon.getCoupon(); | 202 | String tempCoupon = mCoupon.getCoupon(); |
151 | for (int i = 0; i < (12 - mCoupon.getCoupon().length()); i++) { | 203 | for (int i = 0; i < (12 - mCoupon.getCoupon().length()); i++) { | ... | ... |
... | @@ -67,6 +67,7 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe | ... | @@ -67,6 +67,7 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe |
67 | mIvBack = findViewById(R.id.iv_shops_back); | 67 | mIvBack = findViewById(R.id.iv_shops_back); |
68 | mMapView = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mv_shops); | 68 | mMapView = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mv_shops); |
69 | mMapView.getMapAsync(this); | 69 | mMapView.getMapAsync(this); |
70 | + mIvBack.setOnClickListener(this); | ||
70 | } | 71 | } |
71 | 72 | ||
72 | @Override | 73 | @Override | ... | ... |
... | @@ -60,6 +60,7 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -60,6 +60,7 @@ public class Coupon implements Parcelable, Serializable { |
60 | private static final String TRANSACTION_UUID = "transaction_uuid"; | 60 | private static final String TRANSACTION_UUID = "transaction_uuid"; |
61 | private static final String CHANGES_DATES = "changes_dates"; | 61 | private static final String CHANGES_DATES = "changes_dates"; |
62 | private static final String COUPONSET_UUID = "couponset_uuid"; | 62 | private static final String COUPONSET_UUID = "couponset_uuid"; |
63 | + private static final String MERCHANT_UUID = "merchant_uuid"; | ||
63 | 64 | ||
64 | /* Member variables of the Campaign object */ | 65 | /* Member variables of the Campaign object */ |
65 | 66 | ||
... | @@ -77,6 +78,7 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -77,6 +78,7 @@ public class Coupon implements Parcelable, Serializable { |
77 | private String transactionUuid = ""; | 78 | private String transactionUuid = ""; |
78 | private JSONObject changesDates = new JSONObject(); | 79 | private JSONObject changesDates = new JSONObject(); |
79 | private String couponsetUuid = ""; | 80 | private String couponsetUuid = ""; |
81 | + private String merchantUuid = ""; | ||
80 | 82 | ||
81 | /** | 83 | /** |
82 | * Basic constructor used to create an object from a String, representing a | 84 | * Basic constructor used to create an object from a String, representing a |
... | @@ -110,6 +112,7 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -110,6 +112,7 @@ public class Coupon implements Parcelable, Serializable { |
110 | this.transactionUuid = json.optString(TRANSACTION_UUID); | 112 | this.transactionUuid = json.optString(TRANSACTION_UUID); |
111 | this.changesDates = json.optJSONObject(CHANGES_DATES); | 113 | this.changesDates = json.optJSONObject(CHANGES_DATES); |
112 | this.couponsetUuid = json.optString(COUPONSET_UUID); | 114 | this.couponsetUuid = json.optString(COUPONSET_UUID); |
115 | + this.merchantUuid = json.optString(MERCHANT_UUID); | ||
113 | } | 116 | } |
114 | } | 117 | } |
115 | 118 | ||
... | @@ -127,6 +130,7 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -127,6 +130,7 @@ public class Coupon implements Parcelable, Serializable { |
127 | this.transactionDate = source.readString(); | 130 | this.transactionDate = source.readString(); |
128 | this.transactionUuid = source.readString(); | 131 | this.transactionUuid = source.readString(); |
129 | this.couponsetUuid = source.readString(); | 132 | this.couponsetUuid = source.readString(); |
133 | + this.merchantUuid = source.readString(); | ||
130 | } | 134 | } |
131 | 135 | ||
132 | @Override | 136 | @Override |
... | @@ -144,6 +148,7 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -144,6 +148,7 @@ public class Coupon implements Parcelable, Serializable { |
144 | dest.writeString(this.transactionDate); | 148 | dest.writeString(this.transactionDate); |
145 | dest.writeString(this.transactionUuid); | 149 | dest.writeString(this.transactionUuid); |
146 | dest.writeString(this.couponsetUuid); | 150 | dest.writeString(this.couponsetUuid); |
151 | + dest.writeString(this.merchantUuid); | ||
147 | } | 152 | } |
148 | 153 | ||
149 | /** | 154 | /** |
... | @@ -168,6 +173,7 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -168,6 +173,7 @@ public class Coupon implements Parcelable, Serializable { |
168 | jObj.putOpt(TRANSACTION_UUID, this.transactionUuid); | 173 | jObj.putOpt(TRANSACTION_UUID, this.transactionUuid); |
169 | jObj.putOpt(CHANGES_DATES, this.changesDates); | 174 | jObj.putOpt(CHANGES_DATES, this.changesDates); |
170 | jObj.putOpt(COUPONSET_UUID, this.couponsetUuid); | 175 | jObj.putOpt(COUPONSET_UUID, this.couponsetUuid); |
176 | + jObj.putOpt(MERCHANT_UUID, this.merchantUuid); | ||
171 | } catch (JSONException e) { | 177 | } catch (JSONException e) { |
172 | if (WarpConstants.DEBUG) { | 178 | if (WarpConstants.DEBUG) { |
173 | e.printStackTrace(); | 179 | e.printStackTrace(); |
... | @@ -319,6 +325,14 @@ public class Coupon implements Parcelable, Serializable { | ... | @@ -319,6 +325,14 @@ public class Coupon implements Parcelable, Serializable { |
319 | this.couponsetUuid = couponsetUuid; | 325 | this.couponsetUuid = couponsetUuid; |
320 | } | 326 | } |
321 | 327 | ||
328 | + public String getMerchantUuid() { | ||
329 | + return merchantUuid; | ||
330 | + } | ||
331 | + | ||
332 | + public void setMerchantUuid(String merchantUuid) { | ||
333 | + this.merchantUuid = merchantUuid; | ||
334 | + } | ||
335 | + | ||
322 | @Override | 336 | @Override |
323 | public int describeContents() { | 337 | public int describeContents() { |
324 | return 0; | 338 | return 0; | ... | ... |
... | @@ -136,6 +136,50 @@ public class Merchant implements Parcelable, Serializable, ClusterItem { | ... | @@ -136,6 +136,50 @@ public class Merchant implements Parcelable, Serializable, ClusterItem { |
136 | private JSONObject product = new JSONObject(); | 136 | private JSONObject product = new JSONObject(); |
137 | private LatLng coordinates; | 137 | private LatLng coordinates; |
138 | 138 | ||
139 | + public Merchant() { | ||
140 | + this.address = ""; | ||
141 | + this.id = ""; | ||
142 | + this.store_id = ""; | ||
143 | + this.name = ""; | ||
144 | + this.logo = ""; | ||
145 | + this.website = ""; | ||
146 | + this.email = ""; | ||
147 | + this.telephone = ""; | ||
148 | + this.category = ""; | ||
149 | + this.description = ""; | ||
150 | + this.short_description = ""; | ||
151 | + this.region = ""; | ||
152 | + this.latitude = 0.0; | ||
153 | + this.longitude = 0.0; | ||
154 | + this.image = ""; | ||
155 | + this.extra_fields = new JSONObject(); | ||
156 | + this.active = true; | ||
157 | + this.city = ""; | ||
158 | + this.country = ""; | ||
159 | + this.postal_code = ""; | ||
160 | + this.vat = ""; | ||
161 | + this.uuid = ""; | ||
162 | + this.category_uuid = ""; | ||
163 | + this.created = ""; | ||
164 | + this.parent = ""; | ||
165 | + this.img = new JSONArray(); | ||
166 | + this.img_preview = ""; | ||
167 | + this.admin_name = ""; | ||
168 | + this.sorting = 0; | ||
169 | + this.body = ""; | ||
170 | + this.owner_name = ""; | ||
171 | + this.preview = ""; | ||
172 | + this.merchant_metadata = new JSONObject(); | ||
173 | + this.promoted = false; | ||
174 | + this.distance = 0; | ||
175 | + this.default_shown = true; | ||
176 | + this.hidden = false; | ||
177 | + this.working_hours = new JSONObject(); | ||
178 | + this.tags = new JSONArray(); | ||
179 | + this.product = new JSONObject(); | ||
180 | + coordinates = new LatLng(this.latitude, this.longitude); | ||
181 | + } | ||
182 | + | ||
139 | /** | 183 | /** |
140 | * Basic constructor used to create an object from a String, representing a | 184 | * Basic constructor used to create an object from a String, representing a |
141 | * JSON Object | 185 | * JSON Object | ... | ... |
... | @@ -61,6 +61,7 @@ import ly.warp.sdk.io.models.CustomerStateModel; | ... | @@ -61,6 +61,7 @@ import ly.warp.sdk.io.models.CustomerStateModel; |
61 | import ly.warp.sdk.io.models.LoyaltyBadgeModel; | 61 | import ly.warp.sdk.io.models.LoyaltyBadgeModel; |
62 | import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; | 62 | import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; |
63 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage; | 63 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage; |
64 | +import ly.warp.sdk.io.models.MerchantList; | ||
64 | import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest; | 65 | import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest; |
65 | import ly.warp.sdk.io.request.CosmoteSharingRequest; | 66 | import ly.warp.sdk.io.request.CosmoteSharingRequest; |
66 | import ly.warp.sdk.io.request.WarplyIntegrationRequest; | 67 | import ly.warp.sdk.io.request.WarplyIntegrationRequest; |
... | @@ -96,6 +97,7 @@ public class WarplyManagerHelper { | ... | @@ -96,6 +97,7 @@ public class WarplyManagerHelper { |
96 | mAlertDialogReturnSharing, mAlertDialogErrorSharing; | 97 | mAlertDialogReturnSharing, mAlertDialogErrorSharing; |
97 | private static LoyaltyBadgeModel mLoyaltyBadge = new LoyaltyBadgeModel(); | 98 | private static LoyaltyBadgeModel mLoyaltyBadge = new LoyaltyBadgeModel(); |
98 | private static float mDealsSum = 0.0f; | 99 | private static float mDealsSum = 0.0f; |
100 | + private static MerchantList mMerchantList = new MerchantList(); | ||
99 | 101 | ||
100 | // =========================================================== | 102 | // =========================================================== |
101 | // Methods for/from SuperClass/Interfaces | 103 | // Methods for/from SuperClass/Interfaces |
... | @@ -908,6 +910,14 @@ public class WarplyManagerHelper { | ... | @@ -908,6 +910,14 @@ public class WarplyManagerHelper { |
908 | mCouponsetsList = couponsets; | 910 | mCouponsetsList = couponsets; |
909 | } | 911 | } |
910 | 912 | ||
913 | + public static void setMerchantList(MerchantList merchantList) { | ||
914 | + mMerchantList = merchantList; | ||
915 | + } | ||
916 | + | ||
917 | + public static MerchantList getMerchantList() { | ||
918 | + return mMerchantList; | ||
919 | + } | ||
920 | + | ||
911 | public static float getDealsCouponsSum() { | 921 | public static float getDealsCouponsSum() { |
912 | return mDealsSum; | 922 | return mDealsSum; |
913 | } | 923 | } | ... | ... |
... | @@ -25,6 +25,10 @@ | ... | @@ -25,6 +25,10 @@ |
25 | 25 | ||
26 | package ly.warp.sdk.utils.managers; | 26 | package ly.warp.sdk.utils.managers; |
27 | 27 | ||
28 | +import android.os.Handler; | ||
29 | +import android.os.Looper; | ||
30 | +import android.util.Log; | ||
31 | + | ||
28 | import org.json.JSONArray; | 32 | import org.json.JSONArray; |
29 | import org.json.JSONException; | 33 | import org.json.JSONException; |
30 | import org.json.JSONObject; | 34 | import org.json.JSONObject; |
... | @@ -2163,65 +2167,80 @@ public class WarplyManager { | ... | @@ -2163,65 +2167,80 @@ public class WarplyManager { |
2163 | WarpUtils.log("[WARP Trace] WARPLY User Coupons Request is active"); | 2167 | WarpUtils.log("[WARP Trace] WARPLY User Coupons Request is active"); |
2164 | WarpUtils.log("**************************************************"); | 2168 | WarpUtils.log("**************************************************"); |
2165 | 2169 | ||
2166 | - getCouponsets(new WarplyGetCouponsetsRequest() | 2170 | + WarplyManager.getMerchantsMultilingual(new WarplyMerchantsRequest() |
2167 | - .setLanguage(WarplyProperty.getLanguage(Warply.getWarplyContext())), new CallbackReceiver<CouponsetsList>() { | 2171 | + .setIsMultilingual(true) |
2168 | - @Override | 2172 | + , new CallbackReceiver<MerchantList>() { |
2169 | - public void onSuccess(CouponsetsList result) { | ||
2170 | - Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, true, "context", request.toJson(), new CouponsHook(new CallbackReceiver<CouponList>() { | ||
2171 | @Override | 2173 | @Override |
2172 | - public void onSuccess(CouponList response) { | 2174 | + public void onSuccess(MerchantList result) { |
2173 | - CouponList mCouponList = new CouponList(); | 2175 | + WarplyManagerHelper.setMerchantList(result); |
2174 | - for (Coupon coupon : response) { | ||
2175 | - for (Couponset couponset : result) { | ||
2176 | - if (coupon.getCouponsetUuid().equals(couponset.getUuid())) { | ||
2177 | - coupon.setDescription(couponset.getShortDescription()); | ||
2178 | - coupon.setImage(couponset.getImgPreview()); | ||
2179 | - coupon.setName(couponset.getName()); | ||
2180 | - mCouponList.add(coupon); | ||
2181 | - } | ||
2182 | - } | ||
2183 | - } | ||
2184 | - WarplyManagerHelper.setCouponList(mCouponList); | ||
2185 | 2176 | ||
2186 | - CouponList mActiveCouponList = new CouponList(); | 2177 | + getCouponsets(new WarplyGetCouponsetsRequest() |
2187 | - for (Coupon coupon : mCouponList) { | 2178 | + .setLanguage(WarplyProperty.getLanguage(Warply.getWarplyContext())), new CallbackReceiver<CouponsetsList>() { |
2188 | - if (coupon.getStatus() == 1) | 2179 | + @Override |
2189 | - mActiveCouponList.add(coupon); | 2180 | + public void onSuccess(CouponsetsList result) { |
2190 | - } | 2181 | + Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, true, "context", request.toJson(), new CouponsHook(new CallbackReceiver<CouponList>() { |
2182 | + @Override | ||
2183 | + public void onSuccess(CouponList response) { | ||
2184 | + CouponList mCouponList = new CouponList(); | ||
2185 | + for (Coupon coupon : response) { | ||
2186 | + for (Couponset couponset : result) { | ||
2187 | + if (coupon.getCouponsetUuid().equals(couponset.getUuid())) { | ||
2188 | + coupon.setDescription(couponset.getShortDescription()); | ||
2189 | + coupon.setImage(couponset.getImgPreview()); | ||
2190 | + coupon.setName(couponset.getName()); | ||
2191 | + coupon.setMerchantUuid(couponset.getMerchantUuid()); | ||
2192 | + mCouponList.add(coupon); | ||
2193 | + } | ||
2194 | + } | ||
2195 | + } | ||
2196 | + WarplyManagerHelper.setCouponList(mCouponList); | ||
2197 | + | ||
2198 | + CouponList mActiveCouponList = new CouponList(); | ||
2199 | + for (Coupon coupon : mCouponList) { | ||
2200 | + if (coupon.getStatus() == 1) | ||
2201 | + mActiveCouponList.add(coupon); | ||
2202 | + } | ||
2203 | + | ||
2204 | + receiver.onSuccess(mActiveCouponList); | ||
2205 | + } | ||
2206 | + | ||
2207 | + @Override | ||
2208 | + public void onFailure(int errorCode) { | ||
2209 | + if (errorCode == 401) { | ||
2210 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
2211 | + @Override | ||
2212 | + public void onSuccess(JSONObject result) { | ||
2213 | + int status = result.optInt("status", 2); | ||
2214 | + if (status == 1) | ||
2215 | + getUserCoupons(request, receiver); | ||
2216 | + else | ||
2217 | + receiver.onFailure(status); | ||
2218 | + } | ||
2219 | + | ||
2220 | + @Override | ||
2221 | + public void onFailure(int errorCode) { | ||
2222 | + receiver.onFailure(errorCode); | ||
2223 | + } | ||
2224 | + }); | ||
2225 | + } else | ||
2226 | + receiver.onFailure(errorCode); | ||
2227 | + } | ||
2228 | + }, | ||
2229 | + request.getSignature())); | ||
2230 | + } | ||
2191 | 2231 | ||
2192 | - receiver.onSuccess(mActiveCouponList); | 2232 | + @Override |
2233 | + public void onFailure(int errorCode) { | ||
2234 | + receiver.onFailure(errorCode); | ||
2235 | + } | ||
2236 | + }); | ||
2193 | } | 2237 | } |
2194 | 2238 | ||
2195 | @Override | 2239 | @Override |
2196 | public void onFailure(int errorCode) { | 2240 | public void onFailure(int errorCode) { |
2197 | - if (errorCode == 401) { | ||
2198 | - refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
2199 | - @Override | ||
2200 | - public void onSuccess(JSONObject result) { | ||
2201 | - int status = result.optInt("status", 2); | ||
2202 | - if (status == 1) | ||
2203 | - getUserCoupons(request, receiver); | ||
2204 | - else | ||
2205 | - receiver.onFailure(status); | ||
2206 | - } | ||
2207 | 2241 | ||
2208 | - @Override | ||
2209 | - public void onFailure(int errorCode) { | ||
2210 | - receiver.onFailure(errorCode); | ||
2211 | - } | ||
2212 | - }); | ||
2213 | - } else | ||
2214 | - receiver.onFailure(errorCode); | ||
2215 | } | 2242 | } |
2216 | - }, | 2243 | + }); |
2217 | - request.getSignature())); | ||
2218 | - } | ||
2219 | - | ||
2220 | - @Override | ||
2221 | - public void onFailure(int errorCode) { | ||
2222 | - receiver.onFailure(errorCode); | ||
2223 | - } | ||
2224 | - }); | ||
2225 | } | 2244 | } |
2226 | 2245 | ||
2227 | public static void getCosmoteUser(WarplyCosmoteUserRequest request, final CallbackReceiver<JSONObject> receiver) { | 2246 | public static void getCosmoteUser(WarplyCosmoteUserRequest request, final CallbackReceiver<JSONObject> receiver) { | ... | ... |
... | @@ -24,6 +24,8 @@ import io.reactivex.subjects.PublishSubject; | ... | @@ -24,6 +24,8 @@ import io.reactivex.subjects.PublishSubject; |
24 | import ly.warp.sdk.R; | 24 | import ly.warp.sdk.R; |
25 | import ly.warp.sdk.io.models.Coupon; | 25 | import ly.warp.sdk.io.models.Coupon; |
26 | import ly.warp.sdk.io.models.CouponList; | 26 | import ly.warp.sdk.io.models.CouponList; |
27 | +import ly.warp.sdk.io.models.Merchant; | ||
28 | +import ly.warp.sdk.utils.WarplyManagerHelper; | ||
27 | 29 | ||
28 | public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapter.ActiveCouponViewHolder> { | 30 | public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapter.ActiveCouponViewHolder> { |
29 | 31 | ||
... | @@ -92,30 +94,61 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte | ... | @@ -92,30 +94,61 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte |
92 | @Override | 94 | @Override |
93 | public void onBindViewHolder(final ActiveCouponViewHolder holder, int position) { | 95 | public void onBindViewHolder(final ActiveCouponViewHolder holder, int position) { |
94 | Coupon couponItem = mCoupons.get(position); | 96 | Coupon couponItem = mCoupons.get(position); |
97 | + Merchant merchant = new Merchant(); | ||
95 | 98 | ||
96 | if (mIsPast) | 99 | if (mIsPast) |
97 | holder.ivCouponBackground.setColorFilter(ContextCompat.getColor(mContext, R.color.grey_light3), android.graphics.PorterDuff.Mode.MULTIPLY); | 100 | holder.ivCouponBackground.setColorFilter(ContextCompat.getColor(mContext, R.color.grey_light3), android.graphics.PorterDuff.Mode.MULTIPLY); |
98 | 101 | ||
99 | if (couponItem != null) { | 102 | if (couponItem != null) { |
100 | - if (!TextUtils.isEmpty(couponItem.getImage())) { | 103 | + if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) { |
101 | - Glide.with(mContext) | 104 | + for (Merchant mer : WarplyManagerHelper.getMerchantList()) { |
105 | + if (mer.getUuid().equals(couponItem.getMerchantUuid())) { | ||
106 | + merchant = mer; | ||
107 | + break; | ||
108 | + } | ||
109 | + } | ||
110 | + } | ||
111 | + | ||
112 | + if (merchant == null) { | ||
113 | + if (!TextUtils.isEmpty(couponItem.getImage())) { | ||
114 | + Glide.with(mContext) | ||
102 | // .setDefaultRequestOptions( | 115 | // .setDefaultRequestOptions( |
103 | // RequestOptions | 116 | // RequestOptions |
104 | // .placeholderOf(R.drawable.ic_default_contact_photo) | 117 | // .placeholderOf(R.drawable.ic_default_contact_photo) |
105 | // .error(R.drawable.ic_default_contact_photo)) | 118 | // .error(R.drawable.ic_default_contact_photo)) |
106 | - .load(couponItem.getImage()) | 119 | + .load(couponItem.getImage()) |
107 | - .diskCacheStrategy(DiskCacheStrategy.DATA) | 120 | + .diskCacheStrategy(DiskCacheStrategy.DATA) |
108 | - .into(holder.ivCouponLogo); | 121 | + .into(holder.ivCouponLogo); |
122 | + } else { | ||
123 | + Glide.with(mContext) | ||
124 | + .load(R.drawable.ic_cosmote_logo_horizontal_grey) | ||
125 | + .into(holder.ivCouponLogo); | ||
126 | + } | ||
127 | + | ||
128 | + holder.tvCouponTitle.setText(couponItem.getName()); | ||
129 | + if (!mIsPast) | ||
130 | + holder.tvCouponDescription.setText(couponItem.getDescription()); | ||
109 | } else { | 131 | } else { |
110 | - Glide.with(mContext) | 132 | + if (!TextUtils.isEmpty(merchant.getImage())) { |
111 | - .load(R.drawable.ic_cosmote_logo_horizontal_grey) | 133 | + Glide.with(mContext) |
112 | - .into(holder.ivCouponLogo); | 134 | +// .setDefaultRequestOptions( |
135 | +// RequestOptions | ||
136 | +// .placeholderOf(R.drawable.ic_default_contact_photo) | ||
137 | +// .error(R.drawable.ic_default_contact_photo)) | ||
138 | + .load(merchant.getImage()) | ||
139 | + .diskCacheStrategy(DiskCacheStrategy.DATA) | ||
140 | + .into(holder.ivCouponLogo); | ||
141 | + } else { | ||
142 | + Glide.with(mContext) | ||
143 | + .load(R.drawable.ic_cosmote_logo_horizontal_grey) | ||
144 | + .into(holder.ivCouponLogo); | ||
145 | + } | ||
146 | + | ||
147 | + holder.tvCouponTitle.setText(merchant.getAdminName()); | ||
148 | + if (!mIsPast) | ||
149 | + holder.tvCouponDescription.setText(merchant.getShortDescription()); | ||
113 | } | 150 | } |
114 | 151 | ||
115 | - holder.tvCouponTitle.setText(couponItem.getName()); | ||
116 | - if (!mIsPast) | ||
117 | - holder.tvCouponDescription.setText(couponItem.getDescription()); | ||
118 | - | ||
119 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); | 152 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); |
120 | Date newDate = new Date(); | 153 | Date newDate = new Date(); |
121 | try { | 154 | try { | ... | ... |
1.29 KB
This diff is collapsed. Click to expand it.
... | @@ -121,6 +121,8 @@ | ... | @@ -121,6 +121,8 @@ |
121 | <string name="cos_wallet_text4"> σε προσφορές από </string> | 121 | <string name="cos_wallet_text4"> σε προσφορές από </string> |
122 | <string name="cos_wallet_text5"> κουπόνια!</string> | 122 | <string name="cos_wallet_text5"> κουπόνια!</string> |
123 | <string name="cos_value2">%1$s</string> | 123 | <string name="cos_value2">%1$s</string> |
124 | + <string name="cos_show_barcode">Εμφάνιση barcode</string> | ||
125 | + <string name="cos_hide_barcode">Απόκρυψη barcode</string> | ||
124 | 126 | ||
125 | <string-array name="coupons_array"> | 127 | <string-array name="coupons_array"> |
126 | <item>Κουπόνια</item> | 128 | <item>Κουπόνια</item> | ... | ... |
-
Please register or login to post a comment