new coupons request part3, fixes in active coupons, sm coupons, map
Showing
10 changed files
with
148 additions
and
172 deletions
| ... | @@ -116,7 +116,7 @@ public class ActiveCouponsActivity extends Activity implements View.OnClickListe | ... | @@ -116,7 +116,7 @@ public class ActiveCouponsActivity extends Activity implements View.OnClickListe |
| 116 | mCouponsPressed = true; | 116 | mCouponsPressed = true; |
| 117 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Coupon").concat(":").concat(coupon.getName())); | 117 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Coupon").concat(":").concat(coupon.getName())); |
| 118 | Intent intent = new Intent(ActiveCouponsActivity.this, CouponInfoActivity.class); | 118 | Intent intent = new Intent(ActiveCouponsActivity.this, CouponInfoActivity.class); |
| 119 | - intent.putExtra("coupon", (Serializable) coupon); | 119 | + intent.putExtra("coupon", coupon.getCoupon()); |
| 120 | startActivity(intent); | 120 | startActivity(intent); |
| 121 | } | 121 | } |
| 122 | }) | 122 | }) | ... | ... |
| ... | @@ -93,7 +93,7 @@ public class ActiveGiftsActivity extends Activity implements View.OnClickListene | ... | @@ -93,7 +93,7 @@ public class ActiveGiftsActivity extends Activity implements View.OnClickListene |
| 93 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | 93 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); |
| 94 | } else if (dataItem.getDataType() == 2) { | 94 | } else if (dataItem.getDataType() == 2) { |
| 95 | Intent intent = new Intent(ActiveGiftsActivity.this, CouponInfoActivity.class); | 95 | Intent intent = new Intent(ActiveGiftsActivity.this, CouponInfoActivity.class); |
| 96 | - intent.putExtra("coupon", (Serializable) dataItem.getCoupon()); | 96 | + intent.putExtra("coupon", dataItem.getCoupon().getCoupon()); |
| 97 | startActivity(intent); | 97 | startActivity(intent); |
| 98 | } | 98 | } |
| 99 | }) | 99 | }) | ... | ... |
| ... | @@ -35,8 +35,7 @@ import java.util.Date; | ... | @@ -35,8 +35,7 @@ import java.util.Date; |
| 35 | import io.github.inflationx.viewpump.ViewPumpContextWrapper; | 35 | import io.github.inflationx.viewpump.ViewPumpContextWrapper; |
| 36 | import ly.warp.sdk.R; | 36 | import ly.warp.sdk.R; |
| 37 | import ly.warp.sdk.io.models.Coupon; | 37 | import ly.warp.sdk.io.models.Coupon; |
| 38 | -import ly.warp.sdk.io.models.Couponset; | 38 | +import ly.warp.sdk.io.models.UnifiedCoupon; |
| 39 | -import ly.warp.sdk.io.models.Merchant; | ||
| 40 | import ly.warp.sdk.services.EventCouponsService; | 39 | import ly.warp.sdk.services.EventCouponsService; |
| 41 | import ly.warp.sdk.utils.WarplyManagerHelper; | 40 | import ly.warp.sdk.utils.WarplyManagerHelper; |
| 42 | import ly.warp.sdk.utils.managers.WarplyAnalyticsManager; | 41 | import ly.warp.sdk.utils.managers.WarplyAnalyticsManager; |
| ... | @@ -57,10 +56,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -57,10 +56,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
| 57 | mTvTermsValue, mTvFullBarcode, mTvDescription, mTvCouponCodeTitle; | 56 | mTvTermsValue, mTvFullBarcode, mTvDescription, mTvCouponCodeTitle; |
| 58 | private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms, mLlWebsite; | 57 | private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms, mLlWebsite; |
| 59 | private Coupon mCoupon; | 58 | private Coupon mCoupon; |
| 60 | - private Couponset mCouponset; | ||
| 61 | private boolean mIsBarcodeShown = false, mIsTermsShown = false, mIsFromWallet = false, | 59 | private boolean mIsBarcodeShown = false, mIsTermsShown = false, mIsFromWallet = false, |
| 62 | mShopsPressed = false, mGiftPressed = false, mEshopPressed = false, mIsUnified = false; | 60 | mShopsPressed = false, mGiftPressed = false, mEshopPressed = false, mIsUnified = false; |
| 63 | - private Merchant mMerchant; | ||
| 64 | 61 | ||
| 65 | // =========================================================== | 62 | // =========================================================== |
| 66 | // Methods for/from SuperClass/Interfaces | 63 | // Methods for/from SuperClass/Interfaces |
| ... | @@ -71,10 +68,32 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -71,10 +68,32 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
| 71 | super.onCreate(savedInstanceState); | 68 | super.onCreate(savedInstanceState); |
| 72 | setContentView(R.layout.activity_coupon_info); | 69 | setContentView(R.layout.activity_coupon_info); |
| 73 | 70 | ||
| 74 | - mCoupon = (Coupon) getIntent().getSerializableExtra("coupon"); | 71 | + String couponCode = getIntent().getStringExtra("coupon"); |
| 75 | mIsFromWallet = getIntent().getBooleanExtra("isFromWallet", false); | 72 | mIsFromWallet = getIntent().getBooleanExtra("isFromWallet", false); |
| 76 | mIsUnified = getIntent().getBooleanExtra("isUnified", false); | 73 | mIsUnified = getIntent().getBooleanExtra("isUnified", false); |
| 77 | 74 | ||
| 75 | + if (mIsUnified) { | ||
| 76 | + String couponUnifiedCode = getIntent().getStringExtra("unifiedCoupon"); | ||
| 77 | + for (UnifiedCoupon couponItem : WarplyManagerHelper.getMarketCoupons()) { | ||
| 78 | + if (couponItem.getBarcode().equals(couponUnifiedCode)) { | ||
| 79 | + for (Coupon cpn : couponItem.getCoupons()) { | ||
| 80 | + if (cpn.getCoupon().equals(couponCode)) { | ||
| 81 | + mCoupon = cpn; | ||
| 82 | + break; | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + break; | ||
| 86 | + } | ||
| 87 | + } | ||
| 88 | + } else { | ||
| 89 | + for (Coupon cpn : WarplyManagerHelper.getCouponList()) { | ||
| 90 | + if (cpn.getCoupon().equals(couponCode)) { | ||
| 91 | + mCoupon = cpn; | ||
| 92 | + break; | ||
| 93 | + } | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + | ||
| 78 | mIvBack = findViewById(R.id.iv_coupon_info_back); | 97 | mIvBack = findViewById(R.id.iv_coupon_info_back); |
| 79 | mTvTerms = findViewById(R.id.tv_terms); | 98 | mTvTerms = findViewById(R.id.tv_terms); |
| 80 | mLlGiftIt = findViewById(R.id.ll_gift_it); | 99 | mLlGiftIt = findViewById(R.id.ll_gift_it); |
| ... | @@ -147,12 +166,12 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -147,12 +166,12 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
| 147 | 166 | ||
| 148 | if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(CouponInfoActivity.this) == ConnectionResult.SUCCESS) { | 167 | if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(CouponInfoActivity.this) == ConnectionResult.SUCCESS) { |
| 149 | Intent intent = new Intent(CouponInfoActivity.this, ShopsActivity.class); | 168 | Intent intent = new Intent(CouponInfoActivity.this, ShopsActivity.class); |
| 150 | - intent.putExtra("couponset", (Serializable) mCouponset); | 169 | + intent.putExtra("coupon", mCoupon.getCoupon()); |
| 151 | startActivity(intent); | 170 | startActivity(intent); |
| 152 | return; | 171 | return; |
| 153 | } else { | 172 | } else { |
| 154 | Intent intent = new Intent(CouponInfoActivity.this, ShopsHuaweiActivity.class); | 173 | Intent intent = new Intent(CouponInfoActivity.this, ShopsHuaweiActivity.class); |
| 155 | - intent.putExtra("couponset", (Serializable) mCouponset); | 174 | + intent.putExtra("coupon", mCoupon.getCoupon()); |
| 156 | startActivity(intent); | 175 | startActivity(intent); |
| 157 | return; | 176 | return; |
| 158 | } | 177 | } |
| ... | @@ -163,9 +182,9 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -163,9 +182,9 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
| 163 | mEshopPressed = true; | 182 | mEshopPressed = true; |
| 164 | WarplyAnalyticsManager.logTrackersEvent(this, "click", "SeeShopWebsite"); | 183 | WarplyAnalyticsManager.logTrackersEvent(this, "click", "SeeShopWebsite"); |
| 165 | 184 | ||
| 166 | - if (!TextUtils.isEmpty(mMerchant.getWebsite())) { | 185 | + if (mCoupon != null && mCoupon.getMerchantDetails() != null && !TextUtils.isEmpty(mCoupon.getMerchantDetails().getWebsite())) { |
| 167 | Intent intent = new Intent(Intent.ACTION_VIEW); | 186 | Intent intent = new Intent(Intent.ACTION_VIEW); |
| 168 | - intent.setData(Uri.parse(mMerchant.getWebsite())); | 187 | + intent.setData(Uri.parse(mCoupon.getMerchantDetails().getWebsite())); |
| 169 | startActivity(intent); | 188 | startActivity(intent); |
| 170 | } | 189 | } |
| 171 | } | 190 | } |
| ... | @@ -227,81 +246,37 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -227,81 +246,37 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
| 227 | mTvCouponTitle.setText(HtmlCompat.fromHtml(mCoupon.getName(), HtmlCompat.FROM_HTML_MODE_COMPACT)); | 246 | mTvCouponTitle.setText(HtmlCompat.fromHtml(mCoupon.getName(), HtmlCompat.FROM_HTML_MODE_COMPACT)); |
| 228 | } else { | 247 | } else { |
| 229 | mTvCouponCode.setText(mCoupon.getCoupon()); | 248 | mTvCouponCode.setText(mCoupon.getCoupon()); |
| 230 | - mTvCouponTitle.setText(mCoupon.getName()); | 249 | + mTvCouponTitle.setText(mCoupon.getCouponsetDetails().getName()); |
| 231 | - } | ||
| 232 | -// mTvCouponSubtitle.setText(mCoupon.getDescription()); | ||
| 233 | - | ||
| 234 | - if (WarplyManagerHelper.getCouponsets() != null && WarplyManagerHelper.getCouponsets().size() > 0) { | ||
| 235 | - for (Couponset couponset : WarplyManagerHelper.getCouponsets()) { | ||
| 236 | - if (couponset.getUuid().equals(mCoupon.getCouponsetUuid())) { | ||
| 237 | - mCouponset = couponset; | ||
| 238 | - break; | ||
| 239 | - } | ||
| 240 | - } | ||
| 241 | - } | ||
| 242 | - | ||
| 243 | - if (mCouponset != null) { | ||
| 244 | - if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) { | ||
| 245 | - for (Merchant merchant : WarplyManagerHelper.getMerchantList()) { | ||
| 246 | - if (merchant.getUuid().equals(mCouponset.getMerchantUuid())) { | ||
| 247 | - mMerchant = merchant; | ||
| 248 | - break; | ||
| 249 | - } | ||
| 250 | } | 250 | } |
| 251 | 251 | ||
| 252 | - if (mMerchant != null && !TextUtils.isEmpty(mMerchant.getBody()) && !mMerchant.getBody().equals("null")) { | 252 | + if (mCoupon != null) { |
| 253 | - mTvDescription.setText(HtmlCompat.fromHtml(mMerchant.getBody(), HtmlCompat.FROM_HTML_MODE_COMPACT)); | 253 | + if (mIsFromWallet) { |
| 254 | - mTvDescription.setMovementMethod(LinkMovementMethod.getInstance()); | 254 | + if (mCoupon.getMerchantDetails() != null) { |
| 255 | - } else { | ||
| 256 | mTvDescription.setVisibility(View.GONE); | 255 | mTvDescription.setVisibility(View.GONE); |
| 257 | - } | ||
| 258 | - | ||
| 259 | -// if (mMerchant != null) { | ||
| 260 | -// if (mMerchant.getExtraFields() != null && mMerchant.getExtraFields().has("show_map") && (mMerchant.getExtraFields().optBoolean("show_map") || mMerchant.getExtraFields().optString("show_map").equals("true"))) { | ||
| 261 | mLlShops.setVisibility(View.VISIBLE); | 256 | mLlShops.setVisibility(View.VISIBLE); |
| 262 | -// } | ||
| 263 | -// if (mMerchant.getExtraFields() != null && mMerchant.getExtraFields().has("eshop") && (mMerchant.getExtraFields().optBoolean("eshop") || mMerchant.getExtraFields().optString("eshop").equals("true"))) { | ||
| 264 | -// mLlWebsite.setVisibility(View.VISIBLE); | ||
| 265 | -// } | ||
| 266 | -// } | ||
| 267 | } | 257 | } |
| 268 | 258 | ||
| 269 | - mTvCouponSubtitle.setText(mCouponset.getShortDescription()); | 259 | + if (mIsUnified) { |
| 270 | - mTvTermsValue.setText(HtmlCompat.fromHtml(mCouponset.getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT)); | 260 | + mTvCouponSubtitle.setText(HtmlCompat.fromHtml(mCoupon.getDescription(), HtmlCompat.FROM_HTML_MODE_COMPACT)); |
| 271 | - mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance()); | ||
| 272 | } else { | 261 | } else { |
| 273 | - if (mIsFromWallet) { | 262 | + mTvCouponSubtitle.setText(mCoupon.getCouponsetDetails().getShortDescription()); |
| 274 | - if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) { | ||
| 275 | - for (Merchant merchant : WarplyManagerHelper.getMerchantList()) { | ||
| 276 | - if (merchant.getUuid().equals(mCoupon.getMerchantUuid())) { | ||
| 277 | - mMerchant = merchant; | ||
| 278 | - break; | ||
| 279 | } | 263 | } |
| 280 | - } | 264 | + mTvTermsValue.setText(HtmlCompat.fromHtml(mCoupon.getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT)); |
| 281 | - | 265 | + mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance()); |
| 282 | -// if (mMerchant != null && !TextUtils.isEmpty(mMerchant.getBody()) && !mMerchant.getBody().equals("null")) { | 266 | + } else { |
| 283 | -// mTvDescription.setText(HtmlCompat.fromHtml(mMerchant.getBody(), HtmlCompat.FROM_HTML_MODE_COMPACT)); | 267 | + if (mCoupon.getMerchantDetails() != null) { |
| 284 | -// mTvDescription.setMovementMethod(LinkMovementMethod.getInstance()); | 268 | + if (mCoupon.getMerchantDetails() != null && !TextUtils.isEmpty(mCoupon.getMerchantDetails().getBody()) && !mCoupon.getMerchantDetails().getBody().equals("null")) { |
| 285 | -// } else { | 269 | + mTvDescription.setText(HtmlCompat.fromHtml(mCoupon.getMerchantDetails().getBody(), HtmlCompat.FROM_HTML_MODE_COMPACT)); |
| 270 | + mTvDescription.setMovementMethod(LinkMovementMethod.getInstance()); | ||
| 271 | + } else { | ||
| 286 | mTvDescription.setVisibility(View.GONE); | 272 | mTvDescription.setVisibility(View.GONE); |
| 287 | -// } | 273 | + } |
| 288 | 274 | ||
| 289 | -// if (mMerchant != null) { | ||
| 290 | -// if (mMerchant.getExtraFields() != null && mMerchant.getExtraFields().has("show_map") && (mMerchant.getExtraFields().optBoolean("show_map") || mMerchant.getExtraFields().optString("show_map").equals("true"))) { | ||
| 291 | mLlShops.setVisibility(View.VISIBLE); | 275 | mLlShops.setVisibility(View.VISIBLE); |
| 292 | -// } | ||
| 293 | -// if (mMerchant.getExtraFields() != null && mMerchant.getExtraFields().has("eshop") && (mMerchant.getExtraFields().optBoolean("eshop") || mMerchant.getExtraFields().optString("eshop").equals("true"))) { | ||
| 294 | -// mLlWebsite.setVisibility(View.VISIBLE); | ||
| 295 | -// } | ||
| 296 | -// } | ||
| 297 | } | 276 | } |
| 298 | 277 | ||
| 299 | - if(mIsUnified) { | 278 | + mTvCouponSubtitle.setText(mCoupon.getCouponsetDetails().getShortDescription()); |
| 300 | - mTvCouponSubtitle.setText(HtmlCompat.fromHtml(mCoupon.getDescription(), HtmlCompat.FROM_HTML_MODE_COMPACT)); | 279 | + mTvTermsValue.setText(HtmlCompat.fromHtml(mCoupon.getCouponsetDetails().getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT)); |
| 301 | - } else { | ||
| 302 | - mTvCouponSubtitle.setText(mCoupon.getShort_description()); | ||
| 303 | - } | ||
| 304 | - mTvTermsValue.setText(HtmlCompat.fromHtml(mCoupon.getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT)); | ||
| 305 | mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance()); | 280 | mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance()); |
| 306 | } | 281 | } |
| 307 | } | 282 | } |
| ... | @@ -316,19 +291,33 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -316,19 +291,33 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
| 316 | simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy"); | 291 | simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy"); |
| 317 | mTvCouponDate.setText(String.format(getResources().getString(R.string.cos_mycoupon_date), simpleDateFormat.format(newDate != null ? newDate : ""))); | 292 | mTvCouponDate.setText(String.format(getResources().getString(R.string.cos_mycoupon_date), simpleDateFormat.format(newDate != null ? newDate : ""))); |
| 318 | 293 | ||
| 319 | - if (!TextUtils.isEmpty(mCoupon.getImage())) { | ||
| 320 | if (mIsUnified) { | 294 | if (mIsUnified) { |
| 321 | mIvCouponPhoto.setScaleType(ImageView.ScaleType.CENTER_INSIDE); | 295 | mIvCouponPhoto.setScaleType(ImageView.ScaleType.CENTER_INSIDE); |
| 296 | + | ||
| 297 | + if (!TextUtils.isEmpty(mCoupon.getImage())) { | ||
| 298 | + Glide.with(this) | ||
| 299 | +// .setDefaultRequestOptions( | ||
| 300 | +// RequestOptions | ||
| 301 | +// .placeholderOf(R.drawable.ic_default_contact_photo) | ||
| 302 | +// .error(R.drawable.ic_default_contact_photo)) | ||
| 303 | + .load(mCoupon.getImage()) | ||
| 304 | + .diskCacheStrategy(DiskCacheStrategy.DATA) | ||
| 305 | + .into(mIvCouponPhoto); | ||
| 322 | } else { | 306 | } else { |
| 323 | - mIvCouponPhoto.setScaleType(ImageView.ScaleType.CENTER_CROP); | 307 | + Glide.with(this) |
| 308 | + .load(R.drawable.ic_cosmote_logo_horizontal_grey) | ||
| 309 | + .into(mIvCouponPhoto); | ||
| 324 | } | 310 | } |
| 311 | + } else { | ||
| 312 | + mIvCouponPhoto.setScaleType(ImageView.ScaleType.CENTER_CROP); | ||
| 325 | 313 | ||
| 314 | + if (!TextUtils.isEmpty(mCoupon.getCouponsetDetails().getImgPreview())) { | ||
| 326 | Glide.with(this) | 315 | Glide.with(this) |
| 327 | // .setDefaultRequestOptions( | 316 | // .setDefaultRequestOptions( |
| 328 | // RequestOptions | 317 | // RequestOptions |
| 329 | // .placeholderOf(R.drawable.ic_default_contact_photo) | 318 | // .placeholderOf(R.drawable.ic_default_contact_photo) |
| 330 | // .error(R.drawable.ic_default_contact_photo)) | 319 | // .error(R.drawable.ic_default_contact_photo)) |
| 331 | - .load(mCoupon.getImage()) | 320 | + .load(mCoupon.getCouponsetDetails().getImgPreview()) |
| 332 | .diskCacheStrategy(DiskCacheStrategy.DATA) | 321 | .diskCacheStrategy(DiskCacheStrategy.DATA) |
| 333 | .into(mIvCouponPhoto); | 322 | .into(mIvCouponPhoto); |
| 334 | } else { | 323 | } else { |
| ... | @@ -336,8 +325,9 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener | ... | @@ -336,8 +325,9 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener |
| 336 | .load(R.drawable.ic_cosmote_logo_horizontal_grey) | 325 | .load(R.drawable.ic_cosmote_logo_horizontal_grey) |
| 337 | .into(mIvCouponPhoto); | 326 | .into(mIvCouponPhoto); |
| 338 | } | 327 | } |
| 328 | + } | ||
| 329 | + | ||
| 339 | mIvBack.setOnClickListener(this); | 330 | mIvBack.setOnClickListener(this); |
| 340 | -// mTvTerms.setPaintFlags(mTvTerms.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); | ||
| 341 | mLlGiftIt.setOnClickListener(this); | 331 | mLlGiftIt.setOnClickListener(this); |
| 342 | mLlShops.setOnClickListener(this); | 332 | mLlShops.setOnClickListener(this); |
| 343 | mLlWebsite.setOnClickListener(this); | 333 | mLlWebsite.setOnClickListener(this); | ... | ... |
| ... | @@ -39,7 +39,7 @@ import java.util.ArrayList; | ... | @@ -39,7 +39,7 @@ import java.util.ArrayList; |
| 39 | import io.github.inflationx.viewpump.ViewPumpContextWrapper; | 39 | import io.github.inflationx.viewpump.ViewPumpContextWrapper; |
| 40 | import ly.warp.sdk.R; | 40 | import ly.warp.sdk.R; |
| 41 | import ly.warp.sdk.io.callbacks.CallbackReceiver; | 41 | import ly.warp.sdk.io.callbacks.CallbackReceiver; |
| 42 | -import ly.warp.sdk.io.models.Couponset; | 42 | +import ly.warp.sdk.io.models.Coupon; |
| 43 | import ly.warp.sdk.io.models.Merchant; | 43 | import ly.warp.sdk.io.models.Merchant; |
| 44 | import ly.warp.sdk.io.models.MerchantList; | 44 | import ly.warp.sdk.io.models.MerchantList; |
| 45 | import ly.warp.sdk.utils.WarplyManagerHelper; | 45 | import ly.warp.sdk.utils.WarplyManagerHelper; |
| ... | @@ -64,7 +64,7 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe | ... | @@ -64,7 +64,7 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe |
| 64 | // =========================================================== | 64 | // =========================================================== |
| 65 | 65 | ||
| 66 | private ImageView mIvBack; | 66 | private ImageView mIvBack; |
| 67 | - private Couponset mCouponset; | 67 | + private Coupon mCoupon; |
| 68 | private GoogleMap mMap; | 68 | private GoogleMap mMap; |
| 69 | private ClusterManager<Merchant> mClusterManager; | 69 | private ClusterManager<Merchant> mClusterManager; |
| 70 | private SupportMapFragment mMapView; | 70 | private SupportMapFragment mMapView; |
| ... | @@ -82,15 +82,14 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe | ... | @@ -82,15 +82,14 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe |
| 82 | super.onCreate(savedInstanceState); | 82 | super.onCreate(savedInstanceState); |
| 83 | setContentView(R.layout.activity_shops); | 83 | setContentView(R.layout.activity_shops); |
| 84 | 84 | ||
| 85 | - mCouponset = (Couponset) getIntent().getSerializableExtra("couponset"); | 85 | + String couponCode = getIntent().getStringExtra("coupon"); |
| 86 | - if (mCouponset != null) { | 86 | + for (Coupon cpn : WarplyManagerHelper.getCouponList()) { |
| 87 | - for (Merchant merchant : WarplyManagerHelper.getMerchantList()) { | 87 | + if (cpn.getCoupon().equals(couponCode)) { |
| 88 | - if (merchant.getUuid().equals(mCouponset.getMerchantUuid())) { | 88 | + mCoupon = cpn; |
| 89 | - mMerchant = merchant; | 89 | + mMerchant = cpn.getMerchantDetails(); |
| 90 | break; | 90 | break; |
| 91 | } | 91 | } |
| 92 | } | 92 | } |
| 93 | - } | ||
| 94 | 93 | ||
| 95 | mIvBack = findViewById(R.id.iv_shops_back); | 94 | mIvBack = findViewById(R.id.iv_shops_back); |
| 96 | mMapView = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mv_shops); | 95 | mMapView = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mv_shops); |
| ... | @@ -178,9 +177,9 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe | ... | @@ -178,9 +177,9 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe |
| 178 | //// mMap.setOnMarkerClickListener(/*mClusterManager*/this); | 177 | //// mMap.setOnMarkerClickListener(/*mClusterManager*/this); |
| 179 | // } | 178 | // } |
| 180 | 179 | ||
| 181 | - if (mCouponset != null) { | 180 | + if (mCoupon != null) { |
| 182 | ArrayList<String> uuids = new ArrayList<>(); | 181 | ArrayList<String> uuids = new ArrayList<>(); |
| 183 | - uuids.add(mCouponset.getMerchantUuid()); | 182 | + uuids.add(mCoupon.getMerchantUuid()); |
| 184 | WarplyManager.getMerchantsMultilingual(true, uuids, mMerchantsCallback); | 183 | WarplyManager.getMerchantsMultilingual(true, uuids, mMerchantsCallback); |
| 185 | } else { | 184 | } else { |
| 186 | ArrayList<String> catuuids = new ArrayList<>(); | 185 | ArrayList<String> catuuids = new ArrayList<>(); | ... | ... |
| ... | @@ -38,7 +38,7 @@ import java.util.ArrayList; | ... | @@ -38,7 +38,7 @@ import java.util.ArrayList; |
| 38 | import io.github.inflationx.viewpump.ViewPumpContextWrapper; | 38 | import io.github.inflationx.viewpump.ViewPumpContextWrapper; |
| 39 | import ly.warp.sdk.R; | 39 | import ly.warp.sdk.R; |
| 40 | import ly.warp.sdk.io.callbacks.CallbackReceiver; | 40 | import ly.warp.sdk.io.callbacks.CallbackReceiver; |
| 41 | -import ly.warp.sdk.io.models.Couponset; | 41 | +import ly.warp.sdk.io.models.Coupon; |
| 42 | import ly.warp.sdk.io.models.Merchant; | 42 | import ly.warp.sdk.io.models.Merchant; |
| 43 | import ly.warp.sdk.io.models.MerchantList; | 43 | import ly.warp.sdk.io.models.MerchantList; |
| 44 | import ly.warp.sdk.utils.WarplyManagerHelper; | 44 | import ly.warp.sdk.utils.WarplyManagerHelper; |
| ... | @@ -62,7 +62,7 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic | ... | @@ -62,7 +62,7 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic |
| 62 | // =========================================================== | 62 | // =========================================================== |
| 63 | 63 | ||
| 64 | private ImageView mIvBack; | 64 | private ImageView mIvBack; |
| 65 | - private Couponset mCouponset; | 65 | + private Coupon mCoupon; |
| 66 | private HuaweiMap mMap; | 66 | private HuaweiMap mMap; |
| 67 | // private ClusterManager<Merchant> mClusterManager; | 67 | // private ClusterManager<Merchant> mClusterManager; |
| 68 | private SupportMapFragment mSupportMapFragment; | 68 | private SupportMapFragment mSupportMapFragment; |
| ... | @@ -81,15 +81,14 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic | ... | @@ -81,15 +81,14 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic |
| 81 | MapsInitializer.initialize(this); | 81 | MapsInitializer.initialize(this); |
| 82 | setContentView(R.layout.activity_shops_huawei); | 82 | setContentView(R.layout.activity_shops_huawei); |
| 83 | 83 | ||
| 84 | - mCouponset = (Couponset) getIntent().getSerializableExtra("couponset"); | 84 | + String couponCode = getIntent().getStringExtra("coupon"); |
| 85 | - if (mCouponset != null) { | 85 | + for (Coupon cpn : WarplyManagerHelper.getCouponList()) { |
| 86 | - for (Merchant merchant : WarplyManagerHelper.getMerchantList()) { | 86 | + if (cpn.getCoupon().equals(couponCode)) { |
| 87 | - if (merchant.getUuid().equals(mCouponset.getMerchantUuid())) { | 87 | + mCoupon = cpn; |
| 88 | - mMerchant = merchant; | 88 | + mMerchant = cpn.getMerchantDetails(); |
| 89 | break; | 89 | break; |
| 90 | } | 90 | } |
| 91 | } | 91 | } |
| 92 | - } | ||
| 93 | 92 | ||
| 94 | mIvBack = findViewById(R.id.iv_shops_back); | 93 | mIvBack = findViewById(R.id.iv_shops_back); |
| 95 | mSupportMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mv_shops_huawei); | 94 | mSupportMapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.mv_shops_huawei); |
| ... | @@ -179,9 +178,9 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic | ... | @@ -179,9 +178,9 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic |
| 179 | //// mMap.setOnMarkerClickListener(/*mClusterManager*/this); | 178 | //// mMap.setOnMarkerClickListener(/*mClusterManager*/this); |
| 180 | // } | 179 | // } |
| 181 | // | 180 | // |
| 182 | - if (mCouponset != null) { | 181 | + if (mCoupon != null) { |
| 183 | ArrayList<String> uuids = new ArrayList<>(); | 182 | ArrayList<String> uuids = new ArrayList<>(); |
| 184 | - uuids.add(mCouponset.getMerchantUuid()); | 183 | + uuids.add(mCoupon.getMerchantUuid()); |
| 185 | WarplyManager.getMerchantsMultilingual(true, uuids, mMerchantsCallback); | 184 | WarplyManager.getMerchantsMultilingual(true, uuids, mMerchantsCallback); |
| 186 | } else { | 185 | } else { |
| 187 | ArrayList<String> catuuids = new ArrayList<>(); | 186 | ArrayList<String> catuuids = new ArrayList<>(); | ... | ... |
| ... | @@ -235,9 +235,10 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL | ... | @@ -235,9 +235,10 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL |
| 235 | mCouponPressed = true; | 235 | mCouponPressed = true; |
| 236 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("MarketCoupon").concat(":").concat(coupon.getName())); | 236 | WarplyAnalyticsManager.logTrackersEvent(this, "click", ("MarketCoupon").concat(":").concat(coupon.getName())); |
| 237 | Intent intent = new Intent(UnifiedCouponInfoActivity.this, CouponInfoActivity.class); | 237 | Intent intent = new Intent(UnifiedCouponInfoActivity.this, CouponInfoActivity.class); |
| 238 | - intent.putExtra("coupon", (Serializable) coupon); | 238 | + intent.putExtra("coupon", coupon.getCoupon()); |
| 239 | intent.putExtra("isFromWallet", true); | 239 | intent.putExtra("isFromWallet", true); |
| 240 | intent.putExtra("isUnified", true); | 240 | intent.putExtra("isUnified", true); |
| 241 | + intent.putExtra("unifiedCoupon", mCoupon.getBarcode()); | ||
| 241 | startActivity(intent); | 242 | startActivity(intent); |
| 242 | } | 243 | } |
| 243 | }) | 244 | }) | ... | ... |
| ... | @@ -112,6 +112,7 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -112,6 +112,7 @@ public class Couponset implements Parcelable, Serializable { |
| 112 | private String discount_type = ""; | 112 | private String discount_type = ""; |
| 113 | private double final_price = 0.0d; | 113 | private double final_price = 0.0d; |
| 114 | private Date endDate = new Date(); | 114 | private Date endDate = new Date(); |
| 115 | + private String couponsetType = ""; | ||
| 115 | 116 | ||
| 116 | public Couponset() { | 117 | public Couponset() { |
| 117 | this.uuid = ""; | 118 | this.uuid = ""; |
| ... | @@ -159,6 +160,9 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -159,6 +160,9 @@ public class Couponset implements Parcelable, Serializable { |
| 159 | this.updated = ""; | 160 | this.updated = ""; |
| 160 | this.uuid = ""; | 161 | this.uuid = ""; |
| 161 | // this.endDate = new Date(); | 162 | // this.endDate = new Date(); |
| 163 | + this.couponsetType = ""; | ||
| 164 | + this.img_preview = ""; | ||
| 165 | + this.innerText = ""; | ||
| 162 | } | 166 | } |
| 163 | 167 | ||
| 164 | /** | 168 | /** |
| ... | @@ -232,6 +236,9 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -232,6 +236,9 @@ public class Couponset implements Parcelable, Serializable { |
| 232 | this.category = json.optString(CATEGORY); | 236 | this.category = json.optString(CATEGORY); |
| 233 | this.terms = json.optString(TERMS); | 237 | this.terms = json.optString(TERMS); |
| 234 | this.discount_type = json.isNull(DISCOUNT_TYPE) ? "" : json.optString(DISCOUNT_TYPE); | 238 | this.discount_type = json.isNull(DISCOUNT_TYPE) ? "" : json.optString(DISCOUNT_TYPE); |
| 239 | + this.couponsetType = json.optString("couponset_type"); | ||
| 240 | + this.img_preview = json.optString(IMG_PREVIEW); | ||
| 241 | + this.innerText = json.optString(INNER_TEXT); | ||
| 235 | // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); | 242 | // SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); |
| 236 | // Date newDate = new Date(); | 243 | // Date newDate = new Date(); |
| 237 | // String tempRedeemDate = json.optString("end_date"); | 244 | // String tempRedeemDate = json.optString("end_date"); |
| ... | @@ -625,6 +632,14 @@ public class Couponset implements Parcelable, Serializable { | ... | @@ -625,6 +632,14 @@ public class Couponset implements Parcelable, Serializable { |
| 625 | this.final_price = final_price; | 632 | this.final_price = final_price; |
| 626 | } | 633 | } |
| 627 | 634 | ||
| 635 | + public String getCouponsetType() { | ||
| 636 | + return couponsetType; | ||
| 637 | + } | ||
| 638 | + | ||
| 639 | + public void setCouponsetType(String couponsetType) { | ||
| 640 | + this.couponsetType = couponsetType; | ||
| 641 | + } | ||
| 642 | + | ||
| 628 | @Override | 643 | @Override |
| 629 | public int describeContents() { | 644 | public int describeContents() { |
| 630 | return 0; | 645 | return 0; | ... | ... |
| ... | @@ -191,6 +191,9 @@ public class Merchant implements Parcelable, Serializable, ClusterItem { | ... | @@ -191,6 +191,9 @@ public class Merchant implements Parcelable, Serializable, ClusterItem { |
| 191 | this.region = ""; | 191 | this.region = ""; |
| 192 | this.telephone = ""; | 192 | this.telephone = ""; |
| 193 | this.merchant_metadata = new JSONObject(); | 193 | this.merchant_metadata = new JSONObject(); |
| 194 | + this.admin_name = ""; | ||
| 195 | + this.img_preview = ""; | ||
| 196 | + this.website = ""; | ||
| 194 | } | 197 | } |
| 195 | 198 | ||
| 196 | /** | 199 | /** |
| ... | @@ -267,6 +270,9 @@ public class Merchant implements Parcelable, Serializable, ClusterItem { | ... | @@ -267,6 +270,9 @@ public class Merchant implements Parcelable, Serializable, ClusterItem { |
| 267 | this.region = json.optString(REGION); | 270 | this.region = json.optString(REGION); |
| 268 | this.telephone = json.isNull(TELEPHONE) ? "" : json.optString(TELEPHONE); | 271 | this.telephone = json.isNull(TELEPHONE) ? "" : json.optString(TELEPHONE); |
| 269 | this.merchant_metadata = json.optJSONObject(MERCHANT_METADATA); | 272 | this.merchant_metadata = json.optJSONObject(MERCHANT_METADATA); |
| 273 | + this.admin_name = json.optString(ADMIN_NAME); | ||
| 274 | + this.img_preview = json.optString(IMG_PREVIEW); | ||
| 275 | + this.website = json.optString(WEBSITE); | ||
| 270 | 276 | ||
| 271 | // this.id = json.optString(ID); | 277 | // this.id = json.optString(ID); |
| 272 | // this.store_id = json.optString(STORE_ID); | 278 | // this.store_id = json.optString(STORE_ID); | ... | ... |
| ... | @@ -4352,11 +4352,12 @@ public class WarplyManager { | ... | @@ -4352,11 +4352,12 @@ public class WarplyManager { |
| 4352 | executorCoupons.submit(() -> { | 4352 | executorCoupons.submit(() -> { |
| 4353 | for (int i = 0; i < finalJCouponsBody.length(); ++i) { | 4353 | for (int i = 0; i < finalJCouponsBody.length(); ++i) { |
| 4354 | Coupon tempCoupon = new Coupon(finalJCouponsBody.optJSONObject(i), true); | 4354 | Coupon tempCoupon = new Coupon(finalJCouponsBody.optJSONObject(i), true); |
| 4355 | + if (TextUtils.isEmpty(tempCoupon.getCouponsetDetails().getCouponsetType()) || !tempCoupon.getCouponsetDetails().getCouponsetType().equals("supermarket")) | ||
| 4355 | mCouponsList.add(tempCoupon); | 4356 | mCouponsList.add(tempCoupon); |
| 4356 | 4357 | ||
| 4357 | if (tempCoupon.getStatus() == 0) { | 4358 | if (tempCoupon.getStatus() == 0) { |
| 4358 | mCouponRedeemedList.add(tempCoupon); | 4359 | mCouponRedeemedList.add(tempCoupon); |
| 4359 | - } else if (tempCoupon.getStatus() == 1) { | 4360 | + } else if (tempCoupon.getStatus() == 1 && (TextUtils.isEmpty(tempCoupon.getCouponsetDetails().getCouponsetType()) || !tempCoupon.getCouponsetDetails().getCouponsetType().equals("supermarket"))) { |
| 4360 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); | 4361 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); |
| 4361 | Date newDate = new Date(); | 4362 | Date newDate = new Date(); |
| 4362 | try { | 4363 | try { | ... | ... |
| ... | @@ -21,7 +21,6 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy; | ... | @@ -21,7 +21,6 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy; |
| 21 | import java.text.ParseException; | 21 | import java.text.ParseException; |
| 22 | import java.text.SimpleDateFormat; | 22 | import java.text.SimpleDateFormat; |
| 23 | import java.util.Date; | 23 | import java.util.Date; |
| 24 | -import java.util.Locale; | ||
| 25 | import java.util.concurrent.TimeUnit; | 24 | import java.util.concurrent.TimeUnit; |
| 26 | 25 | ||
| 27 | import io.reactivex.Observable; | 26 | import io.reactivex.Observable; |
| ... | @@ -117,6 +116,15 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte | ... | @@ -117,6 +116,15 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte |
| 117 | holder.ivCouponBackground.setColorFilter(ContextCompat.getColor(mContext, R.color.grey_light3), android.graphics.PorterDuff.Mode.MULTIPLY); | 116 | holder.ivCouponBackground.setColorFilter(ContextCompat.getColor(mContext, R.color.grey_light3), android.graphics.PorterDuff.Mode.MULTIPLY); |
| 118 | if (couponItem != null) { | 117 | if (couponItem != null) { |
| 119 | if (mIsCustom) { | 118 | if (mIsCustom) { |
| 119 | + if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) { | ||
| 120 | + for (Merchant mer : WarplyManagerHelper.getMerchantList()) { | ||
| 121 | + if (mer.getUuid().equals(couponItem.getMerchantUuid())) { | ||
| 122 | + merchant = mer; | ||
| 123 | + break; | ||
| 124 | + } | ||
| 125 | + } | ||
| 126 | + } | ||
| 127 | + | ||
| 120 | if (couponItem.getStatus() == 1) { | 128 | if (couponItem.getStatus() == 1) { |
| 121 | holder.ivCouponLogo.setAlpha(1.0f); | 129 | holder.ivCouponLogo.setAlpha(1.0f); |
| 122 | holder.tvCouponTitle.setAlpha(1.0f); | 130 | holder.tvCouponTitle.setAlpha(1.0f); |
| ... | @@ -130,15 +138,7 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte | ... | @@ -130,15 +138,7 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte |
| 130 | holder.tvCouponDescription.setAlpha(0.29f); | 138 | holder.tvCouponDescription.setAlpha(0.29f); |
| 131 | holder.clCustomLayout.setBackgroundResource(R.drawable.ic_coupon_background_new2); | 139 | holder.clCustomLayout.setBackgroundResource(R.drawable.ic_coupon_background_new2); |
| 132 | } | 140 | } |
| 133 | - if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) { | 141 | + |
| 134 | - for (Merchant mer : WarplyManagerHelper.getMerchantList()) { | ||
| 135 | - if (mer.getUuid().equals(couponItem.getMerchantUuid())) { | ||
| 136 | - merchant = mer; | ||
| 137 | - break; | ||
| 138 | - } | ||
| 139 | - } | ||
| 140 | - } | ||
| 141 | - if (merchant == null) { | ||
| 142 | if (!TextUtils.isEmpty(couponItem.getImage())) { | 142 | if (!TextUtils.isEmpty(couponItem.getImage())) { |
| 143 | Glide.with(mContext) | 143 | Glide.with(mContext) |
| 144 | // .setDefaultRequestOptions( | 144 | // .setDefaultRequestOptions( |
| ... | @@ -153,34 +153,14 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte | ... | @@ -153,34 +153,14 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte |
| 153 | .load(R.drawable.ic_cosmote_logo_horizontal_grey) | 153 | .load(R.drawable.ic_cosmote_logo_horizontal_grey) |
| 154 | .into(holder.ivCouponLogo); | 154 | .into(holder.ivCouponLogo); |
| 155 | } | 155 | } |
| 156 | - holder.tvCouponTitle.setText(couponItem.getName()); | 156 | + |
| 157 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | 157 | + holder.tvCouponTitle.setText(!TextUtils.isEmpty(merchant.getAdminName()) ? merchant.getAdminName() : couponItem.getName()); |
| 158 | - holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getDescription().equals("null") || TextUtils.isEmpty(couponItem.getDescription()) ? "" : couponItem.getDescription(), Html.FROM_HTML_MODE_COMPACT)); | ||
| 159 | - } else { | ||
| 160 | - holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getDescription().equals("null") || TextUtils.isEmpty(couponItem.getDescription()) ? "" : couponItem.getDescription())); | ||
| 161 | - } | ||
| 162 | - } else { | ||
| 163 | - if (!TextUtils.isEmpty(merchant.getImgPreview())) { | ||
| 164 | - Glide.with(mContext) | ||
| 165 | -// .setDefaultRequestOptions( | ||
| 166 | -// RequestOptions | ||
| 167 | -// .placeholderOf(R.drawable.ic_default_contact_photo) | ||
| 168 | -// .error(R.drawable.ic_default_contact_photo)) | ||
| 169 | - .load(merchant.getImgPreview()) | ||
| 170 | - .diskCacheStrategy(DiskCacheStrategy.DATA) | ||
| 171 | - .into(holder.ivCouponLogo); | ||
| 172 | - } else { | ||
| 173 | - Glide.with(mContext) | ||
| 174 | - .load(R.drawable.ic_cosmote_logo_horizontal_grey) | ||
| 175 | - .into(holder.ivCouponLogo); | ||
| 176 | - } | ||
| 177 | - holder.tvCouponTitle.setText(merchant.getAdminName()); | ||
| 178 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | 158 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| 179 | holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText().equals("null") || TextUtils.isEmpty(couponItem.getInnerText()) ? "" : couponItem.getInnerText(), Html.FROM_HTML_MODE_COMPACT)); | 159 | holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText().equals("null") || TextUtils.isEmpty(couponItem.getInnerText()) ? "" : couponItem.getInnerText(), Html.FROM_HTML_MODE_COMPACT)); |
| 180 | } else { | 160 | } else { |
| 181 | holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText().equals("null") || TextUtils.isEmpty(couponItem.getInnerText()) ? "" : couponItem.getInnerText())); | 161 | holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText().equals("null") || TextUtils.isEmpty(couponItem.getInnerText()) ? "" : couponItem.getInnerText())); |
| 182 | } | 162 | } |
| 183 | - } | 163 | + |
| 184 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); | 164 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); |
| 185 | Date newDate = new Date(); | 165 | Date newDate = new Date(); |
| 186 | try { | 166 | try { |
| ... | @@ -212,6 +192,7 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte | ... | @@ -212,6 +192,7 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte |
| 212 | holder.tvCouponDateExpired.setText(mContext.getString(R.string.cos_market_coupon_expired)); | 192 | holder.tvCouponDateExpired.setText(mContext.getString(R.string.cos_market_coupon_expired)); |
| 213 | } | 193 | } |
| 214 | } | 194 | } |
| 195 | + | ||
| 215 | if (TextUtils.isEmpty(couponItem.getDiscount_type())) { | 196 | if (TextUtils.isEmpty(couponItem.getDiscount_type())) { |
| 216 | holder.tvCouponValue.setText(couponItem.getDiscount().replace(".", ",") + mContext.getResources().getString(R.string.euro)); | 197 | holder.tvCouponValue.setText(couponItem.getDiscount().replace(".", ",") + mContext.getResources().getString(R.string.euro)); |
| 217 | } else { | 198 | } else { |
| ... | @@ -228,45 +209,23 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte | ... | @@ -228,45 +209,23 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte |
| 228 | holder.itemView.setOnClickListener(v -> onClickSubject.onNext(couponItem)); | 209 | holder.itemView.setOnClickListener(v -> onClickSubject.onNext(couponItem)); |
| 229 | return; | 210 | return; |
| 230 | } | 211 | } |
| 231 | - if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) { | 212 | + |
| 232 | - for (Merchant mer : WarplyManagerHelper.getMerchantList()) { | 213 | + if (!TextUtils.isEmpty(couponItem.getMerchantDetails().getImgPreview())) { |
| 233 | - if (mer.getUuid().equals(couponItem.getMerchantUuid())) { | ||
| 234 | - merchant = mer; | ||
| 235 | - break; | ||
| 236 | - } | ||
| 237 | - } | ||
| 238 | - } | ||
| 239 | - if (merchant == null) { | ||
| 240 | - if (!TextUtils.isEmpty(couponItem.getImage())) { | ||
| 241 | Glide.with(mContext) | 214 | Glide.with(mContext) |
| 242 | // .setDefaultRequestOptions( | 215 | // .setDefaultRequestOptions( |
| 243 | // RequestOptions | 216 | // RequestOptions |
| 244 | // .placeholderOf(R.drawable.ic_default_contact_photo) | 217 | // .placeholderOf(R.drawable.ic_default_contact_photo) |
| 245 | // .error(R.drawable.ic_default_contact_photo)) | 218 | // .error(R.drawable.ic_default_contact_photo)) |
| 246 | - .load(couponItem.getImage()) | 219 | + .load(couponItem.getMerchantDetails().getImgPreview()) |
| 247 | .diskCacheStrategy(DiskCacheStrategy.DATA) | 220 | .diskCacheStrategy(DiskCacheStrategy.DATA) |
| 248 | .into(holder.ivCouponLogo); | 221 | .into(holder.ivCouponLogo); |
| 249 | - } else { | 222 | + } else if (!TextUtils.isEmpty(couponItem.getCouponsetDetails().getImgPreview())) { |
| 250 | - Glide.with(mContext) | ||
| 251 | - .load(R.drawable.ic_cosmote_logo_horizontal_grey) | ||
| 252 | - .into(holder.ivCouponLogo); | ||
| 253 | - } | ||
| 254 | - holder.tvCouponTitle.setText(couponItem.getName()); | ||
| 255 | - if (!mIsPast) { | ||
| 256 | - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | ||
| 257 | - holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText(), Html.FROM_HTML_MODE_COMPACT)); | ||
| 258 | - } else { | ||
| 259 | - holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText())); | ||
| 260 | - } | ||
| 261 | - } | ||
| 262 | - } else { | ||
| 263 | - if (!TextUtils.isEmpty(merchant.getImgPreview())) { | ||
| 264 | Glide.with(mContext) | 223 | Glide.with(mContext) |
| 265 | // .setDefaultRequestOptions( | 224 | // .setDefaultRequestOptions( |
| 266 | // RequestOptions | 225 | // RequestOptions |
| 267 | // .placeholderOf(R.drawable.ic_default_contact_photo) | 226 | // .placeholderOf(R.drawable.ic_default_contact_photo) |
| 268 | // .error(R.drawable.ic_default_contact_photo)) | 227 | // .error(R.drawable.ic_default_contact_photo)) |
| 269 | - .load(merchant.getImgPreview()) | 228 | + .load(couponItem.getCouponsetDetails().getImgPreview()) |
| 270 | .diskCacheStrategy(DiskCacheStrategy.DATA) | 229 | .diskCacheStrategy(DiskCacheStrategy.DATA) |
| 271 | .into(holder.ivCouponLogo); | 230 | .into(holder.ivCouponLogo); |
| 272 | } else { | 231 | } else { |
| ... | @@ -274,15 +233,20 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte | ... | @@ -274,15 +233,20 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte |
| 274 | .load(R.drawable.ic_cosmote_logo_horizontal_grey) | 233 | .load(R.drawable.ic_cosmote_logo_horizontal_grey) |
| 275 | .into(holder.ivCouponLogo); | 234 | .into(holder.ivCouponLogo); |
| 276 | } | 235 | } |
| 277 | - holder.tvCouponTitle.setText(merchant.getAdminName()); | 236 | + |
| 237 | + if (!TextUtils.isEmpty(couponItem.getMerchantDetails().getAdminName())) | ||
| 238 | + holder.tvCouponTitle.setText(couponItem.getMerchantDetails().getAdminName()); | ||
| 239 | + else | ||
| 240 | + holder.tvCouponTitle.setText(couponItem.getCouponsetDetails().getName()); | ||
| 241 | + | ||
| 278 | if (!mIsPast) { | 242 | if (!mIsPast) { |
| 279 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { | 243 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { |
| 280 | - holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText(), Html.FROM_HTML_MODE_COMPACT)); | 244 | + holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getCouponsetDetails().getInnerText(), Html.FROM_HTML_MODE_COMPACT)); |
| 281 | } else { | 245 | } else { |
| 282 | - holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText())); | 246 | + holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getCouponsetDetails().getInnerText())); |
| 283 | - } | ||
| 284 | } | 247 | } |
| 285 | } | 248 | } |
| 249 | + | ||
| 286 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); | 250 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm"); |
| 287 | Date newDate = new Date(); | 251 | Date newDate = new Date(); |
| 288 | try { | 252 | try { |
| ... | @@ -295,17 +259,18 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte | ... | @@ -295,17 +259,18 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte |
| 295 | holder.tvCouponDate.setText(String.format(mContext.getString(R.string.cos_coupon_expired_date), simpleDateFormat.format(newDate != null ? newDate : ""))); | 259 | holder.tvCouponDate.setText(String.format(mContext.getString(R.string.cos_coupon_expired_date), simpleDateFormat.format(newDate != null ? newDate : ""))); |
| 296 | else | 260 | else |
| 297 | holder.tvCouponDate.setText(String.format(mContext.getString(R.string.cos_coupon_date), simpleDateFormat.format(newDate != null ? newDate : ""))); | 261 | holder.tvCouponDate.setText(String.format(mContext.getString(R.string.cos_coupon_date), simpleDateFormat.format(newDate != null ? newDate : ""))); |
| 298 | - if (TextUtils.isEmpty(couponItem.getDiscount_type())) { | 262 | + |
| 299 | - holder.tvCouponValue.setText(couponItem.getDiscount() + mContext.getResources().getString(R.string.euro)); | 263 | + if (TextUtils.isEmpty(couponItem.getCouponsetDetails().getDiscount_type())) { |
| 264 | + holder.tvCouponValue.setText(couponItem.getCouponsetDetails().getDiscount() + mContext.getResources().getString(R.string.euro)); | ||
| 300 | } else { | 265 | } else { |
| 301 | - if (couponItem.getDiscount_type().equals("value")) { | 266 | + if (couponItem.getCouponsetDetails().getDiscount_type().equals("value")) { |
| 302 | - holder.tvCouponValue.setText(couponItem.getDiscount() + mContext.getResources().getString(R.string.euro)); | 267 | + holder.tvCouponValue.setText(couponItem.getCouponsetDetails().getDiscount() + mContext.getResources().getString(R.string.euro)); |
| 303 | - } else if (couponItem.getDiscount_type().equals("percentage")) { | 268 | + } else if (couponItem.getCouponsetDetails().getDiscount_type().equals("percentage")) { |
| 304 | - holder.tvCouponValue.setText(couponItem.getDiscount() + mContext.getResources().getString(R.string.percentage)); | 269 | + holder.tvCouponValue.setText(couponItem.getCouponsetDetails().getDiscount() + mContext.getResources().getString(R.string.percentage)); |
| 305 | - } else if (couponItem.getDiscount_type().equals("plus_one")) { | 270 | + } else if (couponItem.getCouponsetDetails().getDiscount_type().equals("plus_one")) { |
| 306 | - holder.tvCouponValue.setText(couponItem.getDiscount() + mContext.getResources().getString(R.string.plus_one)); | 271 | + holder.tvCouponValue.setText(couponItem.getCouponsetDetails().getDiscount() + mContext.getResources().getString(R.string.plus_one)); |
| 307 | } else { | 272 | } else { |
| 308 | - holder.tvCouponValue.setText(couponItem.getDiscount() + mContext.getResources().getString(R.string.euro)); | 273 | + holder.tvCouponValue.setText(couponItem.getCouponsetDetails().getDiscount() + mContext.getResources().getString(R.string.euro)); |
| 309 | } | 274 | } |
| 310 | } | 275 | } |
| 311 | holder.itemView.setOnClickListener(v -> onClickSubject.onNext(couponItem)); | 276 | holder.itemView.setOnClickListener(v -> onClickSubject.onNext(couponItem)); | ... | ... |
-
Please register or login to post a comment