Panagiotis Triantafyllou

optimizations part2

...@@ -37,6 +37,7 @@ import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel; ...@@ -37,6 +37,7 @@ import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
37 import ly.warp.sdk.io.request.CosmoteSubmitOrderRequest; 37 import ly.warp.sdk.io.request.CosmoteSubmitOrderRequest;
38 import ly.warp.sdk.services.EventCampaignService; 38 import ly.warp.sdk.services.EventCampaignService;
39 import ly.warp.sdk.utils.WarpUtils; 39 import ly.warp.sdk.utils.WarpUtils;
40 +import ly.warp.sdk.utils.WarplyManagerHelper;
40 import ly.warp.sdk.utils.managers.WarplyAnalyticsManager; 41 import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
41 import ly.warp.sdk.utils.managers.WarplyEventBusManager; 42 import ly.warp.sdk.utils.managers.WarplyEventBusManager;
42 import ly.warp.sdk.utils.managers.WarplyManager; 43 import ly.warp.sdk.utils.managers.WarplyManager;
...@@ -62,7 +63,9 @@ public class ContextualActivity extends Activity implements View.OnClickListener ...@@ -62,7 +63,9 @@ public class ContextualActivity extends Activity implements View.OnClickListener
62 private Consumer mConsumer; 63 private Consumer mConsumer;
63 private boolean mIsTermsPressed = false; 64 private boolean mIsTermsPressed = false;
64 private String mSender = ""; 65 private String mSender = "";
65 - private AlertDialog mAlertDialogAskActivate, mAlertDialogErrorActivating, mAlertDialogSuccessActivating; 66 + private AlertDialog mAlertDialogAskActivate, mAlertDialogErrorActivating,
67 + mAlertDialogSuccessActivating;
68 + private Campaign mLoyalty;
66 69
67 // =========================================================== 70 // ===========================================================
68 // Methods for/from SuperClass/Interfaces 71 // Methods for/from SuperClass/Interfaces
...@@ -75,6 +78,15 @@ public class ContextualActivity extends Activity implements View.OnClickListener ...@@ -75,6 +78,15 @@ public class ContextualActivity extends Activity implements View.OnClickListener
75 78
76 mCCMS = (LoyaltyContextualOfferModel) getIntent().getSerializableExtra("ccms"); 79 mCCMS = (LoyaltyContextualOfferModel) getIntent().getSerializableExtra("ccms");
77 80
81 + /* New Addition start */
82 + for (Campaign cmp : WarplyManagerHelper.getCampaignListAll()) {
83 + if (cmp.getSessionUUID().equals(mCCMS.getLoyaltyCampaignId())) {
84 + mLoyalty = cmp;
85 + break;
86 + }
87 + }
88 + /* New Addition end */
89 +
78 mIvBack = findViewById(R.id.iv_contextual_back); 90 mIvBack = findViewById(R.id.iv_contextual_back);
79 mTvCampaignTitle = findViewById(R.id.textView13); 91 mTvCampaignTitle = findViewById(R.id.textView13);
80 mIvCampaignPhoto = findViewById(R.id.imageView6); 92 mIvCampaignPhoto = findViewById(R.id.imageView6);
...@@ -317,22 +329,27 @@ public class ContextualActivity extends Activity implements View.OnClickListener ...@@ -317,22 +329,27 @@ public class ContextualActivity extends Activity implements View.OnClickListener
317 @Override 329 @Override
318 public void onSuccess(JSONObject result) { 330 public void onSuccess(JSONObject result) {
319 int status = result.optInt("status", 2); 331 int status = result.optInt("status", 2);
320 -// runOnUiThread(() -> { 332 + runOnUiThread(() -> {
321 if (status == 1) { 333 if (status == 1) {
322 successActivatingDialog(); 334 successActivatingDialog();
323 /* New Addition start */ 335 /* New Addition start */
324 WarplyManager.getUserCouponsWithCouponsetsInternal(mUserCouponsReceiver); 336 WarplyManager.getUserCouponsWithCouponsetsInternal(mUserCouponsReceiver);
337 +// WarplyManager.getCampaigns(mCampaignsCallback);
338 + if (mLoyalty != null) {
339 + WarplyManagerHelper.removeCampaignItem(mLoyalty);
340 + OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build();
341 + WorkManager.getInstance(ContextualActivity.this).enqueue(mywork);
342 + }
325 /* New Addition end */ 343 /* New Addition end */
326 - WarplyManager.getCampaigns(mCampaignsCallback);
327 } else 344 } else
328 errorActivatingDialog(); 345 errorActivatingDialog();
329 -// }); 346 + });
330 } 347 }
331 348
332 @Override 349 @Override
333 public void onFailure(int errorCode) { 350 public void onFailure(int errorCode) {
334 -// runOnUiThread(() -> errorActivatingDialog()); 351 + runOnUiThread(() -> errorActivatingDialog());
335 - errorActivatingDialog(); 352 +// errorActivatingDialog();
336 } 353 }
337 }; 354 };
338 355
...@@ -350,16 +367,16 @@ public class ContextualActivity extends Activity implements View.OnClickListener ...@@ -350,16 +367,16 @@ public class ContextualActivity extends Activity implements View.OnClickListener
350 } 367 }
351 }; 368 };
352 369
353 - private CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() { 370 +// private CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() {
354 - @Override 371 +// @Override
355 - public void onSuccess(ArrayList<Campaign> result) { 372 +// public void onSuccess(ArrayList<Campaign> result) {
356 - OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build(); 373 +// OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build();
357 - WorkManager.getInstance(ContextualActivity.this).enqueue(mywork); 374 +// WorkManager.getInstance(ContextualActivity.this).enqueue(mywork);
358 - } 375 +// }
359 - 376 +//
360 - @Override 377 +// @Override
361 - public void onFailure(int errorCode) { 378 +// public void onFailure(int errorCode) {
362 - 379 +//
363 - } 380 +// }
364 - }; 381 +// };
365 } 382 }
......
...@@ -264,14 +264,18 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe ...@@ -264,14 +264,18 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
264 showDialog(true, 1); 264 showDialog(true, 1);
265 /* New Addition start */ 265 /* New Addition start */
266 // WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); 266 // WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
267 - /* New Addition end */ 267 +// WarplyManager.getCampaigns(mCampaignsCallback);
268 WarplyManagerHelper.addCouponItem(mCoupon); 268 WarplyManagerHelper.addCouponItem(mCoupon);
269 - WarplyManager.getCampaigns(mCampaignsCallback); 269 + WarplyManagerHelper.removeCampaignItem(mLoyalty);
270 + /* New Addition end */
270 271
271 /* New Addition start */ 272 /* New Addition start */
272 WarplyCouponsChangedEventModel couponsChanged = new WarplyCouponsChangedEventModel(); 273 WarplyCouponsChangedEventModel couponsChanged = new WarplyCouponsChangedEventModel();
273 couponsChanged.setChanged(true); 274 couponsChanged.setChanged(true);
274 EventBus.getDefault().post(new WarplyEventBusManager(couponsChanged)); 275 EventBus.getDefault().post(new WarplyEventBusManager(couponsChanged));
276 +
277 + OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build();
278 + WorkManager.getInstance(CouponsetInfoActivity.this).enqueue(mywork);
275 /* New Addition end */ 279 /* New Addition end */
276 } else { 280 } else {
277 showDialog(false, status); 281 showDialog(false, status);
...@@ -405,17 +409,17 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe ...@@ -405,17 +409,17 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
405 // } 409 // }
406 // }; 410 // };
407 411
408 - private CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() { 412 +// private CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() {
409 - @Override 413 +// @Override
410 - public void onSuccess(ArrayList<Campaign> result) { 414 +// public void onSuccess(ArrayList<Campaign> result) {
411 - OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build(); 415 +// OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build();
412 - WorkManager.getInstance(CouponsetInfoActivity.this).enqueue(mywork); 416 +// WorkManager.getInstance(CouponsetInfoActivity.this).enqueue(mywork);
413 - } 417 +// }
414 - 418 +//
415 - @Override 419 +// @Override
416 - public void onFailure(int errorCode) { 420 +// public void onFailure(int errorCode) {
417 - 421 +//
418 - } 422 +// }
419 - }; 423 +// };
420 424
421 } 425 }
......
...@@ -1343,6 +1343,12 @@ public class WarplyManagerHelper { ...@@ -1343,6 +1343,12 @@ public class WarplyManagerHelper {
1343 return mCampaignListAll; 1343 return mCampaignListAll;
1344 } 1344 }
1345 1345
1346 + public static void removeCampaignItem(Campaign cmp) {
1347 + if (mCampaignListAll != null && !mCampaignListAll.isEmpty()) {
1348 + mCampaignListAll.remove(cmp);
1349 + }
1350 + }
1351 +
1346 public static void setCouponList(CouponList couponList) { 1352 public static void setCouponList(CouponList couponList) {
1347 LoyaltyBadgeModel badge = new LoyaltyBadgeModel(); 1353 LoyaltyBadgeModel badge = new LoyaltyBadgeModel();
1348 CouponList cpnlist = new CouponList(); 1354 CouponList cpnlist = new CouponList();
......
...@@ -5304,18 +5304,18 @@ public class WarplyManager { ...@@ -5304,18 +5304,18 @@ public class WarplyManager {
5304 dynatraceEvent.setEventName("custom_success_read_campaign_loyalty"); 5304 dynatraceEvent.setEventName("custom_success_read_campaign_loyalty");
5305 EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); 5305 EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
5306 5306
5307 - getCampaigns(new CallbackReceiver<ArrayList<Campaign>>() { 5307 +// getCampaigns(new CallbackReceiver<ArrayList<Campaign>>() {
5308 - @Override 5308 +// @Override
5309 - public void onSuccess(ArrayList<Campaign> result) { 5309 +// public void onSuccess(ArrayList<Campaign> result) {
5310 - OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build(); 5310 +// OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build();
5311 - WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork); 5311 +// WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
5312 - } 5312 +// }
5313 - 5313 +//
5314 - @Override 5314 +// @Override
5315 - public void onFailure(int errorCode) { 5315 +// public void onFailure(int errorCode) {
5316 - 5316 +//
5317 - } 5317 +// }
5318 - }); 5318 +// });
5319 } 5319 }
5320 5320
5321 @Override 5321 @Override
...@@ -5325,18 +5325,18 @@ public class WarplyManager { ...@@ -5325,18 +5325,18 @@ public class WarplyManager {
5325 dynatraceEvent.setEventName("custom_success_read_campaign_loyalty"); 5325 dynatraceEvent.setEventName("custom_success_read_campaign_loyalty");
5326 EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent)); 5326 EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
5327 5327
5328 - getCampaigns(new CallbackReceiver<ArrayList<Campaign>>() { 5328 +// getCampaigns(new CallbackReceiver<ArrayList<Campaign>>() {
5329 - @Override 5329 +// @Override
5330 - public void onSuccess(ArrayList<Campaign> result) { 5330 +// public void onSuccess(ArrayList<Campaign> result) {
5331 - OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build(); 5331 +// OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventCampaignService.class).build();
5332 - WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork); 5332 +// WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
5333 - } 5333 +// }
5334 - 5334 +//
5335 - @Override 5335 +// @Override
5336 - public void onFailure(int errorCode) { 5336 +// public void onFailure(int errorCode) {
5337 - 5337 +//
5338 - } 5338 +// }
5339 - }); 5339 +// });
5340 } 5340 }
5341 } 5341 }
5342 }, null); 5342 }, null);
......