Panagiotis Triantafyllou

unified screen basket part3

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.5.4r37'
PUBLISH_VERSION = '4.5.5.4r38'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -11,6 +11,7 @@ import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
......@@ -63,6 +64,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
private ActiveCouponAdapter mAdapterCoupons;
private Set<Coupon> mSelectedItems = new HashSet<>();
private LinearLayout mLlActivateunified;
private AlertDialog mAlertDialog;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -258,8 +260,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
Intent intent = new Intent(ActiveUnifiedCouponsActivity.this, CouponInfoActivity.class);
intent.putExtra("coupon", coupon.getCoupon());
intent.putExtra("isFromWallet", true);
// intent.putExtra("isUnified", true);
// intent.putExtra("unifiedCoupon", coupon.getBarcode());
intent.putExtra("isActiveUnified", true);
startActivity(intent);
}
})
......@@ -321,11 +322,29 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_gray);
mLlActivateunified.setBackgroundResource(R.drawable.selector_button_grey_dark);
mSelectedItems.clear();
if (!isFinishing()) {
mAlertDialog = new AlertDialog.Builder(ActiveUnifiedCouponsActivity.this)
.setTitle(R.string.cos_dlg_success_unified_title)
.setMessage(R.string.cos_dlg_success_unified_subtitle)
.setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
dialogPositive.dismiss();
})
.show();
}
}
@Override
public void onFailure(int errorCode) {
if (!isFinishing()) {
mAlertDialog = new AlertDialog.Builder(ActiveUnifiedCouponsActivity.this)
.setTitle(R.string.cos_dlg_error_unified_title)
.setMessage(R.string.cos_dlg_error_subtitle)
.setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
dialogPositive.dismiss();
})
.show();
}
}
};
}
......
......@@ -56,7 +56,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms, mLlWebsite;
private Coupon mCoupon;
private boolean mIsBarcodeShown = false, mIsTermsShown = false, mIsFromWallet = false,
mShopsPressed = false, mGiftPressed = false, mEshopPressed = false, mIsUnified = false;
mShopsPressed = false, mGiftPressed = false, mEshopPressed = false, mIsUnified = false,
mIsActiveUnified = false;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -70,6 +71,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
String couponCode = getIntent().getStringExtra("coupon");
mIsFromWallet = getIntent().getBooleanExtra("isFromWallet", false);
mIsUnified = getIntent().getBooleanExtra("isUnified", false);
mIsActiveUnified = getIntent().getBooleanExtra("isActiveUnified", false);
if (mIsUnified) {
String couponUnifiedCode = getIntent().getStringExtra("unifiedCoupon");
......@@ -85,6 +87,14 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
}
}
} else {
if (mIsActiveUnified) {
for (Coupon cpn : WarplyManagerHelper.getSmCouponsList()) {
if (cpn.getCoupon().equals(couponCode)) {
mCoupon = cpn;
break;
}
}
} else {
for (Coupon cpn : WarplyManagerHelper.getCouponList()) {
if (cpn.getCoupon().equals(couponCode)) {
mCoupon = cpn;
......@@ -92,6 +102,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
}
}
}
}
mIvBack = findViewById(R.id.iv_coupon_info_back);
mTvTerms = findViewById(R.id.tv_terms);
......
......@@ -1369,7 +1369,7 @@ public class WarplyManagerHelper {
mCouponRedeemedList.addAll(couponRedeemedList);
}
public static void setSmCouponsList(CouponList couponRedeemedList) {
public static void setSmCouponsList(ArrayList<Coupon> couponRedeemedList) {
mSmCouponsList.clear();
mSmCouponsList.addAll(couponRedeemedList);
}
......
......@@ -56,6 +56,8 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
......@@ -3264,14 +3266,25 @@ public class WarplyManager {
Futures.addCallback(mergedResultFuture, new FutureCallback<CouponList>() {
@Override
public void onSuccess(CouponList mergedResult) {
CouponList mfinalActiveSMCoupons = new CouponList();
for (Coupon mergedItem : mergedResult) {
for (Coupon tempItem : mTempActiveSMCoupons) {
if (!mergedItem.getCoupon().equals(tempItem.getCoupon())) {
mfinalActiveSMCoupons.add(mergedItem);
HashSet<String> commonIds = new HashSet<>();
for (Coupon c1 : mergedResult) {
for (Coupon c2 : mTempActiveSMCoupons) {
if (c1.getCoupon().equals(c2.getCoupon())) {
commonIds.add(c1.getCoupon());
}
}
}
HashSet<Coupon> allItems = new HashSet<>(mergedResult);
allItems.addAll(mTempActiveSMCoupons);
Iterator<Coupon> iterator = allItems.iterator();
while (iterator.hasNext()) {
Coupon coupon = iterator.next();
if (commonIds.contains(coupon.getCoupon())) {
iterator.remove(); // Remove items with common 'id'
}
}
ArrayList<Coupon> mfinalActiveSMCoupons = new ArrayList<>(allItems);
WarplyManagerHelper.setSmCouponsList(mfinalActiveSMCoupons);
executorService.shutdownNow();
}
......
......@@ -46,6 +46,9 @@
<string name="cos_redeem_coupon2">Απόκτησέ το δωρεάν</string>
<string name="cos_dlg_success_subtitle">Το κουπόνι εξαργυρώθηκε με επιτυχία</string>
<string name="cos_dlg_error_title">Αποτυχία</string>
<string name="cos_dlg_error_unified_title">Αποτυχία Δημιουργίας Κουπονιού</string>
<string name="cos_dlg_success_unified_title">Δημιουργία Κουπονιού</string>
<string name="cos_dlg_success_unified_subtitle">Το ενιαίο κουπόνι σου δημιουργήθηκε επιτυχώς.</string>
<string name="cos_dlg_error_title2">Αποτυχία αποστολής</string>
<string name="cos_dlg_return_title">Επιστροφή δώρου</string>
<string name="cos_dlg_error_subtitle">Κάτι πήγε στραβά</string>
......