Panagiotis Triantafyllou

sm deals fixes

...@@ -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.4.6rc78' 5 + PUBLISH_VERSION = '4.5.4.6rc79'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
...@@ -46,7 +46,6 @@ import io.github.inflationx.calligraphy3.CalligraphyTypefaceSpan; ...@@ -46,7 +46,6 @@ import io.github.inflationx.calligraphy3.CalligraphyTypefaceSpan;
46 import io.github.inflationx.calligraphy3.TypefaceUtils; 46 import io.github.inflationx.calligraphy3.TypefaceUtils;
47 import io.github.inflationx.viewpump.ViewPumpContextWrapper; 47 import io.github.inflationx.viewpump.ViewPumpContextWrapper;
48 import ly.warp.sdk.R; 48 import ly.warp.sdk.R;
49 -import ly.warp.sdk.io.callbacks.CallbackReceiver;
50 import ly.warp.sdk.io.models.ActiveDFYCouponEventModel; 49 import ly.warp.sdk.io.models.ActiveDFYCouponEventModel;
51 import ly.warp.sdk.io.models.ActiveDFYCouponModel; 50 import ly.warp.sdk.io.models.ActiveDFYCouponModel;
52 import ly.warp.sdk.io.models.Coupon; 51 import ly.warp.sdk.io.models.Coupon;
...@@ -59,7 +58,6 @@ import ly.warp.sdk.utils.WarpUtils; ...@@ -59,7 +58,6 @@ import ly.warp.sdk.utils.WarpUtils;
59 import ly.warp.sdk.utils.WarplyManagerHelper; 58 import ly.warp.sdk.utils.WarplyManagerHelper;
60 import ly.warp.sdk.utils.managers.WarplyAnalyticsManager; 59 import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
61 import ly.warp.sdk.utils.managers.WarplyEventBusManager; 60 import ly.warp.sdk.utils.managers.WarplyEventBusManager;
62 -import ly.warp.sdk.utils.managers.WarplyManager;
63 import ly.warp.sdk.views.adapters.ActiveCouponAdapter; 61 import ly.warp.sdk.views.adapters.ActiveCouponAdapter;
64 import ly.warp.sdk.views.adapters.MarketCouponAdapter; 62 import ly.warp.sdk.views.adapters.MarketCouponAdapter;
65 63
...@@ -170,25 +168,25 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie ...@@ -170,25 +168,25 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
170 mRecyclerCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); 168 mRecyclerCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
171 169
172 initViews(); 170 initViews();
173 -
174 -// WarplyManager.getUnifiedCoupons(mUnifiedCallback);
175 } 171 }
176 172
177 @Override 173 @Override
178 protected void onStart() { 174 protected void onStart() {
179 super.onStart(); 175 super.onStart();
176 + if (!EventBus.getDefault().isRegistered(this))
180 EventBus.getDefault().register(this); 177 EventBus.getDefault().register(this);
181 } 178 }
182 179
183 @Override 180 @Override
184 protected void onStop() { 181 protected void onStop() {
185 super.onStop(); 182 super.onStop();
186 - EventBus.getDefault().unregister(this); 183 +// EventBus.getDefault().unregister(this);
187 } 184 }
188 185
189 @Override 186 @Override
190 public void onDestroy() { 187 public void onDestroy() {
191 super.onDestroy(); 188 super.onDestroy();
189 + EventBus.getDefault().unregister(this);
192 } 190 }
193 191
194 @Override 192 @Override
...@@ -816,19 +814,6 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie ...@@ -816,19 +814,6 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
816 } 814 }
817 } 815 }
818 816
819 - private final CallbackReceiver<ArrayList<UnifiedCoupon>> mUnifiedCallback = new CallbackReceiver<ArrayList<UnifiedCoupon>>() {
820 - @Override
821 - public void onSuccess(ArrayList<UnifiedCoupon> result) {
822 - mUnifiedCoupons = result;
823 - initViews();
824 - }
825 -
826 - @Override
827 - public void onFailure(int errorCode) {
828 - initViews();
829 - }
830 - };
831 -
832 // =========================================================== 817 // ===========================================================
833 // Inner and Anonymous Classes 818 // Inner and Anonymous Classes
834 // =========================================================== 819 // ===========================================================
......
...@@ -297,72 +297,6 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener ...@@ -297,72 +297,6 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
297 } 297 }
298 } 298 }
299 299
300 -// if (mUniqueSectionList.size() == 1) {
301 -// try {
302 -// String firstKey = (String) mUniqueSectionList.keySet().toArray()[0];
303 -// if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) {
304 -// mTvResearchSection.setText(firstKey.substring(1));
305 -// mResearchItems.setNestedScrollingEnabled(false);
306 -// mResearchItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
307 -// mAdapterResearch = new MoreCampaignAdapter(this, mUniqueSectionList.get(firstKey));
308 -// mResearchItems.setAdapter(mAdapterResearch);
309 -// mAdapterResearch.getPositionClicks()
310 -// .doOnNext(this::handleMoreItemClick)
311 -// .doOnError(error -> {
312 -// })
313 -// .subscribe();
314 -//
315 -// mLlResearchItems.setVisibility(View.VISIBLE);
316 -// }
317 -// } catch (IndexOutOfBoundsException ex) {
318 -// ex.printStackTrace();
319 -// }
320 -// }
321 -//
322 -// if (mUniqueSectionList.size() == 2) {
323 -// try {
324 -// String secondKey = (String) mUniqueSectionList.keySet().toArray()[1];
325 -// if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) {
326 -// mTvExclusiveSection.setText(secondKey.substring(1));
327 -// mExclusiveItems.setNestedScrollingEnabled(false);
328 -// mExclusiveItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
329 -// mAdapterExclusive = new MoreCampaignAdapter(this, mUniqueSectionList.get(secondKey));
330 -// mExclusiveItems.setAdapter(mAdapterExclusive);
331 -// mAdapterExclusive.getPositionClicks()
332 -// .doOnNext(this::handleMoreItemClick)
333 -// .doOnError(error -> {
334 -// })
335 -// .subscribe();
336 -//
337 -// mLlExclusiveItems.setVisibility(View.VISIBLE);
338 -// }
339 -// } catch (IndexOutOfBoundsException ex) {
340 -// ex.printStackTrace();
341 -// }
342 -// }
343 -//
344 -// if (mUniqueSectionList.size() == 3) {
345 -// try {
346 -// String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2];
347 -// if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) {
348 -// mTvContestSection.setText(thirdKey.substring(1));
349 -// mContestItems.setNestedScrollingEnabled(false);
350 -// mContestItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
351 -// mAdapterContest = new MoreCampaignAdapter(this, mUniqueSectionList.get(thirdKey));
352 -// mContestItems.setAdapter(mAdapterContest);
353 -// mAdapterContest.getPositionClicks()
354 -// .doOnNext(this::handleMoreItemClick)
355 -// .doOnError(error -> {
356 -// })
357 -// .subscribe();
358 -//
359 -// mLlContestItems.setVisibility(View.VISIBLE);
360 -// }
361 -// } catch (IndexOutOfBoundsException ex) {
362 -// ex.printStackTrace();
363 -// }
364 -// }
365 -
366 if (mContextualList != null && mContextualList.size() > 0) { 300 if (mContextualList != null && mContextualList.size() > 0) {
367 mTvContextualSection.setText(getString(R.string.cos_mfy_other)); 301 mTvContextualSection.setText(getString(R.string.cos_mfy_other));
368 mContextualItems.setNestedScrollingEnabled(false); 302 mContextualItems.setNestedScrollingEnabled(false);
...@@ -384,104 +318,88 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener ...@@ -384,104 +318,88 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
384 mIvBack.setOnClickListener(this); 318 mIvBack.setOnClickListener(this);
385 mIvPopupClose.setOnClickListener(this); 319 mIvPopupClose.setOnClickListener(this);
386 320
387 - if (mUniqueSectionList != null) { 321 + runOnUiThread(() -> {
388 - if (mUniqueSectionList.size() == 1) { 322 + if (mUniqueSectionList != null && mUniqueSectionList.size() > 0) {
389 - try { 323 + for (Map.Entry<String, ArrayList<Campaign>> set : mUniqueSectionList.entrySet()) {
390 - String firstKey = (String) mUniqueSectionList.keySet().toArray()[0]; 324 + String itemKey = set.getKey();
391 - if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) { 325 + ArrayList<Campaign> itemValue = set.getValue();
392 - mTvResearchSection.setText(firstKey.substring(1)); 326 +
393 -// mResearchItems.setNestedScrollingEnabled(false); 327 + if (itemKey.contains("1")) {
394 -// mAdapterResearch = new MoreCampaignAdapter(this, mUniqueSectionList.get(firstKey)); 328 + mTvResearchSection.setText(itemKey.substring(1));
395 -// mResearchItems.setItemAnimator(null); 329 + mResearchItems.setNestedScrollingEnabled(false);
396 -// mAdapterResearch.setHasStableIds(true); 330 + mResearchItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
397 -// mResearchItems.setAdapter(mAdapterResearch); 331 + mAdapterResearch = new MoreCampaignAdapter(this, itemValue);
398 -// mAdapterResearch.getPositionClicks() 332 + mResearchItems.setAdapter(mAdapterResearch);
399 -// .doOnNext(this::handleMoreItemClick) 333 + mAdapterResearch.getPositionClicks()
400 -// .doOnError(error -> { 334 + .doOnNext(this::handleMoreItemClick)
401 -// }) 335 + .doOnError(error -> {
402 -// .subscribe(); 336 + })
403 -// mAdapterResearch.notifyDataSetChanged(); 337 + .subscribe();
404 -
405 - mAdapterResearch.updateData(mUniqueSectionList.get(firstKey));
406 338
339 + mAdapterResearch.notifyDataSetChanged();
407 mLlResearchItems.setVisibility(View.VISIBLE); 340 mLlResearchItems.setVisibility(View.VISIBLE);
408 } 341 }
409 - } catch (IndexOutOfBoundsException ex) {
410 - ex.printStackTrace();
411 - }
412 } 342 }
413 343
414 - if (mUniqueSectionList.size() == 2) { 344 + for (Map.Entry<String, ArrayList<Campaign>> set : mUniqueSectionList.entrySet()) {
415 - try { 345 + String itemKey = set.getKey();
416 - String secondKey = (String) mUniqueSectionList.keySet().toArray()[1]; 346 + ArrayList<Campaign> itemValue = set.getValue();
417 - if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) {
418 - mTvExclusiveSection.setText(secondKey.substring(1));
419 -// mExclusiveItems.setNestedScrollingEnabled(false);
420 -// mAdapterExclusive = new MoreCampaignAdapter(this, mUniqueSectionList.get(secondKey));
421 -// mExclusiveItems.setItemAnimator(null);
422 -// mAdapterExclusive.setHasStableIds(true);
423 -// mExclusiveItems.setAdapter(mAdapterExclusive);
424 -// mAdapterExclusive.getPositionClicks()
425 -// .doOnNext(this::handleMoreItemClick)
426 -// .doOnError(error -> {
427 -// })
428 -// .subscribe();
429 -// mAdapterExclusive.notifyDataSetChanged();
430 -
431 - mAdapterExclusive.updateData(mUniqueSectionList.get(secondKey));
432 347
348 + if (itemKey.contains("2")) {
349 + mTvExclusiveSection.setText(itemKey.substring(1));
350 + mExclusiveItems.setNestedScrollingEnabled(false);
351 + mExclusiveItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
352 + mAdapterExclusive = new MoreCampaignAdapter(this, itemValue);
353 + mExclusiveItems.setAdapter(mAdapterExclusive);
354 + mAdapterExclusive.getPositionClicks()
355 + .doOnNext(this::handleMoreItemClick)
356 + .doOnError(error -> {
357 + })
358 + .subscribe();
359 +
360 + mAdapterExclusive.notifyDataSetChanged();
433 mLlExclusiveItems.setVisibility(View.VISIBLE); 361 mLlExclusiveItems.setVisibility(View.VISIBLE);
434 } 362 }
435 - } catch (IndexOutOfBoundsException ex) {
436 - ex.printStackTrace();
437 - }
438 } 363 }
439 364
440 - if (mUniqueSectionList.size() == 3) { 365 + for (Map.Entry<String, ArrayList<Campaign>> set : mUniqueSectionList.entrySet()) {
441 - try { 366 + String itemKey = set.getKey();
442 - String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2]; 367 + ArrayList<Campaign> itemValue = set.getValue();
443 - if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) {
444 - mTvContestSection.setText(thirdKey.substring(1));
445 -// mContestItems.setNestedScrollingEnabled(false);
446 -// mAdapterContest = new MoreCampaignAdapter(this, mUniqueSectionList.get(thirdKey));
447 -// mContestItems.setItemAnimator(null);
448 -// mAdapterContest.setHasStableIds(true);
449 -// mContestItems.setAdapter(mAdapterContest);
450 -// mAdapterContest.getPositionClicks()
451 -// .doOnNext(this::handleMoreItemClick)
452 -// .doOnError(error -> {
453 -// })
454 -// .subscribe();
455 -// mAdapterContest.notifyDataSetChanged();
456 -
457 - mAdapterContest.updateData(mUniqueSectionList.get(thirdKey));
458 368
369 + if (itemKey.contains("3")) {
370 + mTvContestSection.setText(itemKey.substring(1));
371 + mContestItems.setNestedScrollingEnabled(false);
372 + mContestItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
373 + mAdapterContest = new MoreCampaignAdapter(this, itemValue);
374 + mContestItems.setAdapter(mAdapterContest);
375 + mAdapterContest.getPositionClicks()
376 + .doOnNext(this::handleMoreItemClick)
377 + .doOnError(error -> {
378 + })
379 + .subscribe();
380 +
381 + mAdapterContest.notifyDataSetChanged();
459 mLlContestItems.setVisibility(View.VISIBLE); 382 mLlContestItems.setVisibility(View.VISIBLE);
460 } 383 }
461 - } catch (IndexOutOfBoundsException ex) {
462 - ex.printStackTrace();
463 - }
464 } 384 }
465 385
466 if (mContextualList != null && mContextualList.size() > 0) { 386 if (mContextualList != null && mContextualList.size() > 0) {
467 mTvContextualSection.setText(getString(R.string.cos_mfy_other)); 387 mTvContextualSection.setText(getString(R.string.cos_mfy_other));
468 -// mContextualItems.setNestedScrollingEnabled(false); 388 + mContextualItems.setNestedScrollingEnabled(false);
469 -// mAdapterContextual = new MoreContextualAdapter(this, mContextualList); 389 + mContextualItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
470 -// mContextualItems.setItemAnimator(null); 390 + mAdapterContextual = new MoreContextualAdapter(this, mContextualList);
471 -// mAdapterContextual.setHasStableIds(true); 391 + mContextualItems.setAdapter(mAdapterContextual);
472 -// mContextualItems.setAdapter(mAdapterContextual); 392 + mAdapterContextual.getPositionClicks()
473 -// mAdapterContextual.getPositionClicks() 393 + .doOnNext(this::handleMoreContextualItemClick)
474 -// .doOnNext(this::handleMoreContextualItemClick) 394 + .doOnError(error -> {
475 -// .doOnError(error -> { 395 + })
476 -// }) 396 + .subscribe();
477 -// .subscribe();
478 -// mAdapterContextual.notifyDataSetChanged();
479 -
480 - mAdapterContextual.updateData(mContextualList);
481 397
398 + mAdapterContextual.notifyDataSetChanged();
482 mLlContextualItems.setVisibility(View.VISIBLE); 399 mLlContextualItems.setVisibility(View.VISIBLE);
483 } 400 }
484 } 401 }
402 + });
485 } 403 }
486 404
487 private void handleMoreItemClick(Campaign moreItem) { 405 private void handleMoreItemClick(Campaign moreItem) {
......
...@@ -341,9 +341,9 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL ...@@ -341,9 +341,9 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
341 .setTitle(R.string.cos_dlg_cancel_unified_coupon_success_title) 341 .setTitle(R.string.cos_dlg_cancel_unified_coupon_success_title)
342 .setMessage(R.string.cos_dlg_cancel_unified_coupon_success_subtitle) 342 .setMessage(R.string.cos_dlg_cancel_unified_coupon_success_subtitle)
343 .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> { 343 .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
344 - dialogPositive.dismiss();
345 RefreshUnifiedCouponsEventModel couponsRefreshed = new RefreshUnifiedCouponsEventModel(); 344 RefreshUnifiedCouponsEventModel couponsRefreshed = new RefreshUnifiedCouponsEventModel();
346 EventBus.getDefault().post(new WarplyEventBusManager(couponsRefreshed)); 345 EventBus.getDefault().post(new WarplyEventBusManager(couponsRefreshed));
346 + dialogPositive.dismiss();
347 onBackPressed(); 347 onBackPressed();
348 }) 348 })
349 .setCancelable(false) 349 .setCancelable(false)
......
...@@ -2148,11 +2148,10 @@ public class WarplyManager { ...@@ -2148,11 +2148,10 @@ public class WarplyManager {
2148 if (tempUni.getStatus().trim().equals("active")) 2148 if (tempUni.getStatus().trim().equals("active"))
2149 couponList.add(tempUni); 2149 couponList.add(tempUni);
2150 } 2150 }
2151 - 2151 + }
2152 WarplyManagerHelper.setMarketCoupons(allCouponList); 2152 WarplyManagerHelper.setMarketCoupons(allCouponList);
2153 WarplyManagerHelper.setMarketCouponsList(couponList); 2153 WarplyManagerHelper.setMarketCouponsList(couponList);
2154 } 2154 }
2155 - }
2156 } catch (Exception e) { 2155 } catch (Exception e) {
2157 e.printStackTrace(); 2156 e.printStackTrace();
2158 } 2157 }
......