Panagiotis Triantafyllou

new coupons request part3, fixes in active coupons, sm coupons, map

......@@ -116,7 +116,7 @@ public class ActiveCouponsActivity extends Activity implements View.OnClickListe
mCouponsPressed = true;
WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Coupon").concat(":").concat(coupon.getName()));
Intent intent = new Intent(ActiveCouponsActivity.this, CouponInfoActivity.class);
intent.putExtra("coupon", (Serializable) coupon);
intent.putExtra("coupon", coupon.getCoupon());
startActivity(intent);
}
})
......
......@@ -93,7 +93,7 @@ public class ActiveGiftsActivity extends Activity implements View.OnClickListene
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())));
} else if (dataItem.getDataType() == 2) {
Intent intent = new Intent(ActiveGiftsActivity.this, CouponInfoActivity.class);
intent.putExtra("coupon", (Serializable) dataItem.getCoupon());
intent.putExtra("coupon", dataItem.getCoupon().getCoupon());
startActivity(intent);
}
})
......
......@@ -35,8 +35,7 @@ import java.util.Date;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.Coupon;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.Merchant;
import ly.warp.sdk.io.models.UnifiedCoupon;
import ly.warp.sdk.services.EventCouponsService;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
......@@ -57,10 +56,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
mTvTermsValue, mTvFullBarcode, mTvDescription, mTvCouponCodeTitle;
private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms, mLlWebsite;
private Coupon mCoupon;
private Couponset mCouponset;
private boolean mIsBarcodeShown = false, mIsTermsShown = false, mIsFromWallet = false,
mShopsPressed = false, mGiftPressed = false, mEshopPressed = false, mIsUnified = false;
private Merchant mMerchant;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -71,10 +68,32 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_coupon_info);
mCoupon = (Coupon) getIntent().getSerializableExtra("coupon");
String couponCode = getIntent().getStringExtra("coupon");
mIsFromWallet = getIntent().getBooleanExtra("isFromWallet", false);
mIsUnified = getIntent().getBooleanExtra("isUnified", false);
if (mIsUnified) {
String couponUnifiedCode = getIntent().getStringExtra("unifiedCoupon");
for (UnifiedCoupon couponItem : WarplyManagerHelper.getMarketCoupons()) {
if (couponItem.getBarcode().equals(couponUnifiedCode)) {
for (Coupon cpn : couponItem.getCoupons()) {
if (cpn.getCoupon().equals(couponCode)) {
mCoupon = cpn;
break;
}
}
break;
}
}
} else {
for (Coupon cpn : WarplyManagerHelper.getCouponList()) {
if (cpn.getCoupon().equals(couponCode)) {
mCoupon = cpn;
break;
}
}
}
mIvBack = findViewById(R.id.iv_coupon_info_back);
mTvTerms = findViewById(R.id.tv_terms);
mLlGiftIt = findViewById(R.id.ll_gift_it);
......@@ -147,12 +166,12 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(CouponInfoActivity.this) == ConnectionResult.SUCCESS) {
Intent intent = new Intent(CouponInfoActivity.this, ShopsActivity.class);
intent.putExtra("couponset", (Serializable) mCouponset);
intent.putExtra("coupon", mCoupon.getCoupon());
startActivity(intent);
return;
} else {
Intent intent = new Intent(CouponInfoActivity.this, ShopsHuaweiActivity.class);
intent.putExtra("couponset", (Serializable) mCouponset);
intent.putExtra("coupon", mCoupon.getCoupon());
startActivity(intent);
return;
}
......@@ -163,9 +182,9 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
mEshopPressed = true;
WarplyAnalyticsManager.logTrackersEvent(this, "click", "SeeShopWebsite");
if (!TextUtils.isEmpty(mMerchant.getWebsite())) {
if (mCoupon != null && mCoupon.getMerchantDetails() != null && !TextUtils.isEmpty(mCoupon.getMerchantDetails().getWebsite())) {
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(mMerchant.getWebsite()));
intent.setData(Uri.parse(mCoupon.getMerchantDetails().getWebsite()));
startActivity(intent);
}
}
......@@ -227,82 +246,38 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
mTvCouponTitle.setText(HtmlCompat.fromHtml(mCoupon.getName(), HtmlCompat.FROM_HTML_MODE_COMPACT));
} else {
mTvCouponCode.setText(mCoupon.getCoupon());
mTvCouponTitle.setText(mCoupon.getName());
mTvCouponTitle.setText(mCoupon.getCouponsetDetails().getName());
}
// mTvCouponSubtitle.setText(mCoupon.getDescription());
if (WarplyManagerHelper.getCouponsets() != null && WarplyManagerHelper.getCouponsets().size() > 0) {
for (Couponset couponset : WarplyManagerHelper.getCouponsets()) {
if (couponset.getUuid().equals(mCoupon.getCouponsetUuid())) {
mCouponset = couponset;
break;
}
}
}
if (mCouponset != null) {
if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) {
for (Merchant merchant : WarplyManagerHelper.getMerchantList()) {
if (merchant.getUuid().equals(mCouponset.getMerchantUuid())) {
mMerchant = merchant;
break;
}
}
if (mMerchant != null && !TextUtils.isEmpty(mMerchant.getBody()) && !mMerchant.getBody().equals("null")) {
mTvDescription.setText(HtmlCompat.fromHtml(mMerchant.getBody(), HtmlCompat.FROM_HTML_MODE_COMPACT));
mTvDescription.setMovementMethod(LinkMovementMethod.getInstance());
} else {
mTvDescription.setVisibility(View.GONE);
}
// if (mMerchant != null) {
// if (mMerchant.getExtraFields() != null && mMerchant.getExtraFields().has("show_map") && (mMerchant.getExtraFields().optBoolean("show_map") || mMerchant.getExtraFields().optString("show_map").equals("true"))) {
mLlShops.setVisibility(View.VISIBLE);
// }
// if (mMerchant.getExtraFields() != null && mMerchant.getExtraFields().has("eshop") && (mMerchant.getExtraFields().optBoolean("eshop") || mMerchant.getExtraFields().optString("eshop").equals("true"))) {
// mLlWebsite.setVisibility(View.VISIBLE);
// }
// }
}
mTvCouponSubtitle.setText(mCouponset.getShortDescription());
mTvTermsValue.setText(HtmlCompat.fromHtml(mCouponset.getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT));
mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance());
} else {
if (mCoupon != null) {
if (mIsFromWallet) {
if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) {
for (Merchant merchant : WarplyManagerHelper.getMerchantList()) {
if (merchant.getUuid().equals(mCoupon.getMerchantUuid())) {
mMerchant = merchant;
break;
}
}
// if (mMerchant != null && !TextUtils.isEmpty(mMerchant.getBody()) && !mMerchant.getBody().equals("null")) {
// mTvDescription.setText(HtmlCompat.fromHtml(mMerchant.getBody(), HtmlCompat.FROM_HTML_MODE_COMPACT));
// mTvDescription.setMovementMethod(LinkMovementMethod.getInstance());
// } else {
if (mCoupon.getMerchantDetails() != null) {
mTvDescription.setVisibility(View.GONE);
// }
// if (mMerchant != null) {
// if (mMerchant.getExtraFields() != null && mMerchant.getExtraFields().has("show_map") && (mMerchant.getExtraFields().optBoolean("show_map") || mMerchant.getExtraFields().optString("show_map").equals("true"))) {
mLlShops.setVisibility(View.VISIBLE);
// }
// if (mMerchant.getExtraFields() != null && mMerchant.getExtraFields().has("eshop") && (mMerchant.getExtraFields().optBoolean("eshop") || mMerchant.getExtraFields().optString("eshop").equals("true"))) {
// mLlWebsite.setVisibility(View.VISIBLE);
// }
// }
}
if(mIsUnified) {
if (mIsUnified) {
mTvCouponSubtitle.setText(HtmlCompat.fromHtml(mCoupon.getDescription(), HtmlCompat.FROM_HTML_MODE_COMPACT));
} else {
mTvCouponSubtitle.setText(mCoupon.getShort_description());
mTvCouponSubtitle.setText(mCoupon.getCouponsetDetails().getShortDescription());
}
mTvTermsValue.setText(HtmlCompat.fromHtml(mCoupon.getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT));
mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance());
} else {
if (mCoupon.getMerchantDetails() != null) {
if (mCoupon.getMerchantDetails() != null && !TextUtils.isEmpty(mCoupon.getMerchantDetails().getBody()) && !mCoupon.getMerchantDetails().getBody().equals("null")) {
mTvDescription.setText(HtmlCompat.fromHtml(mCoupon.getMerchantDetails().getBody(), HtmlCompat.FROM_HTML_MODE_COMPACT));
mTvDescription.setMovementMethod(LinkMovementMethod.getInstance());
} else {
mTvDescription.setVisibility(View.GONE);
}
mLlShops.setVisibility(View.VISIBLE);
}
mTvCouponSubtitle.setText(mCoupon.getCouponsetDetails().getShortDescription());
mTvTermsValue.setText(HtmlCompat.fromHtml(mCoupon.getCouponsetDetails().getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT));
mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance());
}
}
......@@ -316,28 +291,43 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy");
mTvCouponDate.setText(String.format(getResources().getString(R.string.cos_mycoupon_date), simpleDateFormat.format(newDate != null ? newDate : "")));
if (!TextUtils.isEmpty(mCoupon.getImage())) {
if (mIsUnified) {
mIvCouponPhoto.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
if (mIsUnified) {
mIvCouponPhoto.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
if (!TextUtils.isEmpty(mCoupon.getImage())) {
Glide.with(this)
// .setDefaultRequestOptions(
// RequestOptions
// .placeholderOf(R.drawable.ic_default_contact_photo)
// .error(R.drawable.ic_default_contact_photo))
.load(mCoupon.getImage())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(mIvCouponPhoto);
} else {
mIvCouponPhoto.setScaleType(ImageView.ScaleType.CENTER_CROP);
Glide.with(this)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(mIvCouponPhoto);
}
} else {
mIvCouponPhoto.setScaleType(ImageView.ScaleType.CENTER_CROP);
Glide.with(this)
if (!TextUtils.isEmpty(mCoupon.getCouponsetDetails().getImgPreview())) {
Glide.with(this)
// .setDefaultRequestOptions(
// RequestOptions
// .placeholderOf(R.drawable.ic_default_contact_photo)
// .error(R.drawable.ic_default_contact_photo))
.load(mCoupon.getImage())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(mIvCouponPhoto);
} else {
Glide.with(this)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(mIvCouponPhoto);
.load(mCoupon.getCouponsetDetails().getImgPreview())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(mIvCouponPhoto);
} else {
Glide.with(this)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(mIvCouponPhoto);
}
}
mIvBack.setOnClickListener(this);
// mTvTerms.setPaintFlags(mTvTerms.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
mLlGiftIt.setOnClickListener(this);
mLlShops.setOnClickListener(this);
mLlWebsite.setOnClickListener(this);
......
......@@ -39,7 +39,7 @@ import java.util.ArrayList;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;
import ly.warp.sdk.R;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.Coupon;
import ly.warp.sdk.io.models.Merchant;
import ly.warp.sdk.io.models.MerchantList;
import ly.warp.sdk.utils.WarplyManagerHelper;
......@@ -64,7 +64,7 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
// ===========================================================
private ImageView mIvBack;
private Couponset mCouponset;
private Coupon mCoupon;
private GoogleMap mMap;
private ClusterManager<Merchant> mClusterManager;
private SupportMapFragment mMapView;
......@@ -82,13 +82,12 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shops);
mCouponset = (Couponset) getIntent().getSerializableExtra("couponset");
if (mCouponset != null) {
for (Merchant merchant : WarplyManagerHelper.getMerchantList()) {
if (merchant.getUuid().equals(mCouponset.getMerchantUuid())) {
mMerchant = merchant;
break;
}
String couponCode = getIntent().getStringExtra("coupon");
for (Coupon cpn : WarplyManagerHelper.getCouponList()) {
if (cpn.getCoupon().equals(couponCode)) {
mCoupon = cpn;
mMerchant = cpn.getMerchantDetails();
break;
}
}
......@@ -178,9 +177,9 @@ public class ShopsActivity extends FragmentActivity implements View.OnClickListe
//// mMap.setOnMarkerClickListener(/*mClusterManager*/this);
// }
if (mCouponset != null) {
if (mCoupon != null) {
ArrayList<String> uuids = new ArrayList<>();
uuids.add(mCouponset.getMerchantUuid());
uuids.add(mCoupon.getMerchantUuid());
WarplyManager.getMerchantsMultilingual(true, uuids, mMerchantsCallback);
} else {
ArrayList<String> catuuids = new ArrayList<>();
......
......@@ -38,7 +38,7 @@ import java.util.ArrayList;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;
import ly.warp.sdk.R;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.Coupon;
import ly.warp.sdk.io.models.Merchant;
import ly.warp.sdk.io.models.MerchantList;
import ly.warp.sdk.utils.WarplyManagerHelper;
......@@ -62,7 +62,7 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic
// ===========================================================
private ImageView mIvBack;
private Couponset mCouponset;
private Coupon mCoupon;
private HuaweiMap mMap;
// private ClusterManager<Merchant> mClusterManager;
private SupportMapFragment mSupportMapFragment;
......@@ -81,13 +81,12 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic
MapsInitializer.initialize(this);
setContentView(R.layout.activity_shops_huawei);
mCouponset = (Couponset) getIntent().getSerializableExtra("couponset");
if (mCouponset != null) {
for (Merchant merchant : WarplyManagerHelper.getMerchantList()) {
if (merchant.getUuid().equals(mCouponset.getMerchantUuid())) {
mMerchant = merchant;
break;
}
String couponCode = getIntent().getStringExtra("coupon");
for (Coupon cpn : WarplyManagerHelper.getCouponList()) {
if (cpn.getCoupon().equals(couponCode)) {
mCoupon = cpn;
mMerchant = cpn.getMerchantDetails();
break;
}
}
......@@ -179,9 +178,9 @@ public class ShopsHuaweiActivity extends FragmentActivity implements View.OnClic
//// mMap.setOnMarkerClickListener(/*mClusterManager*/this);
// }
//
if (mCouponset != null) {
if (mCoupon != null) {
ArrayList<String> uuids = new ArrayList<>();
uuids.add(mCouponset.getMerchantUuid());
uuids.add(mCoupon.getMerchantUuid());
WarplyManager.getMerchantsMultilingual(true, uuids, mMerchantsCallback);
} else {
ArrayList<String> catuuids = new ArrayList<>();
......
......@@ -235,9 +235,10 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
mCouponPressed = true;
WarplyAnalyticsManager.logTrackersEvent(this, "click", ("MarketCoupon").concat(":").concat(coupon.getName()));
Intent intent = new Intent(UnifiedCouponInfoActivity.this, CouponInfoActivity.class);
intent.putExtra("coupon", (Serializable) coupon);
intent.putExtra("coupon", coupon.getCoupon());
intent.putExtra("isFromWallet", true);
intent.putExtra("isUnified", true);
intent.putExtra("unifiedCoupon", mCoupon.getBarcode());
startActivity(intent);
}
})
......
......@@ -112,6 +112,7 @@ public class Couponset implements Parcelable, Serializable {
private String discount_type = "";
private double final_price = 0.0d;
private Date endDate = new Date();
private String couponsetType = "";
public Couponset() {
this.uuid = "";
......@@ -159,6 +160,9 @@ public class Couponset implements Parcelable, Serializable {
this.updated = "";
this.uuid = "";
// this.endDate = new Date();
this.couponsetType = "";
this.img_preview = "";
this.innerText = "";
}
/**
......@@ -232,6 +236,9 @@ public class Couponset implements Parcelable, Serializable {
this.category = json.optString(CATEGORY);
this.terms = json.optString(TERMS);
this.discount_type = json.isNull(DISCOUNT_TYPE) ? "" : json.optString(DISCOUNT_TYPE);
this.couponsetType = json.optString("couponset_type");
this.img_preview = json.optString(IMG_PREVIEW);
this.innerText = json.optString(INNER_TEXT);
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
// Date newDate = new Date();
// String tempRedeemDate = json.optString("end_date");
......@@ -625,6 +632,14 @@ public class Couponset implements Parcelable, Serializable {
this.final_price = final_price;
}
public String getCouponsetType() {
return couponsetType;
}
public void setCouponsetType(String couponsetType) {
this.couponsetType = couponsetType;
}
@Override
public int describeContents() {
return 0;
......
......@@ -191,6 +191,9 @@ public class Merchant implements Parcelable, Serializable, ClusterItem {
this.region = "";
this.telephone = "";
this.merchant_metadata = new JSONObject();
this.admin_name = "";
this.img_preview = "";
this.website = "";
}
/**
......@@ -267,6 +270,9 @@ public class Merchant implements Parcelable, Serializable, ClusterItem {
this.region = json.optString(REGION);
this.telephone = json.isNull(TELEPHONE) ? "" : json.optString(TELEPHONE);
this.merchant_metadata = json.optJSONObject(MERCHANT_METADATA);
this.admin_name = json.optString(ADMIN_NAME);
this.img_preview = json.optString(IMG_PREVIEW);
this.website = json.optString(WEBSITE);
// this.id = json.optString(ID);
// this.store_id = json.optString(STORE_ID);
......
......@@ -4352,11 +4352,12 @@ public class WarplyManager {
executorCoupons.submit(() -> {
for (int i = 0; i < finalJCouponsBody.length(); ++i) {
Coupon tempCoupon = new Coupon(finalJCouponsBody.optJSONObject(i), true);
mCouponsList.add(tempCoupon);
if (TextUtils.isEmpty(tempCoupon.getCouponsetDetails().getCouponsetType()) || !tempCoupon.getCouponsetDetails().getCouponsetType().equals("supermarket"))
mCouponsList.add(tempCoupon);
if (tempCoupon.getStatus() == 0) {
mCouponRedeemedList.add(tempCoupon);
} else if (tempCoupon.getStatus() == 1) {
} else if (tempCoupon.getStatus() == 1 && (TextUtils.isEmpty(tempCoupon.getCouponsetDetails().getCouponsetType()) || !tempCoupon.getCouponsetDetails().getCouponsetType().equals("supermarket"))) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
Date newDate = new Date();
try {
......
......@@ -21,7 +21,6 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
......@@ -117,6 +116,15 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
holder.ivCouponBackground.setColorFilter(ContextCompat.getColor(mContext, R.color.grey_light3), android.graphics.PorterDuff.Mode.MULTIPLY);
if (couponItem != null) {
if (mIsCustom) {
if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) {
for (Merchant mer : WarplyManagerHelper.getMerchantList()) {
if (mer.getUuid().equals(couponItem.getMerchantUuid())) {
merchant = mer;
break;
}
}
}
if (couponItem.getStatus() == 1) {
holder.ivCouponLogo.setAlpha(1.0f);
holder.tvCouponTitle.setAlpha(1.0f);
......@@ -130,57 +138,29 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
holder.tvCouponDescription.setAlpha(0.29f);
holder.clCustomLayout.setBackgroundResource(R.drawable.ic_coupon_background_new2);
}
if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) {
for (Merchant mer : WarplyManagerHelper.getMerchantList()) {
if (mer.getUuid().equals(couponItem.getMerchantUuid())) {
merchant = mer;
break;
}
}
}
if (merchant == null) {
if (!TextUtils.isEmpty(couponItem.getImage())) {
Glide.with(mContext)
if (!TextUtils.isEmpty(couponItem.getImage())) {
Glide.with(mContext)
// .setDefaultRequestOptions(
// RequestOptions
// .placeholderOf(R.drawable.ic_default_contact_photo)
// .error(R.drawable.ic_default_contact_photo))
.load(couponItem.getImage())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(holder.ivCouponLogo);
} else {
Glide.with(mContext)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(holder.ivCouponLogo);
}
holder.tvCouponTitle.setText(couponItem.getName());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getDescription().equals("null") || TextUtils.isEmpty(couponItem.getDescription()) ? "" : couponItem.getDescription(), Html.FROM_HTML_MODE_COMPACT));
} else {
holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getDescription().equals("null") || TextUtils.isEmpty(couponItem.getDescription()) ? "" : couponItem.getDescription()));
}
.load(couponItem.getImage())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(holder.ivCouponLogo);
} else {
if (!TextUtils.isEmpty(merchant.getImgPreview())) {
Glide.with(mContext)
// .setDefaultRequestOptions(
// RequestOptions
// .placeholderOf(R.drawable.ic_default_contact_photo)
// .error(R.drawable.ic_default_contact_photo))
.load(merchant.getImgPreview())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(holder.ivCouponLogo);
} else {
Glide.with(mContext)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(holder.ivCouponLogo);
}
holder.tvCouponTitle.setText(merchant.getAdminName());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText().equals("null") || TextUtils.isEmpty(couponItem.getInnerText()) ? "" : couponItem.getInnerText(), Html.FROM_HTML_MODE_COMPACT));
} else {
holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText().equals("null") || TextUtils.isEmpty(couponItem.getInnerText()) ? "" : couponItem.getInnerText()));
}
Glide.with(mContext)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(holder.ivCouponLogo);
}
holder.tvCouponTitle.setText(!TextUtils.isEmpty(merchant.getAdminName()) ? merchant.getAdminName() : couponItem.getName());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText().equals("null") || TextUtils.isEmpty(couponItem.getInnerText()) ? "" : couponItem.getInnerText(), Html.FROM_HTML_MODE_COMPACT));
} else {
holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText().equals("null") || TextUtils.isEmpty(couponItem.getInnerText()) ? "" : couponItem.getInnerText()));
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
Date newDate = new Date();
try {
......@@ -212,6 +192,7 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
holder.tvCouponDateExpired.setText(mContext.getString(R.string.cos_market_coupon_expired));
}
}
if (TextUtils.isEmpty(couponItem.getDiscount_type())) {
holder.tvCouponValue.setText(couponItem.getDiscount().replace(".", ",") + mContext.getResources().getString(R.string.euro));
} else {
......@@ -228,61 +209,44 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
holder.itemView.setOnClickListener(v -> onClickSubject.onNext(couponItem));
return;
}
if (WarplyManagerHelper.getMerchantList() != null && WarplyManagerHelper.getMerchantList().size() > 0) {
for (Merchant mer : WarplyManagerHelper.getMerchantList()) {
if (mer.getUuid().equals(couponItem.getMerchantUuid())) {
merchant = mer;
break;
}
}
}
if (merchant == null) {
if (!TextUtils.isEmpty(couponItem.getImage())) {
Glide.with(mContext)
if (!TextUtils.isEmpty(couponItem.getMerchantDetails().getImgPreview())) {
Glide.with(mContext)
// .setDefaultRequestOptions(
// RequestOptions
// .placeholderOf(R.drawable.ic_default_contact_photo)
// .error(R.drawable.ic_default_contact_photo))
.load(couponItem.getImage())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(holder.ivCouponLogo);
} else {
Glide.with(mContext)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(holder.ivCouponLogo);
}
holder.tvCouponTitle.setText(couponItem.getName());
if (!mIsPast) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText(), Html.FROM_HTML_MODE_COMPACT));
} else {
holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText()));
}
}
} else {
if (!TextUtils.isEmpty(merchant.getImgPreview())) {
Glide.with(mContext)
.load(couponItem.getMerchantDetails().getImgPreview())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(holder.ivCouponLogo);
} else if (!TextUtils.isEmpty(couponItem.getCouponsetDetails().getImgPreview())) {
Glide.with(mContext)
// .setDefaultRequestOptions(
// RequestOptions
// .placeholderOf(R.drawable.ic_default_contact_photo)
// .error(R.drawable.ic_default_contact_photo))
.load(merchant.getImgPreview())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(holder.ivCouponLogo);
.load(couponItem.getCouponsetDetails().getImgPreview())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(holder.ivCouponLogo);
} else {
Glide.with(mContext)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(holder.ivCouponLogo);
}
if (!TextUtils.isEmpty(couponItem.getMerchantDetails().getAdminName()))
holder.tvCouponTitle.setText(couponItem.getMerchantDetails().getAdminName());
else
holder.tvCouponTitle.setText(couponItem.getCouponsetDetails().getName());
if (!mIsPast) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getCouponsetDetails().getInnerText(), Html.FROM_HTML_MODE_COMPACT));
} else {
Glide.with(mContext)
.load(R.drawable.ic_cosmote_logo_horizontal_grey)
.into(holder.ivCouponLogo);
}
holder.tvCouponTitle.setText(merchant.getAdminName());
if (!mIsPast) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText(), Html.FROM_HTML_MODE_COMPACT));
} else {
holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getInnerText()));
}
holder.tvCouponDescription.setText(Html.fromHtml(couponItem.getCouponsetDetails().getInnerText()));
}
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
Date newDate = new Date();
try {
......@@ -295,17 +259,18 @@ public class ActiveCouponAdapter extends RecyclerView.Adapter<ActiveCouponAdapte
holder.tvCouponDate.setText(String.format(mContext.getString(R.string.cos_coupon_expired_date), simpleDateFormat.format(newDate != null ? newDate : "")));
else
holder.tvCouponDate.setText(String.format(mContext.getString(R.string.cos_coupon_date), simpleDateFormat.format(newDate != null ? newDate : "")));
if (TextUtils.isEmpty(couponItem.getDiscount_type())) {
holder.tvCouponValue.setText(couponItem.getDiscount() + mContext.getResources().getString(R.string.euro));
if (TextUtils.isEmpty(couponItem.getCouponsetDetails().getDiscount_type())) {
holder.tvCouponValue.setText(couponItem.getCouponsetDetails().getDiscount() + mContext.getResources().getString(R.string.euro));
} else {
if (couponItem.getDiscount_type().equals("value")) {
holder.tvCouponValue.setText(couponItem.getDiscount() + mContext.getResources().getString(R.string.euro));
} else if (couponItem.getDiscount_type().equals("percentage")) {
holder.tvCouponValue.setText(couponItem.getDiscount() + mContext.getResources().getString(R.string.percentage));
} else if (couponItem.getDiscount_type().equals("plus_one")) {
holder.tvCouponValue.setText(couponItem.getDiscount() + mContext.getResources().getString(R.string.plus_one));
if (couponItem.getCouponsetDetails().getDiscount_type().equals("value")) {
holder.tvCouponValue.setText(couponItem.getCouponsetDetails().getDiscount() + mContext.getResources().getString(R.string.euro));
} else if (couponItem.getCouponsetDetails().getDiscount_type().equals("percentage")) {
holder.tvCouponValue.setText(couponItem.getCouponsetDetails().getDiscount() + mContext.getResources().getString(R.string.percentage));
} else if (couponItem.getCouponsetDetails().getDiscount_type().equals("plus_one")) {
holder.tvCouponValue.setText(couponItem.getCouponsetDetails().getDiscount() + mContext.getResources().getString(R.string.plus_one));
} else {
holder.tvCouponValue.setText(couponItem.getDiscount() + mContext.getResources().getString(R.string.euro));
holder.tvCouponValue.setText(couponItem.getCouponsetDetails().getDiscount() + mContext.getResources().getString(R.string.euro));
}
}
holder.itemView.setOnClickListener(v -> onClickSubject.onNext(couponItem));
......