Merge branch 'cosmote' of https://git.warp.ly/open-source/warply_android_sdk_mav…
…en_plugin into cosmote
Showing
1 changed file
with
40 additions
and
0 deletions
... | @@ -4,13 +4,21 @@ import android.os.Bundle; | ... | @@ -4,13 +4,21 @@ import android.os.Bundle; |
4 | 4 | ||
5 | import androidx.fragment.app.Fragment; | 5 | import androidx.fragment.app.Fragment; |
6 | 6 | ||
7 | +import java.util.ArrayList; | ||
8 | +import java.util.HashMap; | ||
9 | + | ||
10 | +import ly.warp.sdk.Warply; | ||
7 | import ly.warp.sdk.io.callbacks.CallbackReceiver; | 11 | import ly.warp.sdk.io.callbacks.CallbackReceiver; |
12 | +import ly.warp.sdk.io.models.Campaign; | ||
13 | +import ly.warp.sdk.io.models.CampaignList; | ||
8 | import ly.warp.sdk.io.models.Consumer; | 14 | import ly.warp.sdk.io.models.Consumer; |
9 | import ly.warp.sdk.io.request.WarplyConsumerRequest; | 15 | import ly.warp.sdk.io.request.WarplyConsumerRequest; |
16 | +import ly.warp.sdk.io.request.WarplyInboxRequest; | ||
10 | import ly.warp.sdk.utils.managers.WarplyManager; | 17 | import ly.warp.sdk.utils.managers.WarplyManager; |
11 | 18 | ||
12 | public class BaseFragment extends Fragment { | 19 | public class BaseFragment extends Fragment { |
13 | private static Consumer mConsumer; | 20 | private static Consumer mConsumer; |
21 | + private static HashMap mUniqueCampaignList = new HashMap<String, CampaignList>(); | ||
14 | 22 | ||
15 | @Override | 23 | @Override |
16 | public void onCreate(Bundle savedInstanceState) { | 24 | public void onCreate(Bundle savedInstanceState) { |
... | @@ -21,6 +29,12 @@ public class BaseFragment extends Fragment { | ... | @@ -21,6 +29,12 @@ public class BaseFragment extends Fragment { |
21 | WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerReceiver); | 29 | WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerReceiver); |
22 | } | 30 | } |
23 | }).start(); | 31 | }).start(); |
32 | + | ||
33 | + new Thread(() -> { | ||
34 | + if (!Thread.currentThread().isInterrupted()) { | ||
35 | + Warply.getInbox(new WarplyInboxRequest().setUseCache(false), mInboxReceiver); | ||
36 | + } | ||
37 | + }).start(); | ||
24 | } | 38 | } |
25 | 39 | ||
26 | 40 | ||
... | @@ -45,4 +59,30 @@ public class BaseFragment extends Fragment { | ... | @@ -45,4 +59,30 @@ public class BaseFragment extends Fragment { |
45 | Thread.currentThread().interrupt(); | 59 | Thread.currentThread().interrupt(); |
46 | } | 60 | } |
47 | }; | 61 | }; |
62 | + | ||
63 | + private final CallbackReceiver<CampaignList> mInboxReceiver = | ||
64 | + new CallbackReceiver<CampaignList>() { | ||
65 | + @Override | ||
66 | + public void onSuccess(CampaignList result) { | ||
67 | + for (Campaign campaign : result) { | ||
68 | + if (mUniqueCampaignList.containsKey(campaign.getOfferCategory().trim())) { | ||
69 | + CampaignList tempCampaignList = (CampaignList) mUniqueCampaignList.get(campaign.getOfferCategory().trim()); | ||
70 | + tempCampaignList.add(campaign); | ||
71 | + mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList); | ||
72 | + } else { | ||
73 | + CampaignList tempCampaignList = new CampaignList(); | ||
74 | + tempCampaignList.add(campaign); | ||
75 | + mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList); | ||
76 | + } | ||
77 | + } | ||
78 | + | ||
79 | + Thread.currentThread().interrupt(); | ||
80 | + } | ||
81 | + | ||
82 | + @Override | ||
83 | + public void onFailure(int errorCode) { | ||
84 | + Thread.currentThread().interrupt(); | ||
85 | + } | ||
86 | + }; | ||
87 | + | ||
48 | } | 88 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment