Panagiotis Triantafyllou

unified screen basket part3

...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.5.4r37' 5 + PUBLISH_VERSION = '4.5.5.4r38'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
...@@ -11,6 +11,7 @@ import android.widget.LinearLayout; ...@@ -11,6 +11,7 @@ import android.widget.LinearLayout;
11 import android.widget.RelativeLayout; 11 import android.widget.RelativeLayout;
12 import android.widget.TextView; 12 import android.widget.TextView;
13 13
14 +import androidx.appcompat.app.AlertDialog;
14 import androidx.constraintlayout.widget.ConstraintLayout; 15 import androidx.constraintlayout.widget.ConstraintLayout;
15 import androidx.recyclerview.widget.LinearLayoutManager; 16 import androidx.recyclerview.widget.LinearLayoutManager;
16 import androidx.recyclerview.widget.RecyclerView; 17 import androidx.recyclerview.widget.RecyclerView;
...@@ -63,6 +64,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -63,6 +64,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
63 private ActiveCouponAdapter mAdapterCoupons; 64 private ActiveCouponAdapter mAdapterCoupons;
64 private Set<Coupon> mSelectedItems = new HashSet<>(); 65 private Set<Coupon> mSelectedItems = new HashSet<>();
65 private LinearLayout mLlActivateunified; 66 private LinearLayout mLlActivateunified;
67 + private AlertDialog mAlertDialog;
66 68
67 // =========================================================== 69 // ===========================================================
68 // Methods for/from SuperClass/Interfaces 70 // Methods for/from SuperClass/Interfaces
...@@ -258,8 +260,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -258,8 +260,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
258 Intent intent = new Intent(ActiveUnifiedCouponsActivity.this, CouponInfoActivity.class); 260 Intent intent = new Intent(ActiveUnifiedCouponsActivity.this, CouponInfoActivity.class);
259 intent.putExtra("coupon", coupon.getCoupon()); 261 intent.putExtra("coupon", coupon.getCoupon());
260 intent.putExtra("isFromWallet", true); 262 intent.putExtra("isFromWallet", true);
261 -// intent.putExtra("isUnified", true); 263 + intent.putExtra("isActiveUnified", true);
262 -// intent.putExtra("unifiedCoupon", coupon.getBarcode());
263 startActivity(intent); 264 startActivity(intent);
264 } 265 }
265 }) 266 })
...@@ -321,11 +322,29 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -321,11 +322,29 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
321 mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_gray); 322 mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_gray);
322 mLlActivateunified.setBackgroundResource(R.drawable.selector_button_grey_dark); 323 mLlActivateunified.setBackgroundResource(R.drawable.selector_button_grey_dark);
323 mSelectedItems.clear(); 324 mSelectedItems.clear();
325 +
326 + if (!isFinishing()) {
327 + mAlertDialog = new AlertDialog.Builder(ActiveUnifiedCouponsActivity.this)
328 + .setTitle(R.string.cos_dlg_success_unified_title)
329 + .setMessage(R.string.cos_dlg_success_unified_subtitle)
330 + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
331 + dialogPositive.dismiss();
332 + })
333 + .show();
334 + }
324 } 335 }
325 336
326 @Override 337 @Override
327 public void onFailure(int errorCode) { 338 public void onFailure(int errorCode) {
328 - 339 + if (!isFinishing()) {
340 + mAlertDialog = new AlertDialog.Builder(ActiveUnifiedCouponsActivity.this)
341 + .setTitle(R.string.cos_dlg_error_unified_title)
342 + .setMessage(R.string.cos_dlg_error_subtitle)
343 + .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
344 + dialogPositive.dismiss();
345 + })
346 + .show();
347 + }
329 } 348 }
330 }; 349 };
331 } 350 }
......
...@@ -56,7 +56,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -56,7 +56,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
56 private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms, mLlWebsite; 56 private LinearLayout mLlGiftIt, mLlShops, mLlBarcodeShown, mLlBarcodeContainer, mLlTerms, mLlWebsite;
57 private Coupon mCoupon; 57 private Coupon mCoupon;
58 private boolean mIsBarcodeShown = false, mIsTermsShown = false, mIsFromWallet = false, 58 private boolean mIsBarcodeShown = false, mIsTermsShown = false, mIsFromWallet = false,
59 - mShopsPressed = false, mGiftPressed = false, mEshopPressed = false, mIsUnified = false; 59 + mShopsPressed = false, mGiftPressed = false, mEshopPressed = false, mIsUnified = false,
60 + mIsActiveUnified = false;
60 61
61 // =========================================================== 62 // ===========================================================
62 // Methods for/from SuperClass/Interfaces 63 // Methods for/from SuperClass/Interfaces
...@@ -70,6 +71,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -70,6 +71,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
70 String couponCode = getIntent().getStringExtra("coupon"); 71 String couponCode = getIntent().getStringExtra("coupon");
71 mIsFromWallet = getIntent().getBooleanExtra("isFromWallet", false); 72 mIsFromWallet = getIntent().getBooleanExtra("isFromWallet", false);
72 mIsUnified = getIntent().getBooleanExtra("isUnified", false); 73 mIsUnified = getIntent().getBooleanExtra("isUnified", false);
74 + mIsActiveUnified = getIntent().getBooleanExtra("isActiveUnified", false);
73 75
74 if (mIsUnified) { 76 if (mIsUnified) {
75 String couponUnifiedCode = getIntent().getStringExtra("unifiedCoupon"); 77 String couponUnifiedCode = getIntent().getStringExtra("unifiedCoupon");
...@@ -85,6 +87,14 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -85,6 +87,14 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
85 } 87 }
86 } 88 }
87 } else { 89 } else {
90 + if (mIsActiveUnified) {
91 + for (Coupon cpn : WarplyManagerHelper.getSmCouponsList()) {
92 + if (cpn.getCoupon().equals(couponCode)) {
93 + mCoupon = cpn;
94 + break;
95 + }
96 + }
97 + } else {
88 for (Coupon cpn : WarplyManagerHelper.getCouponList()) { 98 for (Coupon cpn : WarplyManagerHelper.getCouponList()) {
89 if (cpn.getCoupon().equals(couponCode)) { 99 if (cpn.getCoupon().equals(couponCode)) {
90 mCoupon = cpn; 100 mCoupon = cpn;
...@@ -92,6 +102,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -92,6 +102,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
92 } 102 }
93 } 103 }
94 } 104 }
105 + }
95 106
96 mIvBack = findViewById(R.id.iv_coupon_info_back); 107 mIvBack = findViewById(R.id.iv_coupon_info_back);
97 mTvTerms = findViewById(R.id.tv_terms); 108 mTvTerms = findViewById(R.id.tv_terms);
......
...@@ -1369,7 +1369,7 @@ public class WarplyManagerHelper { ...@@ -1369,7 +1369,7 @@ public class WarplyManagerHelper {
1369 mCouponRedeemedList.addAll(couponRedeemedList); 1369 mCouponRedeemedList.addAll(couponRedeemedList);
1370 } 1370 }
1371 1371
1372 - public static void setSmCouponsList(CouponList couponRedeemedList) { 1372 + public static void setSmCouponsList(ArrayList<Coupon> couponRedeemedList) {
1373 mSmCouponsList.clear(); 1373 mSmCouponsList.clear();
1374 mSmCouponsList.addAll(couponRedeemedList); 1374 mSmCouponsList.addAll(couponRedeemedList);
1375 } 1375 }
......
...@@ -56,6 +56,8 @@ import java.text.SimpleDateFormat; ...@@ -56,6 +56,8 @@ import java.text.SimpleDateFormat;
56 import java.util.ArrayList; 56 import java.util.ArrayList;
57 import java.util.Collections; 57 import java.util.Collections;
58 import java.util.Date; 58 import java.util.Date;
59 +import java.util.HashSet;
60 +import java.util.Iterator;
59 import java.util.LinkedHashSet; 61 import java.util.LinkedHashSet;
60 import java.util.List; 62 import java.util.List;
61 import java.util.Locale; 63 import java.util.Locale;
...@@ -3264,14 +3266,25 @@ public class WarplyManager { ...@@ -3264,14 +3266,25 @@ public class WarplyManager {
3264 Futures.addCallback(mergedResultFuture, new FutureCallback<CouponList>() { 3266 Futures.addCallback(mergedResultFuture, new FutureCallback<CouponList>() {
3265 @Override 3267 @Override
3266 public void onSuccess(CouponList mergedResult) { 3268 public void onSuccess(CouponList mergedResult) {
3267 - CouponList mfinalActiveSMCoupons = new CouponList(); 3269 + HashSet<String> commonIds = new HashSet<>();
3268 - for (Coupon mergedItem : mergedResult) { 3270 + for (Coupon c1 : mergedResult) {
3269 - for (Coupon tempItem : mTempActiveSMCoupons) { 3271 + for (Coupon c2 : mTempActiveSMCoupons) {
3270 - if (!mergedItem.getCoupon().equals(tempItem.getCoupon())) { 3272 + if (c1.getCoupon().equals(c2.getCoupon())) {
3271 - mfinalActiveSMCoupons.add(mergedItem); 3273 + commonIds.add(c1.getCoupon());
3272 } 3274 }
3273 } 3275 }
3274 } 3276 }
3277 + HashSet<Coupon> allItems = new HashSet<>(mergedResult);
3278 + allItems.addAll(mTempActiveSMCoupons);
3279 + Iterator<Coupon> iterator = allItems.iterator();
3280 + while (iterator.hasNext()) {
3281 + Coupon coupon = iterator.next();
3282 + if (commonIds.contains(coupon.getCoupon())) {
3283 + iterator.remove(); // Remove items with common 'id'
3284 + }
3285 + }
3286 + ArrayList<Coupon> mfinalActiveSMCoupons = new ArrayList<>(allItems);
3287 +
3275 WarplyManagerHelper.setSmCouponsList(mfinalActiveSMCoupons); 3288 WarplyManagerHelper.setSmCouponsList(mfinalActiveSMCoupons);
3276 executorService.shutdownNow(); 3289 executorService.shutdownNow();
3277 } 3290 }
......
...@@ -46,6 +46,9 @@ ...@@ -46,6 +46,9 @@
46 <string name="cos_redeem_coupon2">Απόκτησέ το δωρεάν</string> 46 <string name="cos_redeem_coupon2">Απόκτησέ το δωρεάν</string>
47 <string name="cos_dlg_success_subtitle">Το κουπόνι εξαργυρώθηκε με επιτυχία</string> 47 <string name="cos_dlg_success_subtitle">Το κουπόνι εξαργυρώθηκε με επιτυχία</string>
48 <string name="cos_dlg_error_title">Αποτυχία</string> 48 <string name="cos_dlg_error_title">Αποτυχία</string>
49 + <string name="cos_dlg_error_unified_title">Αποτυχία Δημιουργίας Κουπονιού</string>
50 + <string name="cos_dlg_success_unified_title">Δημιουργία Κουπονιού</string>
51 + <string name="cos_dlg_success_unified_subtitle">Το ενιαίο κουπόνι σου δημιουργήθηκε επιτυχώς.</string>
49 <string name="cos_dlg_error_title2">Αποτυχία αποστολής</string> 52 <string name="cos_dlg_error_title2">Αποτυχία αποστολής</string>
50 <string name="cos_dlg_return_title">Επιστροφή δώρου</string> 53 <string name="cos_dlg_return_title">Επιστροφή δώρου</string>
51 <string name="cos_dlg_error_subtitle">Κάτι πήγε στραβά</string> 54 <string name="cos_dlg_error_subtitle">Κάτι πήγε στραβά</string>
......