Showing
14 changed files
with
147 additions
and
105 deletions
... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
6 | 6 | ||
7 | # dev cosmote f83dfde1145e4c2da69793abb2f579af | 7 | # dev cosmote f83dfde1145e4c2da69793abb2f579af |
8 | # prod cosmote 0086a2088301440792091b9f814c2267 | 8 | # prod cosmote 0086a2088301440792091b9f814c2267 |
9 | -Uuid=d5f9038f46374666a1f4e1039d89f608 | 9 | +Uuid=f83dfde1145e4c2da69793abb2f579af |
10 | 10 | ||
11 | # If we need to see logs in Logcat | 11 | # If we need to see logs in Logcat |
12 | Debug=true | 12 | Debug=true |
... | @@ -16,7 +16,7 @@ Debug=true | ... | @@ -16,7 +16,7 @@ Debug=true |
16 | # Development: https://engage-stage.warp.ly | 16 | # Development: https://engage-stage.warp.ly |
17 | # DEH Production: https://engage-prod.dei.gr | 17 | # DEH Production: https://engage-prod.dei.gr |
18 | # DEH Development: https://engage-uat.dei.gr | 18 | # DEH Development: https://engage-uat.dei.gr |
19 | -BaseURL=https://engage-prod.dei.gr | 19 | +BaseURL=https://engage-stage.warp.ly |
20 | 20 | ||
21 | # For Verify Ticket request | 21 | # For Verify Ticket request |
22 | VerifyURL=/partners/cosmote/verify | 22 | VerifyURL=/partners/cosmote/verify | ... | ... |
... | @@ -503,12 +503,26 @@ public enum Warply { | ... | @@ -503,12 +503,26 @@ public enum Warply { |
503 | INSTANCE.registerWarplyInternal(); | 503 | INSTANCE.registerWarplyInternal(); |
504 | } | 504 | } |
505 | 505 | ||
506 | + public static void registerWarply(Context context) { | ||
507 | + INSTANCE.isInitializedOrThrow(); | ||
508 | + INSTANCE.registerWarplyInternal(context); | ||
509 | + } | ||
510 | + | ||
506 | private void registerWarplyInternal() { | 511 | private void registerWarplyInternal() { |
507 | isInitializedOrThrow(); | 512 | isInitializedOrThrow(); |
508 | if (!WarpUtils.isRegisteredWarply(mContext)) | 513 | if (!WarpUtils.isRegisteredWarply(mContext)) |
509 | wakeRegistrationTask(); | 514 | wakeRegistrationTask(); |
510 | } | 515 | } |
511 | 516 | ||
517 | + private void registerWarplyInternal(Context context) { | ||
518 | + isInitializedOrThrow(); | ||
519 | + if (!WarpUtils.isRegisteredWarply(mContext)) { | ||
520 | + if (!acquireRegisterLock()) | ||
521 | + return; | ||
522 | + registerToServerInternal(context); | ||
523 | + } | ||
524 | + } | ||
525 | + | ||
512 | /** | 526 | /** |
513 | * Method used to unregister from the Warply service. You also need to | 527 | * Method used to unregister from the Warply service. You also need to |
514 | * unregister from the GCM service, in order to stop receiving push | 528 | * unregister from the GCM service, in order to stop receiving push |
... | @@ -730,7 +744,7 @@ public enum Warply { | ... | @@ -730,7 +744,7 @@ public enum Warply { |
730 | return; | 744 | return; |
731 | } | 745 | } |
732 | if (!WarpUtils.isRegisteredWarply(context)) { | 746 | if (!WarpUtils.isRegisteredWarply(context)) { |
733 | - registerWarply(); | 747 | + registerWarply(context); |
734 | return; | 748 | return; |
735 | } | 749 | } |
736 | if (WarpUtils.getIsDEVICEINFOENABLED(context)) | 750 | if (WarpUtils.getIsDEVICEINFOENABLED(context)) |
... | @@ -1290,6 +1304,20 @@ public enum Warply { | ... | @@ -1290,6 +1304,20 @@ public enum Warply { |
1290 | }); | 1304 | }); |
1291 | } | 1305 | } |
1292 | 1306 | ||
1307 | + private void registerToServerInternal(Context context) { | ||
1308 | + WarpUtils.setLastDeviceInfo(mContext, ""); | ||
1309 | + WarpUtils.setLastApplicationData(mContext, ""); | ||
1310 | + WarpUtils.setLastApplicationUUID(mContext, WarplyProperty.getAppUuid(mContext)); | ||
1311 | + WarplyDBHelper.getInstance(mContext).deleteAllRequests(); | ||
1312 | + WarplyDBHelper.getInstance(mContext).deleteAllPushRequests(); | ||
1313 | + WarplyDBHelper.getInstance(mContext).deleteAllPushAckRequests(); | ||
1314 | + WarpUtils.setWebId(mContext, "deprecated"); | ||
1315 | + WarpUtils.setApiKey(mContext, ""); | ||
1316 | + if (mRegistrationListener != null) | ||
1317 | + mRegistrationListener.onSuccess(ServiceRegistrationCallback.REGISTERED_WARPLY); | ||
1318 | + releaseRegisterLock(); | ||
1319 | + } | ||
1320 | + | ||
1293 | private String buildWarplyRequestUrl(String warplyPath) { | 1321 | private String buildWarplyRequestUrl(String warplyPath) { |
1294 | StringBuilder sb = new StringBuilder(WarplyProperty.getBaseUrl(mContext) + WarpConstants.BASE_URL_MOBILE); | 1322 | StringBuilder sb = new StringBuilder(WarplyProperty.getBaseUrl(mContext) + WarpConstants.BASE_URL_MOBILE); |
1295 | sb.append(WarplyProperty.getAppUuid(mContext)).append("/") | 1323 | sb.append(WarplyProperty.getAppUuid(mContext)).append("/") | ... | ... |
... | @@ -7,25 +7,30 @@ import android.util.TypedValue; | ... | @@ -7,25 +7,30 @@ import android.util.TypedValue; |
7 | import android.view.View; | 7 | import android.view.View; |
8 | import android.widget.ImageView; | 8 | import android.widget.ImageView; |
9 | import android.widget.LinearLayout; | 9 | import android.widget.LinearLayout; |
10 | +import android.widget.RelativeLayout; | ||
10 | import android.widget.TextView; | 11 | import android.widget.TextView; |
11 | 12 | ||
12 | -import androidx.annotation.NonNull; | ||
13 | import androidx.recyclerview.widget.LinearLayoutManager; | 13 | import androidx.recyclerview.widget.LinearLayoutManager; |
14 | import androidx.recyclerview.widget.RecyclerView; | 14 | import androidx.recyclerview.widget.RecyclerView; |
15 | import androidx.viewpager2.widget.ViewPager2; | 15 | import androidx.viewpager2.widget.ViewPager2; |
16 | 16 | ||
17 | +import com.bumptech.glide.Glide; | ||
18 | +import com.bumptech.glide.load.engine.DiskCacheStrategy; | ||
19 | + | ||
17 | import java.util.ArrayList; | 20 | import java.util.ArrayList; |
18 | -import java.util.Arrays; | ||
19 | import java.util.List; | 21 | import java.util.List; |
20 | 22 | ||
21 | import ly.warp.sdk.R; | 23 | import ly.warp.sdk.R; |
22 | import ly.warp.sdk.io.adapters.BannerAdapter; | 24 | import ly.warp.sdk.io.adapters.BannerAdapter; |
23 | import ly.warp.sdk.io.adapters.OfferAdapter; | 25 | import ly.warp.sdk.io.adapters.OfferAdapter; |
26 | +import ly.warp.sdk.io.callbacks.CallbackReceiver; | ||
27 | +import ly.warp.sdk.io.models.Campaign; | ||
24 | import ly.warp.sdk.io.models.DummyDataProvider; | 28 | import ly.warp.sdk.io.models.DummyDataProvider; |
25 | import ly.warp.sdk.io.models.OfferCategory; | 29 | import ly.warp.sdk.io.models.OfferCategory; |
26 | import ly.warp.sdk.io.models.OfferItem; | 30 | import ly.warp.sdk.io.models.OfferItem; |
27 | import ly.warp.sdk.utils.WarpUtils; | 31 | import ly.warp.sdk.utils.WarpUtils; |
28 | import ly.warp.sdk.utils.WarplyManagerHelper; | 32 | import ly.warp.sdk.utils.WarplyManagerHelper; |
33 | +import ly.warp.sdk.utils.managers.WarplyManager; | ||
29 | import ly.warp.sdk.views.HorizontalSpaceItemDecoration; | 34 | import ly.warp.sdk.views.HorizontalSpaceItemDecoration; |
30 | 35 | ||
31 | public class HomeActivity extends Activity implements View.OnClickListener, OfferAdapter.OnOfferClickListener { | 36 | public class HomeActivity extends Activity implements View.OnClickListener, OfferAdapter.OnOfferClickListener { |
... | @@ -36,6 +41,9 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -36,6 +41,9 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
36 | // =========================================================== | 41 | // =========================================================== |
37 | // Fields | 42 | // Fields |
38 | // =========================================================== | 43 | // =========================================================== |
44 | + | ||
45 | + private RelativeLayout mPbLoading; | ||
46 | + | ||
39 | private ViewPager2 mBannerViewPager; | 47 | private ViewPager2 mBannerViewPager; |
40 | private BannerAdapter mBannerAdapter; | 48 | private BannerAdapter mBannerAdapter; |
41 | private LinearLayout mDotsContainer; | 49 | private LinearLayout mDotsContainer; |
... | @@ -88,16 +96,18 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -88,16 +96,18 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
88 | setContentView(R.layout.activity_home); | 96 | setContentView(R.layout.activity_home); |
89 | 97 | ||
90 | initViews(); | 98 | initViews(); |
99 | + mPbLoading.setVisibility(View.VISIBLE); | ||
100 | + WarplyManager.getCampaigns(mCampaignsCallback); | ||
91 | 101 | ||
92 | // Setup all category sections | 102 | // Setup all category sections |
93 | - setupTopOffersSection(); | 103 | +// setupTopOffersSection(); |
94 | - setupFavoritesSection(); | 104 | +// setupFavoritesSection(); |
95 | - setupViabilitySection(); | 105 | +// setupViabilitySection(); |
96 | - setupFamilySection(); | 106 | +// setupFamilySection(); |
97 | - setupFoodCoffeeSection(); | 107 | +// setupFoodCoffeeSection(); |
98 | - setupTravellingSection(); | 108 | +// setupTravellingSection(); |
99 | - setupKidsSection(); | 109 | +// setupKidsSection(); |
100 | - setupPurchasesSection(); | 110 | +// setupPurchasesSection(); |
101 | } | 111 | } |
102 | 112 | ||
103 | @Override | 113 | @Override |
... | @@ -130,8 +140,8 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -130,8 +140,8 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
130 | // =========================================================== | 140 | // =========================================================== |
131 | 141 | ||
132 | private void initViews() { | 142 | private void initViews() { |
133 | - // Initialize banner carousel | 143 | + mPbLoading = findViewById(R.id.pb_loading); |
134 | - setupBannerCarousel(); | 144 | + mPbLoading.setOnTouchListener((v, event) -> true); |
135 | 145 | ||
136 | mIvProfile = findViewById(R.id.profile_icon); | 146 | mIvProfile = findViewById(R.id.profile_icon); |
137 | mIvProfile.setOnClickListener(this); | 147 | mIvProfile.setOnClickListener(this); |
... | @@ -411,18 +421,18 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -411,18 +421,18 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
411 | mBannerViewPager = findViewById(R.id.banner_viewpager); | 421 | mBannerViewPager = findViewById(R.id.banner_viewpager); |
412 | mDotsContainer = findViewById(R.id.dots_container); | 422 | mDotsContainer = findViewById(R.id.dots_container); |
413 | 423 | ||
414 | - // Setup adapter with 5 banner images | 424 | + mBannerAdapter = new BannerAdapter(this, WarplyManagerHelper.getCampaignList()); |
415 | - List<Integer> bannerImages = getBannerImages(); | 425 | + mBannerAdapter.setOnBannerClickListener(campaign -> { |
416 | - List<String> bannerUrls = getBannerUrls(); | 426 | + startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(campaign))); |
417 | - mBannerAdapter = new BannerAdapter(this, bannerImages); | ||
418 | - mBannerAdapter.setOnBannerClickListener(position -> { | ||
419 | - startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(bannerUrls.get(position)))); | ||
420 | }); | 427 | }); |
421 | 428 | ||
429 | + // Set the number of pages to preload for adjacent items | ||
430 | + mBannerViewPager.setOffscreenPageLimit(5); | ||
431 | + | ||
422 | mBannerViewPager.setAdapter(mBannerAdapter); | 432 | mBannerViewPager.setAdapter(mBannerAdapter); |
423 | 433 | ||
424 | // Setup pagination dots | 434 | // Setup pagination dots |
425 | - setupPaginationDots(bannerImages.size()); | 435 | + setupPaginationDots(WarplyManagerHelper.getCampaignList().size()); |
426 | 436 | ||
427 | // Handle page changes | 437 | // Handle page changes |
428 | mBannerViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { | 438 | mBannerViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() { |
... | @@ -434,27 +444,6 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -434,27 +444,6 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
434 | } | 444 | } |
435 | 445 | ||
436 | /** | 446 | /** |
437 | - * Returns a list of banner image resource IDs | ||
438 | - */ | ||
439 | - private List<Integer> getBannerImages() { | ||
440 | - return Arrays.asList( | ||
441 | - R.drawable.demo_home_banner2, | ||
442 | - R.drawable.demo_home_banner4, | ||
443 | - R.drawable.demo_home_banner3, | ||
444 | - R.drawable.demo_home_banner1 | ||
445 | - ); | ||
446 | - } | ||
447 | - | ||
448 | - private List<String> getBannerUrls() { | ||
449 | - return Arrays.asList( | ||
450 | - "https://warply.s3.amazonaws.com/dei/campaigns/match_dev/index.html", | ||
451 | - "https://warply.s3.amazonaws.com/dei/campaigns/questionnaire_dev/index.html", | ||
452 | - "https://warply.s3.amazonaws.com/dei/campaigns/tesla_dev/index.html", | ||
453 | - "https://warply.s3.amazonaws.com/dei/campaigns/EnergySaverContest_dev/index.html" | ||
454 | - ); | ||
455 | - } | ||
456 | - | ||
457 | - /** | ||
458 | * Sets up the pagination dots | 447 | * Sets up the pagination dots |
459 | * | 448 | * |
460 | * @param count Number of dots to display | 449 | * @param count Number of dots to display |
... | @@ -496,4 +485,27 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe | ... | @@ -496,4 +485,27 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe |
496 | mDots.get(i).setImageResource(i == position ? R.drawable.dot_active : R.drawable.dot_inactive); | 485 | mDots.get(i).setImageResource(i == position ? R.drawable.dot_active : R.drawable.dot_inactive); |
497 | } | 486 | } |
498 | } | 487 | } |
488 | + | ||
489 | + private CallbackReceiver<ArrayList<Campaign>> mCampaignsCallback = new CallbackReceiver<ArrayList<Campaign>>() { | ||
490 | + @Override | ||
491 | + public void onSuccess(ArrayList<Campaign> result) { | ||
492 | + mPbLoading.setVisibility(View.GONE); | ||
493 | + if (result != null && !result.isEmpty()) { | ||
494 | + // Preloads the campaigns' images | ||
495 | + result.forEach(campaign -> { | ||
496 | + Glide.with(getApplicationContext()) | ||
497 | + .load(campaign.getLogoUrl()) | ||
498 | + .diskCacheStrategy(DiskCacheStrategy.DATA) | ||
499 | + .preload(); | ||
500 | + }); | ||
501 | + | ||
502 | + setupBannerCarousel(); | ||
503 | + } | ||
504 | + } | ||
505 | + | ||
506 | + @Override | ||
507 | + public void onFailure(int errorCode) { | ||
508 | + mPbLoading.setVisibility(View.GONE); | ||
509 | + } | ||
510 | + }; | ||
499 | } | 511 | } | ... | ... |
... | @@ -38,8 +38,8 @@ public class HomeFragment extends Fragment implements View.OnClickListener { | ... | @@ -38,8 +38,8 @@ public class HomeFragment extends Fragment implements View.OnClickListener { |
38 | 38 | ||
39 | // 6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826 | 39 | // 6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826 |
40 | // prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282, live 3000136179 | 40 | // prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282, live 3000136179 |
41 | - mPbLoading.setVisibility(View.VISIBLE); | 41 | +// mPbLoading.setVisibility(View.VISIBLE); |
42 | - WarplyManager.getDehUser("aggeliki@warp.ly", mLoginReceiver); | 42 | +// WarplyManager.getDehUser("aggeliki@warp.ly", mLoginReceiver); |
43 | } | 43 | } |
44 | 44 | ||
45 | @Override | 45 | @Override |
... | @@ -49,16 +49,6 @@ public class HomeFragment extends Fragment implements View.OnClickListener { | ... | @@ -49,16 +49,6 @@ public class HomeFragment extends Fragment implements View.OnClickListener { |
49 | 49 | ||
50 | @Override | 50 | @Override |
51 | public void onClick(View view) { | 51 | public void onClick(View view) { |
52 | -// if (view.getId() == R.id.ll_auth_login) { | ||
53 | -// //6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826, 7000000831 shared coupons | ||
54 | -// //prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282, live 3000136179 | ||
55 | -//// mPbLoading.setVisibility(View.VISIBLE); | ||
56 | -//// WarplyManager.getDehUser(mEtGuid.getText().toString(), mLoginReceiver); | ||
57 | -// | ||
58 | -// Intent myIntent = new Intent(getContext(), HomeActivity.class); | ||
59 | -// startActivity(myIntent); | ||
60 | -// return; | ||
61 | -// } | ||
62 | // if (view.getId() == R.id.ll_auth_logout) { | 52 | // if (view.getId() == R.id.ll_auth_logout) { |
63 | // mPbLoading.setVisibility(View.VISIBLE); | 53 | // mPbLoading.setVisibility(View.VISIBLE); |
64 | // WarplyManager.logout(mLogoutReceiver); | 54 | // WarplyManager.logout(mLogoutReceiver); | ... | ... |
... | @@ -9,23 +9,27 @@ import android.widget.ImageView; | ... | @@ -9,23 +9,27 @@ import android.widget.ImageView; |
9 | import androidx.annotation.NonNull; | 9 | import androidx.annotation.NonNull; |
10 | import androidx.recyclerview.widget.RecyclerView; | 10 | import androidx.recyclerview.widget.RecyclerView; |
11 | 11 | ||
12 | -import java.util.List; | 12 | +import com.bumptech.glide.Glide; |
13 | +import com.bumptech.glide.load.engine.DiskCacheStrategy; | ||
14 | + | ||
15 | +import java.util.ArrayList; | ||
13 | 16 | ||
14 | import ly.warp.sdk.R; | 17 | import ly.warp.sdk.R; |
18 | +import ly.warp.sdk.io.models.Campaign; | ||
15 | 19 | ||
16 | public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerViewHolder> { | 20 | public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerViewHolder> { |
17 | 21 | ||
18 | private final Context mContext; | 22 | private final Context mContext; |
19 | - private final List<Integer> mBannerImages; | 23 | + private final ArrayList<Campaign> mCampaigns; |
20 | private OnBannerClickListener mListener; | 24 | private OnBannerClickListener mListener; |
21 | 25 | ||
22 | public interface OnBannerClickListener { | 26 | public interface OnBannerClickListener { |
23 | - void onBannerClick(int position); | 27 | + void onBannerClick(Campaign campaign); |
24 | } | 28 | } |
25 | 29 | ||
26 | - public BannerAdapter(Context context, List<Integer> bannerImages) { | 30 | + public BannerAdapter(Context context, ArrayList<Campaign> campaigns) { |
27 | this.mContext = context; | 31 | this.mContext = context; |
28 | - this.mBannerImages = bannerImages; | 32 | + this.mCampaigns = campaigns; |
29 | } | 33 | } |
30 | 34 | ||
31 | public void setOnBannerClickListener(OnBannerClickListener listener) { | 35 | public void setOnBannerClickListener(OnBannerClickListener listener) { |
... | @@ -41,18 +45,27 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView | ... | @@ -41,18 +45,27 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView |
41 | 45 | ||
42 | @Override | 46 | @Override |
43 | public void onBindViewHolder(@NonNull BannerViewHolder holder, int position) { | 47 | public void onBindViewHolder(@NonNull BannerViewHolder holder, int position) { |
44 | - holder.imageView.setImageResource(mBannerImages.get(position)); | 48 | + Campaign campaignItem = mCampaigns.get(position); |
49 | + | ||
50 | + Glide.with(mContext) | ||
51 | +// .setDefaultRequestOptions( | ||
52 | +// RequestOptions | ||
53 | +// .placeholderOf(R.drawable.demo_logo) | ||
54 | +// .error(R.drawable.demo_logo)) | ||
55 | + .load(campaignItem.getLogoUrl()) | ||
56 | + .diskCacheStrategy(DiskCacheStrategy.DATA) | ||
57 | + .into(holder.imageView); | ||
45 | 58 | ||
46 | holder.itemView.setOnClickListener(v -> { | 59 | holder.itemView.setOnClickListener(v -> { |
47 | if (mListener != null) { | 60 | if (mListener != null) { |
48 | - mListener.onBannerClick(position); | 61 | + mListener.onBannerClick(campaignItem); |
49 | } | 62 | } |
50 | }); | 63 | }); |
51 | } | 64 | } |
52 | 65 | ||
53 | @Override | 66 | @Override |
54 | public int getItemCount() { | 67 | public int getItemCount() { |
55 | - return mBannerImages.size(); | 68 | + return mCampaigns.size(); |
56 | } | 69 | } |
57 | 70 | ||
58 | static class BannerViewHolder extends RecyclerView.ViewHolder { | 71 | static class BannerViewHolder extends RecyclerView.ViewHolder { | ... | ... |
... | @@ -66,6 +66,10 @@ public class WarplyManagerHelper { | ... | @@ -66,6 +66,10 @@ public class WarplyManagerHelper { |
66 | mCampaignListAll.addAll(campaignList); | 66 | mCampaignListAll.addAll(campaignList); |
67 | } | 67 | } |
68 | 68 | ||
69 | + public static ArrayList<Campaign> getCampaignList() { | ||
70 | + return mCampaignListAll; | ||
71 | + } | ||
72 | + | ||
69 | public static void setCouponRedeemedList(CouponList couponRedeemedList) { | 73 | public static void setCouponRedeemedList(CouponList couponRedeemedList) { |
70 | mCouponRedeemedList.clear(); | 74 | mCouponRedeemedList.clear(); |
71 | mCouponRedeemedList.addAll(couponRedeemedList); | 75 | mCouponRedeemedList.addAll(couponRedeemedList); | ... | ... |
... | @@ -353,49 +353,20 @@ public class WarplyManager { | ... | @@ -353,49 +353,20 @@ public class WarplyManager { |
353 | }); | 353 | }); |
354 | } | 354 | } |
355 | 355 | ||
356 | - private static ArrayList<Campaign> mergeCampaignResults(ArrayList<Campaign> resultCampaigns, ArrayList<Campaign> resultPersonalizedCampaigns, JSONObject resultCampaignsAvailability) { | 356 | + private static ArrayList<Campaign> mergeCampaignResults(ArrayList<Campaign> resultCampaigns, ArrayList<Campaign> resultPersonalizedCampaigns) { |
357 | ArrayList<Campaign> newCampaignList = new ArrayList<Campaign>(); | 357 | ArrayList<Campaign> newCampaignList = new ArrayList<Campaign>(); |
358 | ArrayList<Campaign> campaignLoyaltyList = new ArrayList<>(); | 358 | ArrayList<Campaign> campaignLoyaltyList = new ArrayList<>(); |
359 | - newCampaignList.clear(); | 359 | + if (resultCampaigns != null && !resultCampaigns.isEmpty()) |
360 | - if (resultCampaigns != null && resultCampaigns.size() > 0) | ||
361 | newCampaignList.addAll(resultCampaigns); | 360 | newCampaignList.addAll(resultCampaigns); |
362 | - if (resultPersonalizedCampaigns != null && resultPersonalizedCampaigns.size() > 0) | 361 | + if (resultPersonalizedCampaigns != null && !resultPersonalizedCampaigns.isEmpty()) |
363 | newCampaignList.addAll(resultPersonalizedCampaigns); | 362 | newCampaignList.addAll(resultPersonalizedCampaigns); |
364 | 363 | ||
365 | - if (newCampaignList != null && newCampaignList.size() > 0) { | 364 | + if (newCampaignList != null && !newCampaignList.isEmpty()) { |
366 | - Collections.sort(newCampaignList, (obj1, obj2) -> Integer.compare(obj1.getSorting(), obj2.getSorting())); | 365 | + newCampaignList.sort((obj1, obj2) -> Integer.compare(obj1.getSorting(), obj2.getSorting())); |
367 | - campaignLoyaltyList.clear(); | ||
368 | - for (Campaign camp : newCampaignList) { | ||
369 | - if (resultCampaignsAvailability != null && resultCampaignsAvailability.length() > 0) { | ||
370 | - JSONObject campaignSettings = WarpJSONParser.getJSONFromString(camp.getCampaignTypeSettings()); | ||
371 | - if (campaignSettings != null) { | ||
372 | - if (campaignSettings.has("couponset")) { | ||
373 | - String cpnUuid = campaignSettings.optString("couponset"); | ||
374 | - if (resultCampaignsAvailability.has(cpnUuid)) { | ||
375 | - camp.setCouponAvailability(resultCampaignsAvailability.optInt(cpnUuid)); | ||
376 | - } | ||
377 | - } | ||
378 | - } | ||
379 | - } | ||
380 | 366 | ||
381 | - try { | 367 | + Set<Campaign> set = new LinkedHashSet<>(newCampaignList); |
382 | - JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); | ||
383 | - if (extraFields != null) { | ||
384 | - if (extraFields.length() == 0 || !(extraFields.has("ccms_offer") || extraFields.has("type"))) { | ||
385 | - if (camp.getCouponAvailability() == null || camp.getCouponAvailability() != 0) | ||
386 | - campaignLoyaltyList.add(camp); | ||
387 | - } | ||
388 | - } | ||
389 | - } catch (Exception exception) { | ||
390 | - if (camp.getCouponAvailability() == null || camp.getCouponAvailability() != 0) | ||
391 | - campaignLoyaltyList.add(camp); | ||
392 | - } | ||
393 | - } | ||
394 | - WarplyManagerHelper.setCampaignList(newCampaignList); | ||
395 | - | ||
396 | - Set<Campaign> set = new LinkedHashSet<>(campaignLoyaltyList); | ||
397 | - campaignLoyaltyList.clear(); | ||
398 | campaignLoyaltyList.addAll(set); | 368 | campaignLoyaltyList.addAll(set); |
369 | + WarplyManagerHelper.setCampaignList(campaignLoyaltyList); | ||
399 | } | 370 | } |
400 | 371 | ||
401 | return campaignLoyaltyList; | 372 | return campaignLoyaltyList; |
... | @@ -444,14 +415,12 @@ public class WarplyManager { | ... | @@ -444,14 +415,12 @@ public class WarplyManager { |
444 | ListenableFuture<ArrayList<Campaign>> futureCampaigns = getCampaignsRetro(service); | 415 | ListenableFuture<ArrayList<Campaign>> futureCampaigns = getCampaignsRetro(service); |
445 | SettableFuture<ArrayList<Campaign>> futurePersonalized = SettableFuture.create(); | 416 | SettableFuture<ArrayList<Campaign>> futurePersonalized = SettableFuture.create(); |
446 | ListenableFuture<ArrayList<Campaign>> futurePersonalizedCampaigns = getCampaignsPersonalizedRetro(service, 0, futurePersonalized); | 417 | ListenableFuture<ArrayList<Campaign>> futurePersonalizedCampaigns = getCampaignsPersonalizedRetro(service, 0, futurePersonalized); |
447 | - ListenableFuture<JSONObject> futureCampaignAvailability = getCampaignAvailability(service); | ||
448 | 418 | ||
449 | - ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureCampaigns, futurePersonalizedCampaigns, futureCampaignAvailability); | 419 | + ListenableFuture<List<Object>> allResultsFuture = Futures.allAsList(futureCampaigns, futurePersonalizedCampaigns); |
450 | ListenableFuture<ArrayList<Campaign>> mergedResultFuture = Futures.transformAsync(allResultsFuture, results -> { | 420 | ListenableFuture<ArrayList<Campaign>> mergedResultFuture = Futures.transformAsync(allResultsFuture, results -> { |
451 | ArrayList<Campaign> resultCampaigns = (ArrayList<Campaign>) results.get(0); | 421 | ArrayList<Campaign> resultCampaigns = (ArrayList<Campaign>) results.get(0); |
452 | ArrayList<Campaign> resultPersonalizedCampaigns = (ArrayList<Campaign>) results.get(1); | 422 | ArrayList<Campaign> resultPersonalizedCampaigns = (ArrayList<Campaign>) results.get(1); |
453 | - JSONObject resultCampaignsAvailability = (JSONObject) results.get(2); | 423 | + return executorService.submit(() -> mergeCampaignResults(resultCampaigns, resultPersonalizedCampaigns)); |
454 | - return executorService.submit(() -> mergeCampaignResults(resultCampaigns, resultPersonalizedCampaigns, resultCampaignsAvailability)); | ||
455 | }, executorService); | 424 | }, executorService); |
456 | 425 | ||
457 | Futures.addCallback(mergedResultFuture, new FutureCallback<ArrayList<Campaign>>() { | 426 | Futures.addCallback(mergedResultFuture, new FutureCallback<ArrayList<Campaign>>() { |
... | @@ -734,6 +703,10 @@ public class WarplyManager { | ... | @@ -734,6 +703,10 @@ public class WarplyManager { |
734 | } | 703 | } |
735 | } | 704 | } |
736 | }); | 705 | }); |
706 | + } else if (response.code() == 502) { | ||
707 | +// receiver.onFailure(response.code()); | ||
708 | +// future.set(new ArrayList<Campaign>()); | ||
709 | + future.set(new ArrayList<Campaign>()); | ||
737 | } else { | 710 | } else { |
738 | // receiver.onFailure(response.code()); | 711 | // receiver.onFailure(response.code()); |
739 | // future.set(new ArrayList<Campaign>()); | 712 | // future.set(new ArrayList<Campaign>()); | ... | ... |

84.9 KB

96.3 KB
... | @@ -78,6 +78,28 @@ | ... | @@ -78,6 +78,28 @@ |
78 | app:layout_constraintBottom_toBottomOf="parent" | 78 | app:layout_constraintBottom_toBottomOf="parent" |
79 | app:layout_constraintEnd_toEndOf="parent" | 79 | app:layout_constraintEnd_toEndOf="parent" |
80 | app:layout_constraintStart_toStartOf="parent" /> | 80 | app:layout_constraintStart_toStartOf="parent" /> |
81 | + | ||
82 | + <RelativeLayout | ||
83 | + android:id="@+id/pb_loading" | ||
84 | + android:layout_width="wrap_content" | ||
85 | + android:layout_height="wrap_content" | ||
86 | + android:background="@android:color/transparent" | ||
87 | + app:layout_constraintStart_toStartOf="@+id/banner_viewpager" | ||
88 | + app:layout_constraintEnd_toEndOf="@+id/banner_viewpager" | ||
89 | + app:layout_constraintTop_toTopOf="@+id/banner_viewpager" | ||
90 | + app:layout_constraintBottom_toBottomOf="@+id/banner_viewpager" | ||
91 | + android:translationZ="100dp" | ||
92 | + android:visibility="gone" | ||
93 | + tools:visibility="visible"> | ||
94 | + | ||
95 | + <ProgressBar | ||
96 | + android:layout_width="48dp" | ||
97 | + android:layout_height="48dp" | ||
98 | + android:layout_centerInParent="true" | ||
99 | + android:indeterminate="true" | ||
100 | + android:indeterminateTint="@color/custom_light_blue" | ||
101 | + android:indeterminateTintMode="src_atop" /> | ||
102 | + </RelativeLayout> | ||
81 | </androidx.constraintlayout.widget.ConstraintLayout> | 103 | </androidx.constraintlayout.widget.ConstraintLayout> |
82 | 104 | ||
83 | <!-- Top Offers Section --> | 105 | <!-- Top Offers Section --> | ... | ... |
... | @@ -22,7 +22,7 @@ | ... | @@ -22,7 +22,7 @@ |
22 | android:id="@+id/user_img" | 22 | android:id="@+id/user_img" |
23 | android:layout_width="60dp" | 23 | android:layout_width="60dp" |
24 | android:layout_height="60dp" | 24 | android:layout_height="60dp" |
25 | - android:src="@drawable/demo_logo_small" | 25 | + android:src="@drawable/demo_profile" |
26 | app:layout_constraintStart_toStartOf="parent" | 26 | app:layout_constraintStart_toStartOf="parent" |
27 | app:layout_constraintTop_toTopOf="parent" /> | 27 | app:layout_constraintTop_toTopOf="parent" /> |
28 | 28 | ... | ... |
... | @@ -8,7 +8,7 @@ | ... | @@ -8,7 +8,7 @@ |
8 | android:id="@+id/iv_banner" | 8 | android:id="@+id/iv_banner" |
9 | android:layout_width="match_parent" | 9 | android:layout_width="match_parent" |
10 | android:layout_height="match_parent" | 10 | android:layout_height="match_parent" |
11 | - android:scaleType="fitXY" | 11 | + android:scaleType="centerCrop" |
12 | app:layout_constraintBottom_toBottomOf="parent" | 12 | app:layout_constraintBottom_toBottomOf="parent" |
13 | app:layout_constraintEnd_toEndOf="parent" | 13 | app:layout_constraintEnd_toEndOf="parent" |
14 | app:layout_constraintStart_toStartOf="parent" | 14 | app:layout_constraintStart_toStartOf="parent" | ... | ... |
-
Please register or login to post a comment