Panagiotis Triantafyllou

new coupons request part5, crash fixes

......@@ -150,7 +150,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
.concat(mCoupon.getName()));
Intent intent = new Intent(CouponInfoActivity.this, CouponShareActivity.class);
intent.putExtra("coupon", (Serializable) mCoupon);
intent.putExtra("coupon", mCoupon.getCoupon());
intent.putExtra("isFromWallet", mIsFromWallet);
if (!mIsFromWallet)
startActivity(intent);
......
......@@ -38,6 +38,7 @@ import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
import ly.warp.sdk.io.request.CosmoteCouponSharingRequest;
import ly.warp.sdk.io.request.WarplyConsumerRequest;
import ly.warp.sdk.io.request.WarplyUserCouponsRequest;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
import ly.warp.sdk.utils.managers.WarplyManager;
......@@ -76,9 +77,16 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_coupon_share);
mCoupon = (Coupon) getIntent().getSerializableExtra("coupon");
String couponCode = getIntent().getStringExtra("coupon");
mIsFromWallet = getIntent().getBooleanExtra("isFromWallet", false);
for (Coupon cpn : WarplyManagerHelper.getCouponList()) {
if (cpn.getCoupon().equals(couponCode)) {
mCoupon = cpn;
break;
}
}
mIvBack = findViewById(R.id.iv_coupon_share_back);
mTvCouponTitle = findViewById(R.id.textView13);
mIvCouponPhoto = findViewById(R.id.imageView6);
......@@ -154,15 +162,15 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
// ===========================================================
private void initViews() {
mTvCouponTitle.setText(mCoupon.getName());
mTvCouponTitle.setText(mCoupon.getCouponsetDetails().getName());
if (!TextUtils.isEmpty(mCoupon.getImage())) {
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())
.load(mCoupon.getCouponsetDetails().getImgPreview())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(mIvCouponPhoto);
} else {
......@@ -288,7 +296,7 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
.setPositiveButton(R.string.cos_dlg_negative_button3, (dialogPositive, whichPositive) -> {
WarplyAnalyticsManager.logTrackersEvent(this, "click", ("ShareCoupon")
.concat(":")
.concat(mCoupon.getName()));
.concat(mCoupon.getCouponsetDetails().getName()));
new Thread(() -> {
if (!Thread.currentThread().isInterrupted()) {
......
......@@ -76,10 +76,24 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_couponset_info);
mCouponset = (Couponset) getIntent().getSerializableExtra("couponset");
mLoyalty = (Campaign) getIntent().getSerializableExtra("loyalty");
String couponsetCode = getIntent().getStringExtra("couponset");
String campaignCode = getIntent().getStringExtra("loyalty");
mCcms = (LoyaltyContextualOfferModel) getIntent().getSerializableExtra("ccms");
for (Couponset cpnst : WarplyManagerHelper.getCouponsets()) {
if (cpnst.getUuid().equals(couponsetCode)) {
mCouponset = cpnst;
break;
}
}
for (Campaign cmp : WarplyManagerHelper.getCampaignList()) {
if (cmp.getSessionUUID().equals(campaignCode)) {
mLoyalty = cmp;
break;
}
}
mIvBack = findViewById(R.id.iv_couponset_info_back);
mTvTerms = findViewById(R.id.tv_terms);
mTvCouponsetTitle = findViewById(R.id.textView13);
......
......@@ -25,7 +25,6 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.Set;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;
......@@ -254,8 +253,8 @@ public class GiftsForYouActivity extends AppCompatActivity implements View.OnCli
WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(dataItem.getCampaign().getSessionUUID()));
WarplyManager.getSingleCampaign(dataItem.getCampaign().getSessionUUID());
Intent intent = new Intent(GiftsForYouActivity.this, CouponsetInfoActivity.class);
intent.putExtra("couponset", (Serializable) cpns);
intent.putExtra("loyalty", (Serializable) dataItem.getCampaign());
intent.putExtra("couponset", cpns.getUuid());
intent.putExtra("loyalty", dataItem.getCampaign().getSessionUUID());
intent.putExtra("ccms", ccmsItem);
startActivityForResult(intent, 1004);
break;
......@@ -294,8 +293,8 @@ public class GiftsForYouActivity extends AppCompatActivity implements View.OnCli
WarplyAnalyticsManager.logTrackersEvent(this, "click", ("Loyalty").concat(":").concat(dataItem.getCampaign().getSessionUUID()));
WarplyManager.getSingleCampaign(dataItem.getCampaign().getSessionUUID());
Intent intent = new Intent(GiftsForYouActivity.this, CouponsetInfoActivity.class);
intent.putExtra("couponset", (Serializable) cpns);
intent.putExtra("loyalty", (Serializable) dataItem.getCampaign());
intent.putExtra("couponset", cpns.getUuid());
intent.putExtra("loyalty", dataItem.getCampaign().getSessionUUID());
startActivityForResult(intent, 1004);
break;
}
......@@ -332,7 +331,7 @@ public class GiftsForYouActivity extends AppCompatActivity implements View.OnCli
WarplyManager.getSingleCampaign(dataItem.getCampaign().getSessionUUID());
Intent intent = new Intent(GiftsForYouActivity.this, TelcoActivity.class);
intent.putExtra("ccms", ccms);
intent.putExtra("loyalty", (Serializable) dataItem.getCampaign());
intent.putExtra("loyalty", dataItem.getCampaign().getSessionUUID());
startActivityForResult(intent, 1004);
break;
}
......
......@@ -23,6 +23,7 @@ import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
......@@ -115,6 +116,7 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
}
}
}
Collections.sort(mExpiredMarketCoupons, (coupon1, coupon2) -> coupon2.getChangesDates().optString("redeemed").compareTo(coupon1.getChangesDates().optString("redeemed")));
new Handler(Looper.getMainLooper()).post(this::initViews);
executor.shutdownNow();
});
......
......@@ -23,7 +23,6 @@ import org.json.JSONObject;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
......@@ -420,7 +419,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
WarplyManager.getSingleCampaign(moreItem.getSessionUUID());
Intent intent = new Intent(MoreForYouActivity.this, TelcoActivity.class);
intent.putExtra("ccms", ccms);
intent.putExtra("loyalty", (Serializable) moreItem);
intent.putExtra("loyalty", moreItem.getSessionUUID());
startActivityForResult(intent, 1003);
break;
}
......
......@@ -34,6 +34,7 @@ import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
import ly.warp.sdk.io.models.WarplyCCMSEnabledModel;
import ly.warp.sdk.io.request.CosmoteSubmitOrderRequest;
import ly.warp.sdk.io.request.WarplyConsumerRequest;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
import ly.warp.sdk.utils.managers.WarplyManager;
......@@ -73,7 +74,14 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
setContentView(R.layout.activity_telco);
mCCMS = (LoyaltyContextualOfferModel) getIntent().getSerializableExtra("ccms");
mLoyalty = (Campaign) getIntent().getSerializableExtra("loyalty");
String campaignCode = getIntent().getStringExtra("loyalty");
for (Campaign cmp : WarplyManagerHelper.getCampaignList()) {
if (cmp.getSessionUUID().equals(campaignCode)) {
mLoyalty = cmp;
break;
}
}
mIvBack = findViewById(R.id.iv_telco_back);
mTvCampaignTitle = findViewById(R.id.textView13);
......
......@@ -107,6 +107,7 @@ public class Campaign implements Parcelable, Serializable {
private String bannerTitle;
private String categoryId;
private Integer couponAvailability;
private String endDate, startDate;
/**
* Basic constructor used to create an object from a String, representing a
......@@ -148,6 +149,8 @@ public class Campaign implements Parcelable, Serializable {
this.bannerTitle = "";
this.couponAvailability = null;
this.categoryId = "";
this.endDate = "";
this.startDate = "";
}
/**
......@@ -659,6 +662,22 @@ public class Campaign implements Parcelable, Serializable {
this.bannerTitle = bannerTitle;
}
public String getEndDate() {
return endDate;
}
public void setEndDate(String endDate) {
this.endDate = endDate;
}
public String getStartDate() {
return startDate;
}
public void setStartDate(String startDate) {
this.startDate = startDate;
}
@Override
public int describeContents() {
return 0;
......
......@@ -163,6 +163,7 @@ public class Couponset implements Parcelable, Serializable {
this.couponsetType = "";
this.img_preview = "";
this.innerText = "";
this.final_price = 0.0d;
}
/**
......@@ -239,6 +240,7 @@ public class Couponset implements Parcelable, Serializable {
this.couponsetType = json.optString("couponset_type");
this.img_preview = json.optString(IMG_PREVIEW);
this.innerText = json.optString(INNER_TEXT);
this.final_price = json.isNull(FINAL_PRICE) ? 0.0d : json.optDouble(FINAL_PRICE);
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
// Date newDate = new Date();
// String tempRedeemDate = json.optString("end_date");
......
......@@ -863,7 +863,7 @@ public class WarplyManagerHelper {
WarplyManager.getSingleCampaign(camp.getSessionUUID());
Intent intent = new Intent(context, TelcoActivity.class);
intent.putExtra("ccms", item);
intent.putExtra("loyalty", (Serializable) camp);
intent.putExtra("loyalty", camp.getSessionUUID());
context.startActivity(intent);
break;
}
......@@ -906,8 +906,8 @@ public class WarplyManagerHelper {
WarplyAnalyticsManager.logTrackersEvent(context, "click", ("Loyalty").concat(":").concat(item.getSessionUUID()));
WarplyManager.getSingleCampaign(item.getSessionUUID());
Intent intent = new Intent(context, CouponsetInfoActivity.class);
intent.putExtra("couponset", (Serializable) cpns);
intent.putExtra("loyalty", (Serializable) item);
intent.putExtra("couponset", cpns.getUuid());
intent.putExtra("loyalty", item.getSessionUUID());
intent.putExtra("ccms", ccmsItem);
context.startActivity(intent);
break;
......@@ -946,8 +946,8 @@ public class WarplyManagerHelper {
WarplyAnalyticsManager.logTrackersEvent(context, "click", ("Loyalty").concat(":").concat(item.getSessionUUID()));
WarplyManager.getSingleCampaign(item.getSessionUUID());
Intent intent = new Intent(context, CouponsetInfoActivity.class);
intent.putExtra("couponset", (Serializable) cpns);
intent.putExtra("loyalty", (Serializable) item);
intent.putExtra("couponset", cpns.getUuid());
intent.putExtra("loyalty", item.getSessionUUID());
context.startActivity(intent);
break;
}
......@@ -1081,8 +1081,8 @@ public class WarplyManagerHelper {
for (Couponset cpns : mCouponsetsList) {
if (cpns.getUuid().equals(cpnUuid)) {
Intent intent = new Intent(context, CouponsetInfoActivity.class);
intent.putExtra("couponset", (Serializable) cpns);
intent.putExtra("loyalty", (Serializable) item);
intent.putExtra("couponset", cpns.getUuid());
intent.putExtra("loyalty", item.getSessionUUID());
context.startActivity(intent);
break;
}
......@@ -1099,7 +1099,7 @@ public class WarplyManagerHelper {
if (ccms.getLoyaltyCampaignId().equals(item.getSessionUUID())) {
Intent intent = new Intent(context, TelcoActivity.class);
intent.putExtra("ccms", ccms);
intent.putExtra("loyalty", (Serializable) item);
intent.putExtra("loyalty", item.getSessionUUID());
context.startActivity(intent);
break;
}
......@@ -1336,7 +1336,7 @@ public class WarplyManagerHelper {
try {
couponCount += 1;
// couponValue += Float.parseFloat(coupon.getDiscount());
couponValue += (float) coupon.getFinal_price();
couponValue += (float) coupon.getCouponsetDetails().getFinal_price();
} catch (NumberFormatException e) {
couponCount -= 1;
}
......
......@@ -1764,6 +1764,8 @@ public class WarplyManager {
camp.setSorting(newCamp.getSorting());
camp.setNew(newCamp.getIsNew());
camp.setType(newCamp.getCampaignType());
camp.setEndDate(newCamp.getEndDate());
camp.setStartDate(newCamp.getStartDate());
try {
camp.setExtraFields(newCamp.getExtraFields().toString());
if (!TextUtils.isEmpty(newCamp.getExtraFields().toString())) {
......@@ -1906,6 +1908,8 @@ public class WarplyManager {
camp.setSorting(newCamp.getSorting());
camp.setNew(newCamp.getIsNew());
camp.setType(newCamp.getCampaignType());
camp.setEndDate(newCamp.getEndDate());
camp.setStartDate(newCamp.getStartDate());
try {
camp.setExtraFields(newCamp.getExtraFields().toString());
if (!TextUtils.isEmpty(newCamp.getExtraFields().toString())) {
......
......@@ -24,8 +24,6 @@ import io.reactivex.subjects.PublishSubject;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.Coupon;
import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.models.Merchant;
import ly.warp.sdk.utils.WarplyManagerHelper;
public class ExpiredCouponAdapter extends RecyclerView.Adapter<ExpiredCouponAdapter.ExpiredCouponViewHolder> {
......@@ -93,44 +91,20 @@ public class ExpiredCouponAdapter extends RecyclerView.Adapter<ExpiredCouponAdap
@Override
public void onBindViewHolder(final ExpiredCouponViewHolder holder, int position) {
Coupon couponItem = mCoupons.get(position);
Merchant merchant = new Merchant();
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 (merchant == null) {
holder.tvCouponTitle.setText(couponItem.getName());
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 {
holder.tvCouponTitle.setText(merchant.getAdminName());
if (!TextUtils.isEmpty(merchant.getImgPreview())) {
holder.tvCouponTitle.setText(couponItem.getMerchantDetails().getAdminName());
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(merchant.getImgPreview())
.load(couponItem.getMerchantDetails().getImgPreview())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(holder.ivCouponLogo);
}
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
Date newDate = new Date();
......@@ -149,30 +123,17 @@ public class ExpiredCouponAdapter extends RecyclerView.Adapter<ExpiredCouponAdap
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) {
holder.tvCouponTitle.setText(couponItem.getName());
} else {
holder.tvCouponTitle.setText(merchant.getAdminName());
if (!TextUtils.isEmpty(merchant.getImgPreview())) {
holder.tvCouponTitle.setText(couponItem.getMerchantDetails().getAdminName());
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(merchant.getImgPreview())
.load(couponItem.getMerchantDetails().getImgPreview())
.diskCacheStrategy(DiskCacheStrategy.DATA)
.into(holder.ivCouponLogo);
}
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
Date newDate = new Date();
......@@ -185,7 +146,7 @@ public class ExpiredCouponAdapter extends RecyclerView.Adapter<ExpiredCouponAdap
holder.tvCouponDate.setVisibility(View.GONE);
}
String itemValue = String.format("%.02f", couponItem.getFinal_price());
String itemValue = String.format("%.02f", couponItem.getCouponsetDetails().getFinal_price());
holder.tvCouponValue.setText(itemValue + mContext.getResources().getString(R.string.euro));
holder.itemView.setOnClickListener(v -> onClickSubject.onNext(couponItem));
}
......