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();
180 - EventBus.getDefault().register(this); 176 + if (!EventBus.getDefault().isRegistered(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 - 338 +
405 - mAdapterResearch.updateData(mUniqueSectionList.get(firstKey)); 339 + mAdapterResearch.notifyDataSetChanged();
406 - 340 + mLlResearchItems.setVisibility(View.VISIBLE);
407 - mLlResearchItems.setVisibility(View.VISIBLE);
408 - }
409 - } catch (IndexOutOfBoundsException ex) {
410 - ex.printStackTrace();
411 } 341 }
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) { 347 +
418 - mTvExclusiveSection.setText(secondKey.substring(1)); 348 + if (itemKey.contains("2")) {
419 -// mExclusiveItems.setNestedScrollingEnabled(false); 349 + mTvExclusiveSection.setText(itemKey.substring(1));
420 -// mAdapterExclusive = new MoreCampaignAdapter(this, mUniqueSectionList.get(secondKey)); 350 + mExclusiveItems.setNestedScrollingEnabled(false);
421 -// mExclusiveItems.setItemAnimator(null); 351 + mExclusiveItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
422 -// mAdapterExclusive.setHasStableIds(true); 352 + mAdapterExclusive = new MoreCampaignAdapter(this, itemValue);
423 -// mExclusiveItems.setAdapter(mAdapterExclusive); 353 + mExclusiveItems.setAdapter(mAdapterExclusive);
424 -// mAdapterExclusive.getPositionClicks() 354 + mAdapterExclusive.getPositionClicks()
425 -// .doOnNext(this::handleMoreItemClick) 355 + .doOnNext(this::handleMoreItemClick)
426 -// .doOnError(error -> { 356 + .doOnError(error -> {
427 -// }) 357 + })
428 -// .subscribe(); 358 + .subscribe();
429 -// mAdapterExclusive.notifyDataSetChanged(); 359 +
430 - 360 + mAdapterExclusive.notifyDataSetChanged();
431 - mAdapterExclusive.updateData(mUniqueSectionList.get(secondKey)); 361 + mLlExclusiveItems.setVisibility(View.VISIBLE);
432 -
433 - mLlExclusiveItems.setVisibility(View.VISIBLE);
434 - }
435 - } catch (IndexOutOfBoundsException ex) {
436 - ex.printStackTrace();
437 } 362 }
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) { 368 +
444 - mTvContestSection.setText(thirdKey.substring(1)); 369 + if (itemKey.contains("3")) {
445 -// mContestItems.setNestedScrollingEnabled(false); 370 + mTvContestSection.setText(itemKey.substring(1));
446 -// mAdapterContest = new MoreCampaignAdapter(this, mUniqueSectionList.get(thirdKey)); 371 + mContestItems.setNestedScrollingEnabled(false);
447 -// mContestItems.setItemAnimator(null); 372 + mContestItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
448 -// mAdapterContest.setHasStableIds(true); 373 + mAdapterContest = new MoreCampaignAdapter(this, itemValue);
449 -// mContestItems.setAdapter(mAdapterContest); 374 + mContestItems.setAdapter(mAdapterContest);
450 -// mAdapterContest.getPositionClicks() 375 + mAdapterContest.getPositionClicks()
451 -// .doOnNext(this::handleMoreItemClick) 376 + .doOnNext(this::handleMoreItemClick)
452 -// .doOnError(error -> { 377 + .doOnError(error -> {
453 -// }) 378 + })
454 -// .subscribe(); 379 + .subscribe();
455 -// mAdapterContest.notifyDataSetChanged(); 380 +
456 - 381 + mAdapterContest.notifyDataSetChanged();
457 - mAdapterContest.updateData(mUniqueSectionList.get(thirdKey)); 382 + mLlContestItems.setVisibility(View.VISIBLE);
458 -
459 - mLlContestItems.setVisibility(View.VISIBLE);
460 - }
461 - } catch (IndexOutOfBoundsException ex) {
462 - ex.printStackTrace();
463 } 383 }
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,10 +2148,9 @@ public class WarplyManager { ...@@ -2148,10 +2148,9 @@ 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 -
2152 - WarplyManagerHelper.setMarketCoupons(allCouponList);
2153 - WarplyManagerHelper.setMarketCouponsList(couponList);
2154 } 2151 }
2152 + WarplyManagerHelper.setMarketCoupons(allCouponList);
2153 + WarplyManagerHelper.setMarketCouponsList(couponList);
2155 } 2154 }
2156 } catch (Exception e) { 2155 } catch (Exception e) {
2157 e.printStackTrace(); 2156 e.printStackTrace();
......