Showing
15 changed files
with
470 additions
and
174 deletions
| ... | @@ -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-cosbeta26' | 5 | + PUBLISH_VERSION = '4.5.4-cosbeta27' |
| 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
| 7 | } | 7 | } |
| 8 | 8 | ||
| ... | @@ -34,42 +34,42 @@ android { | ... | @@ -34,42 +34,42 @@ android { |
| 34 | 34 | ||
| 35 | dependencies { | 35 | dependencies { |
| 36 | //------------------------------ Support -----------------------------// | 36 | //------------------------------ Support -----------------------------// |
| 37 | - api 'androidx.appcompat:appcompat:1.4.1' | 37 | + implementation 'androidx.appcompat:appcompat:1.4.1' |
| 38 | - api 'androidx.recyclerview:recyclerview:1.2.1' | 38 | + implementation 'androidx.recyclerview:recyclerview:1.2.1' |
| 39 | - api 'androidx.cardview:cardview:1.0.0' | 39 | + implementation 'androidx.cardview:cardview:1.0.0' |
| 40 | api "androidx.security:security-crypto:1.1.0-alpha03" // For minSDK 23 use 1.0.0, for minSDK 21 use 1.1.0 that is currently in alpha | 40 | api "androidx.security:security-crypto:1.1.0-alpha03" // For minSDK 23 use 1.0.0, for minSDK 21 use 1.1.0 that is currently in alpha |
| 41 | api 'org.altbeacon:android-beacon-library:2.19.3' | 41 | api 'org.altbeacon:android-beacon-library:2.19.3' |
| 42 | api 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' | 42 | api 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2' |
| 43 | - api 'de.hdodenhof:circleimageview:3.1.0' | 43 | + implementation 'de.hdodenhof:circleimageview:3.1.0' |
| 44 | api group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.2.21' | 44 | api group: 'io.reactivex.rxjava2', name: 'rxjava', version: '2.2.21' |
| 45 | - api 'com.google.android.material:material:1.5.0' | 45 | + implementation 'com.google.android.material:material:1.5.0' |
| 46 | api group: 'com.google.zxing', name: 'core', version: '3.4.1' | 46 | api group: 'com.google.zxing', name: 'core', version: '3.4.1' |
| 47 | api group: 'com.google.zxing', name: 'javase', version: '3.4.1' | 47 | api group: 'com.google.zxing', name: 'javase', version: '3.4.1' |
| 48 | api 'com.github.siyamed:android-shape-imageview:0.9.3' | 48 | api 'com.github.siyamed:android-shape-imageview:0.9.3' |
| 49 | - api 'org.greenrobot:eventbus:3.3.1' | 49 | + implementation 'org.greenrobot:eventbus:3.3.1' |
| 50 | 50 | ||
| 51 | //------------------------------ Firebase -----------------------------// | 51 | //------------------------------ Firebase -----------------------------// |
| 52 | api platform('com.google.firebase:firebase-bom:29.0.3') | 52 | api platform('com.google.firebase:firebase-bom:29.0.3') |
| 53 | - api 'com.google.firebase:firebase-messaging' | 53 | + implementation 'com.google.firebase:firebase-messaging' |
| 54 | 54 | ||
| 55 | //------------------------------ GMS -----------------------------// | 55 | //------------------------------ GMS -----------------------------// |
| 56 | api 'com.google.android.gms:play-services-base:18.0.1' | 56 | api 'com.google.android.gms:play-services-base:18.0.1' |
| 57 | - api 'com.google.android.gms:play-services-location:19.0.1' | 57 | + implementation 'com.google.android.gms:play-services-location:19.0.1' |
| 58 | - api 'com.google.android.gms:play-services-maps:18.0.2' | 58 | + implementation 'com.google.android.gms:play-services-maps:18.0.2' |
| 59 | api 'com.google.maps.android:android-maps-utils:0.5' | 59 | api 'com.google.maps.android:android-maps-utils:0.5' |
| 60 | 60 | ||
| 61 | //------------------------------ Work Manager -----------------------------// | 61 | //------------------------------ Work Manager -----------------------------// |
| 62 | api 'androidx.work:work-runtime:2.7.1' | 62 | api 'androidx.work:work-runtime:2.7.1' |
| 63 | 63 | ||
| 64 | //------------------------------ Glide -----------------------------// | 64 | //------------------------------ Glide -----------------------------// |
| 65 | - api 'com.github.bumptech.glide:glide:4.12.0' | 65 | + implementation 'com.github.bumptech.glide:glide:4.12.0' |
| 66 | annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' | 66 | annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0' |
| 67 | 67 | ||
| 68 | //------------------------------ Huawei -----------------------------// | 68 | //------------------------------ Huawei -----------------------------// |
| 69 | - api 'com.huawei.agconnect:agconnect-core:1.6.5.300' | 69 | + implementation 'com.huawei.agconnect:agconnect-core:1.6.5.300' |
| 70 | - api 'com.huawei.hms:base:6.4.0.302' | 70 | + implementation 'com.huawei.hms:base:6.4.0.302' |
| 71 | - api 'com.huawei.hms:push:6.3.0.304' | 71 | + implementation 'com.huawei.hms:push:6.3.0.304' |
| 72 | - api 'com.huawei.hms:ads-identifier:3.4.39.302' | 72 | + implementation 'com.huawei.hms:ads-identifier:3.4.39.302' |
| 73 | 73 | ||
| 74 | //------------------------------ SQLCipher -----------------------------// | 74 | //------------------------------ SQLCipher -----------------------------// |
| 75 | api "net.zetetic:android-database-sqlcipher:4.5.0" | 75 | api "net.zetetic:android-database-sqlcipher:4.5.0" | ... | ... |
| ... | @@ -471,7 +471,7 @@ public enum Warply { | ... | @@ -471,7 +471,7 @@ public enum Warply { |
| 471 | INSTANCE.getInboxInternal(new CallbackReceiver<CampaignList>() { | 471 | INSTANCE.getInboxInternal(new CallbackReceiver<CampaignList>() { |
| 472 | @Override | 472 | @Override |
| 473 | public void onSuccess(CampaignList result) { | 473 | public void onSuccess(CampaignList result) { |
| 474 | - WarplyManagerHelper.setUniqueCampaignList(result); | 474 | + WarplyManagerHelper.setCampaignList(result); |
| 475 | if (result.size() >= 0) { | 475 | if (result.size() >= 0) { |
| 476 | objectSerializer.serialize(result, File.separator + requestSignature); | 476 | objectSerializer.serialize(result, File.separator + requestSignature); |
| 477 | warplyPreferences.saveInboxLastCachedTimeStamp(requestSignature, System.currentTimeMillis()); | 477 | warplyPreferences.saveInboxLastCachedTimeStamp(requestSignature, System.currentTimeMillis()); | ... | ... |
| ... | @@ -193,8 +193,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -193,8 +193,7 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation |
| 193 | 193 | ||
| 194 | // Thread.currentThread().interrupt(); | 194 | // Thread.currentThread().interrupt(); |
| 195 | 195 | ||
| 196 | - WarplyManager.getCouponsets(new WarplyGetCouponsetsRequest() | 196 | + WarplyManager.getUserCouponsWithCouponsets(new WarplyUserCouponsRequest(), mUserCouponsReceiver); |
| 197 | - .setLanguage(WarplyProperty.getLanguage(BaseFragmentActivity.this)), mCouponsetsReceiver); | ||
| 198 | 197 | ||
| 199 | } | 198 | } |
| 200 | 199 | ||
| ... | @@ -204,18 +203,6 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation | ... | @@ -204,18 +203,6 @@ public class BaseFragmentActivity extends FragmentActivity implements Navigation |
| 204 | } | 203 | } |
| 205 | }; | 204 | }; |
| 206 | 205 | ||
| 207 | - private CallbackReceiver<CouponsetsList> mCouponsetsReceiver = new CallbackReceiver<CouponsetsList>() { | ||
| 208 | - @Override | ||
| 209 | - public void onSuccess(CouponsetsList result) { | ||
| 210 | - WarplyManager.getUserCoupons(new WarplyUserCouponsRequest(), mUserCouponsReceiver); | ||
| 211 | - } | ||
| 212 | - | ||
| 213 | - @Override | ||
| 214 | - public void onFailure(int errorCode) { | ||
| 215 | - Thread.currentThread().interrupt(); | ||
| 216 | - } | ||
| 217 | - }; | ||
| 218 | - | ||
| 219 | 206 | ||
| 220 | private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() { | 207 | private final CallbackReceiver<CouponList> mUserCouponsReceiver = new CallbackReceiver<CouponList>() { |
| 221 | @Override | 208 | @Override | ... | ... |
| ... | @@ -13,6 +13,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; | ... | @@ -13,6 +13,7 @@ import androidx.recyclerview.widget.LinearLayoutManager; |
| 13 | import androidx.recyclerview.widget.RecyclerView; | 13 | import androidx.recyclerview.widget.RecyclerView; |
| 14 | 14 | ||
| 15 | import org.greenrobot.eventbus.EventBus; | 15 | import org.greenrobot.eventbus.EventBus; |
| 16 | +import org.json.JSONObject; | ||
| 16 | 17 | ||
| 17 | import java.util.ArrayList; | 18 | import java.util.ArrayList; |
| 18 | import java.util.HashMap; | 19 | import java.util.HashMap; |
| ... | @@ -49,9 +50,8 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -49,9 +50,8 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
| 49 | private ArrayList<MergedGifts> mData = new ArrayList(); | 50 | private ArrayList<MergedGifts> mData = new ArrayList(); |
| 50 | private RecyclerView mRecyclerMergedGifts; | 51 | private RecyclerView mRecyclerMergedGifts; |
| 51 | private MergedGiftsAdapter mAdapterMergedGifts; | 52 | private MergedGiftsAdapter mAdapterMergedGifts; |
| 52 | - | ||
| 53 | private ArrayList<Campaign> mValuesList = new ArrayList<>(); | 53 | private ArrayList<Campaign> mValuesList = new ArrayList<>(); |
| 54 | - private HashSet<Campaign> mHashSetList = new HashSet<>(); | 54 | + // private HashSet<Campaign> mHashSetList = new HashSet<>(); |
| 55 | private ArrayList<LoyaltyGiftsForYouPackage> mSeasonalList = new ArrayList<>(); | 55 | private ArrayList<LoyaltyGiftsForYouPackage> mSeasonalList = new ArrayList<>(); |
| 56 | private HashSet<LoyaltyGiftsForYouPackage> mHashSetSeasonalList = new HashSet<>(); | 56 | private HashSet<LoyaltyGiftsForYouPackage> mHashSetSeasonalList = new HashSet<>(); |
| 57 | 57 | ||
| ... | @@ -64,11 +64,13 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -64,11 +64,13 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
| 64 | super.onCreate(savedInstanceState); | 64 | super.onCreate(savedInstanceState); |
| 65 | setContentView(R.layout.activity_gifts_for_you); | 65 | setContentView(R.layout.activity_gifts_for_you); |
| 66 | 66 | ||
| 67 | - if (WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you").size() > 0) { | 67 | +// if (WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you").size() > 0) { |
| 68 | - mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you")); | 68 | +// mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you")); |
| 69 | - mValuesList.clear(); | 69 | +// mValuesList.clear(); |
| 70 | - mValuesList.addAll(mHashSetList); | 70 | +// mValuesList.addAll(mHashSetList); |
| 71 | - } | 71 | +// } |
| 72 | + | ||
| 73 | + filterItems(); | ||
| 72 | 74 | ||
| 73 | if (WarplyManagerHelper.getSeasonalList() != null && WarplyManagerHelper.getSeasonalList().size() > 0) { | 75 | if (WarplyManagerHelper.getSeasonalList() != null && WarplyManagerHelper.getSeasonalList().size() > 0) { |
| 74 | mHashSetSeasonalList.addAll(WarplyManagerHelper.getSeasonalList()); | 76 | mHashSetSeasonalList.addAll(WarplyManagerHelper.getSeasonalList()); |
| ... | @@ -114,7 +116,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -114,7 +116,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
| 114 | 116 | ||
| 115 | private void initViews() { | 117 | private void initViews() { |
| 116 | mIvBack.setOnClickListener(this); | 118 | mIvBack.setOnClickListener(this); |
| 117 | - mTvTitle.setText(getIntent().getStringExtra("title")); | ||
| 118 | mIvPopupClose.setOnClickListener(this); | 119 | mIvPopupClose.setOnClickListener(this); |
| 119 | 120 | ||
| 120 | // if (WarpUtils.getGiftsPopup(this)) | 121 | // if (WarpUtils.getGiftsPopup(this)) |
| ... | @@ -130,21 +131,19 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -130,21 +131,19 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
| 130 | EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyGiftsForYouOfferClickEvent())); | 131 | EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltyGiftsForYouOfferClickEvent())); |
| 131 | 132 | ||
| 132 | try { | 133 | try { |
| 133 | - String key = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()).keys().next(); | 134 | + JSONObject extraFields = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()); |
| 134 | - if (!TextUtils.isEmpty(key) && key.equals("ccms_offer")) { | 135 | + if (extraFields != null) { |
| 135 | - String value = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()).optString(key); | 136 | + if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { |
| 136 | - if (!TextUtils.isEmpty(value) && value.equals("true")) { | ||
| 137 | for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | 137 | for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { |
| 138 | if (ccms.getLoyaltyCampaignId().equals(dataItem.getCampaign().getSessionUUID())) { | 138 | if (ccms.getLoyaltyCampaignId().equals(dataItem.getCampaign().getSessionUUID())) { |
| 139 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms))); | 139 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms))); |
| 140 | - return; | 140 | + break; |
| 141 | } | 141 | } |
| 142 | } | 142 | } |
| 143 | } else { | 143 | } else { |
| 144 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | 144 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); |
| 145 | } | 145 | } |
| 146 | } | 146 | } |
| 147 | - startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | ||
| 148 | } catch (Exception exception) { | 147 | } catch (Exception exception) { |
| 149 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | 148 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); |
| 150 | } | 149 | } |
| ... | @@ -175,7 +174,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -175,7 +174,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
| 175 | } | 174 | } |
| 176 | 175 | ||
| 177 | if (seasonalList != null && seasonalList.size() > 0) { | 176 | if (seasonalList != null && seasonalList.size() > 0) { |
| 178 | - Log.v("GIFTS_FOR_YOU", String.valueOf(seasonalList.size())); | 177 | + Log.v("SEASONAL", String.valueOf(seasonalList.size())); |
| 179 | for (LoyaltyGiftsForYouPackage seasonal : seasonalList) { | 178 | for (LoyaltyGiftsForYouPackage seasonal : seasonalList) { |
| 180 | MergedGifts data = new MergedGifts(); | 179 | MergedGifts data = new MergedGifts(); |
| 181 | data.setCampaign(null); | 180 | data.setCampaign(null); |
| ... | @@ -186,6 +185,58 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -186,6 +185,58 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
| 186 | } | 185 | } |
| 187 | } | 186 | } |
| 188 | 187 | ||
| 188 | + private void filterItems() { | ||
| 189 | + ArrayList<Campaign> gfyList = new ArrayList<>(); | ||
| 190 | + if (WarplyManagerHelper.getCampaignList() != null && WarplyManagerHelper.getCampaignList().size() > 0) { | ||
| 191 | + Log.v("Got L:{" + String.valueOf(WarplyManagerHelper.getCampaignList().size()) + "}", " LOYALTY campaigns"); | ||
| 192 | + if (WarplyManagerHelper.getCCMSLoyaltyCampaigns() == null || WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() == 0) { | ||
| 193 | + Log.v("Got C:{0}", " CCMS campaigns"); | ||
| 194 | + for (Campaign camp : WarplyManagerHelper.getCampaignList()) { | ||
| 195 | + if (camp.getOfferCategory().equals("gifts_for_you")) { | ||
| 196 | + try { | ||
| 197 | + JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); | ||
| 198 | + if (extraFields != null) { | ||
| 199 | + if (extraFields.length() == 0 || !extraFields.has("ccms_offer") || !(extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true"))) { | ||
| 200 | + gfyList.add(camp); | ||
| 201 | + } | ||
| 202 | + } | ||
| 203 | + } catch (Exception exception) { | ||
| 204 | + gfyList.add(camp); | ||
| 205 | + } | ||
| 206 | + } | ||
| 207 | + } | ||
| 208 | + } else { | ||
| 209 | + int ccmsCount = 0; | ||
| 210 | + Log.v("Got C:{" + String.valueOf(WarplyManagerHelper.getCCMSLoyaltyCampaigns().size()) + "}", " CCMS campaigns"); | ||
| 211 | + for (Campaign camp : WarplyManagerHelper.getCampaignList()) { | ||
| 212 | + if (camp.getOfferCategory().equals("gifts_for_you")) { | ||
| 213 | + try { | ||
| 214 | + JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); | ||
| 215 | + if (extraFields != null) { | ||
| 216 | + if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { | ||
| 217 | + for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | ||
| 218 | + if (ccms.getLoyaltyCampaignId().equals(camp.getSessionUUID())) { | ||
| 219 | + gfyList.add(camp); | ||
| 220 | + ccmsCount++; | ||
| 221 | + break; | ||
| 222 | + } | ||
| 223 | + } | ||
| 224 | + } else { | ||
| 225 | + gfyList.add(camp); | ||
| 226 | + } | ||
| 227 | + } | ||
| 228 | + } catch (Exception exception) { | ||
| 229 | + gfyList.add(camp); | ||
| 230 | + } | ||
| 231 | + } | ||
| 232 | + } | ||
| 233 | + Log.v("Got M:{" + String.valueOf(ccmsCount) + "}", " Matched campaigns"); | ||
| 234 | + } | ||
| 235 | + | ||
| 236 | + mValuesList.addAll(gfyList); | ||
| 237 | + } | ||
| 238 | + } | ||
| 239 | + | ||
| 189 | // =========================================================== | 240 | // =========================================================== |
| 190 | // Inner and Anonymous Classes | 241 | // Inner and Anonymous Classes |
| 191 | // =========================================================== | 242 | // =========================================================== | ... | ... |
| ... | @@ -12,13 +12,17 @@ import androidx.recyclerview.widget.LinearLayoutManager; | ... | @@ -12,13 +12,17 @@ import androidx.recyclerview.widget.LinearLayoutManager; |
| 12 | import androidx.recyclerview.widget.RecyclerView; | 12 | import androidx.recyclerview.widget.RecyclerView; |
| 13 | 13 | ||
| 14 | import org.greenrobot.eventbus.EventBus; | 14 | import org.greenrobot.eventbus.EventBus; |
| 15 | +import org.json.JSONObject; | ||
| 15 | 16 | ||
| 16 | import java.util.ArrayList; | 17 | import java.util.ArrayList; |
| 17 | import java.util.HashSet; | 18 | import java.util.HashSet; |
| 18 | 19 | ||
| 19 | import ly.warp.sdk.R; | 20 | import ly.warp.sdk.R; |
| 20 | import ly.warp.sdk.io.models.Campaign; | 21 | import ly.warp.sdk.io.models.Campaign; |
| 22 | +import ly.warp.sdk.io.models.CampaignList; | ||
| 23 | +import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; | ||
| 21 | import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; | 24 | import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; |
| 25 | +import ly.warp.sdk.utils.WarpJSONParser; | ||
| 22 | import ly.warp.sdk.utils.WarpUtils; | 26 | import ly.warp.sdk.utils.WarpUtils; |
| 23 | import ly.warp.sdk.utils.WarplyManagerHelper; | 27 | import ly.warp.sdk.utils.WarplyManagerHelper; |
| 24 | import ly.warp.sdk.utils.managers.WarplyEventBusManager; | 28 | import ly.warp.sdk.utils.managers.WarplyEventBusManager; |
| ... | @@ -41,7 +45,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -41,7 +45,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 41 | private MoreCampaignAdapter mAdapterMore; | 45 | private MoreCampaignAdapter mAdapterMore; |
| 42 | private LinearLayout mLlMorePopup; | 46 | private LinearLayout mLlMorePopup; |
| 43 | private ArrayList<Campaign> mValuesList = new ArrayList<>(); | 47 | private ArrayList<Campaign> mValuesList = new ArrayList<>(); |
| 44 | - private HashSet<Campaign> mHashSetList = new HashSet<>(); | 48 | +// private HashSet<Campaign> mHashSetList = new HashSet<>(); |
| 45 | 49 | ||
| 46 | // =========================================================== | 50 | // =========================================================== |
| 47 | // Methods for/from SuperClass/Interfaces | 51 | // Methods for/from SuperClass/Interfaces |
| ... | @@ -59,12 +63,13 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -59,12 +63,13 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 59 | 63 | ||
| 60 | mRecyclerMore = findViewById(R.id.rv_more_items); | 64 | mRecyclerMore = findViewById(R.id.rv_more_items); |
| 61 | 65 | ||
| 66 | +// if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) { | ||
| 67 | +// mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("more_for_you")); | ||
| 68 | +// mValuesList.clear(); | ||
| 69 | +// mValuesList.addAll(mHashSetList); | ||
| 70 | +// } | ||
| 62 | 71 | ||
| 63 | - if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) { | 72 | + filterItems(); |
| 64 | - mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("more_for_you")); | ||
| 65 | - mValuesList.clear(); | ||
| 66 | - mValuesList.addAll(mHashSetList); | ||
| 67 | - } | ||
| 68 | 73 | ||
| 69 | initViews(); | 74 | initViews(); |
| 70 | } | 75 | } |
| ... | @@ -92,7 +97,6 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -92,7 +97,6 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 92 | 97 | ||
| 93 | private void initViews() { | 98 | private void initViews() { |
| 94 | mIvBack.setOnClickListener(this); | 99 | mIvBack.setOnClickListener(this); |
| 95 | - mTvTitle.setText(getIntent().getStringExtra("title")); | ||
| 96 | mIvPopupClose.setOnClickListener(this); | 100 | mIvPopupClose.setOnClickListener(this); |
| 97 | 101 | ||
| 98 | // if (WarpUtils.getMorePopup(this)) | 102 | // if (WarpUtils.getMorePopup(this)) |
| ... | @@ -106,7 +110,24 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -106,7 +110,24 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 106 | mAdapterMore.getPositionClicks() | 110 | mAdapterMore.getPositionClicks() |
| 107 | .doOnNext(gift -> { | 111 | .doOnNext(gift -> { |
| 108 | EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltySDKFirebaseEventModel())); | 112 | EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltySDKFirebaseEventModel())); |
| 113 | + | ||
| 114 | + try { | ||
| 115 | + JSONObject extraFields = WarpJSONParser.getJSONFromString(gift.getExtraFields()); | ||
| 116 | + if (extraFields != null) { | ||
| 117 | + if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { | ||
| 118 | + for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | ||
| 119 | + if (ccms.getLoyaltyCampaignId().equals(gift.getSessionUUID())) { | ||
| 120 | + startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(gift, ccms))); | ||
| 121 | + break; | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + } else { | ||
| 125 | + startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(gift))); | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + } catch (Exception exception) { | ||
| 109 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(gift))); | 129 | startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(gift))); |
| 130 | + } | ||
| 110 | }) | 131 | }) |
| 111 | .doOnError(error -> { | 132 | .doOnError(error -> { |
| 112 | }) | 133 | }) |
| ... | @@ -116,6 +137,58 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -116,6 +137,58 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 116 | } | 137 | } |
| 117 | } | 138 | } |
| 118 | 139 | ||
| 140 | + private void filterItems() { | ||
| 141 | + ArrayList<Campaign> gfyList = new ArrayList<>(); | ||
| 142 | + if (WarplyManagerHelper.getCampaignList() != null && WarplyManagerHelper.getCampaignList().size() > 0) { | ||
| 143 | + Log.v("Got L:{" + String.valueOf(WarplyManagerHelper.getCampaignList().size()) + "}", " LOYALTY campaigns"); | ||
| 144 | + if (WarplyManagerHelper.getCCMSLoyaltyCampaigns() == null || WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() == 0) { | ||
| 145 | + Log.v("Got C:{0}", " CCMS campaigns"); | ||
| 146 | + for (Campaign camp : WarplyManagerHelper.getCampaignList()) { | ||
| 147 | + if (camp.getOfferCategory().equals("more_for_you")) { | ||
| 148 | + try { | ||
| 149 | + JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); | ||
| 150 | + if (extraFields != null) { | ||
| 151 | + if (extraFields.length() == 0 || !extraFields.has("ccms_offer") || !(extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true"))) { | ||
| 152 | + gfyList.add(camp); | ||
| 153 | + } | ||
| 154 | + } | ||
| 155 | + } catch (Exception exception) { | ||
| 156 | + gfyList.add(camp); | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + } else { | ||
| 161 | + int ccmsCount = 0; | ||
| 162 | + Log.v("Got C:{" + String.valueOf(WarplyManagerHelper.getCCMSLoyaltyCampaigns().size()) + "}", " CCMS campaigns"); | ||
| 163 | + for (Campaign camp : WarplyManagerHelper.getCampaignList()) { | ||
| 164 | + if (camp.getOfferCategory().equals("more_for_you")) { | ||
| 165 | + try { | ||
| 166 | + JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); | ||
| 167 | + if (extraFields != null) { | ||
| 168 | + if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { | ||
| 169 | + for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | ||
| 170 | + if (ccms.getLoyaltyCampaignId().equals(camp.getSessionUUID())) { | ||
| 171 | + gfyList.add(camp); | ||
| 172 | + ccmsCount++; | ||
| 173 | + break; | ||
| 174 | + } | ||
| 175 | + } | ||
| 176 | + } else { | ||
| 177 | + gfyList.add(camp); | ||
| 178 | + } | ||
| 179 | + } | ||
| 180 | + } catch (Exception exception) { | ||
| 181 | + gfyList.add(camp); | ||
| 182 | + } | ||
| 183 | + } | ||
| 184 | + } | ||
| 185 | + Log.v("Got M:{" + String.valueOf(ccmsCount) + "}", " Matched campaigns"); | ||
| 186 | + } | ||
| 187 | + | ||
| 188 | + mValuesList.addAll(gfyList); | ||
| 189 | + } | ||
| 190 | + } | ||
| 191 | + | ||
| 119 | // =========================================================== | 192 | // =========================================================== |
| 120 | // Inner and Anonymous Classes | 193 | // Inner and Anonymous Classes |
| 121 | // =========================================================== | 194 | // =========================================================== | ... | ... |
| ... | @@ -122,17 +122,16 @@ public class WarpViewActivity extends WarpBaseActivity { | ... | @@ -122,17 +122,16 @@ public class WarpViewActivity extends WarpBaseActivity { |
| 122 | 122 | ||
| 123 | @Subscribe() | 123 | @Subscribe() |
| 124 | public void onMessageEvent(WarplyEventBusManager event) { | 124 | public void onMessageEvent(WarplyEventBusManager event) { |
| 125 | - EventBus.getDefault().unregister(this); | 125 | +// EventBus.getDefault().unregister(this); |
| 126 | if (event.getQuestionnaire() != null) { | 126 | if (event.getQuestionnaire() != null) { |
| 127 | - EventBus.getDefault().post(new WarplyEventBusManager(event.getQuestionnaire())); | 127 | + setResult(RESULT_OK, new Intent()); |
| 128 | - setResult(RESULT_OK,new Intent()); | 128 | + finish(); |
| 129 | } | 129 | } |
| 130 | if (event.getCoupon() != null) | 130 | if (event.getCoupon() != null) |
| 131 | - EventBus.getDefault().post(new WarplyEventBusManager(event.getCoupon())); | 131 | + finish(); |
| 132 | if (event.getPacingCard() != null) | 132 | if (event.getPacingCard() != null) |
| 133 | - EventBus.getDefault().post(new WarplyEventBusManager(event.getPacingCard())); | 133 | + finish(); |
| 134 | if (event.getPacingService() != null) | 134 | if (event.getPacingService() != null) |
| 135 | - EventBus.getDefault().post(new WarplyEventBusManager(event.getPacingService())); | ||
| 136 | finish(); | 135 | finish(); |
| 137 | } | 136 | } |
| 138 | 137 | ... | ... |
| ... | @@ -14,11 +14,16 @@ import androidx.fragment.app.Fragment; | ... | @@ -14,11 +14,16 @@ import androidx.fragment.app.Fragment; |
| 14 | import androidx.recyclerview.widget.LinearLayoutManager; | 14 | import androidx.recyclerview.widget.LinearLayoutManager; |
| 15 | import androidx.recyclerview.widget.RecyclerView; | 15 | import androidx.recyclerview.widget.RecyclerView; |
| 16 | 16 | ||
| 17 | +import org.json.JSONObject; | ||
| 18 | + | ||
| 17 | import ly.warp.sdk.R; | 19 | import ly.warp.sdk.R; |
| 18 | import ly.warp.sdk.activities.GiftsForYouActivity; | 20 | import ly.warp.sdk.activities.GiftsForYouActivity; |
| 19 | import ly.warp.sdk.activities.LoyaltyWallet; | 21 | import ly.warp.sdk.activities.LoyaltyWallet; |
| 20 | import ly.warp.sdk.activities.MoreForYouActivity; | 22 | import ly.warp.sdk.activities.MoreForYouActivity; |
| 21 | import ly.warp.sdk.activities.WarpViewActivity; | 23 | import ly.warp.sdk.activities.WarpViewActivity; |
| 24 | +import ly.warp.sdk.io.models.Campaign; | ||
| 25 | +import ly.warp.sdk.io.models.CampaignList; | ||
| 26 | +import ly.warp.sdk.utils.WarpJSONParser; | ||
| 22 | import ly.warp.sdk.utils.WarplyManagerHelper; | 27 | import ly.warp.sdk.utils.WarplyManagerHelper; |
| 23 | import ly.warp.sdk.views.adapters.ProfileCampaignAdapter; | 28 | import ly.warp.sdk.views.adapters.ProfileCampaignAdapter; |
| 24 | 29 | ||
| ... | @@ -66,28 +71,35 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener { | ... | @@ -66,28 +71,35 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener { |
| 66 | mIvMore = view.findViewById(R.id.iv_more3); | 71 | mIvMore = view.findViewById(R.id.iv_more3); |
| 67 | mIvMore.setOnClickListener(this); | 72 | mIvMore.setOnClickListener(this); |
| 68 | 73 | ||
| 69 | - mClDealsOuter = view.findViewById(R.id.cl_recycler_inner); | 74 | +// mClDealsOuter = view.findViewById(R.id.cl_recycler_inner); |
| 70 | - mRecyclerDeals = view.findViewById(R.id.rv_deals); | 75 | +// mRecyclerDeals = view.findViewById(R.id.rv_deals); |
| 71 | - if (WarplyManagerHelper.getUniqueCampaignList().get("deals_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("deals_for_you").size() > 0) { | 76 | +// if (WarplyManagerHelper.getUniqueCampaignList().get("deals_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("deals_for_you").size() > 0) { |
| 72 | - mRecyclerDeals.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); | 77 | +// mRecyclerDeals.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); |
| 73 | - mAdapterDeals = new ProfileCampaignAdapter(getContext(), WarplyManagerHelper.getUniqueCampaignList().get("deals_for_you")); | 78 | +// mAdapterDeals = new ProfileCampaignAdapter(getContext(), WarplyManagerHelper.getUniqueCampaignList().get("deals_for_you")); |
| 74 | - mRecyclerDeals.setAdapter(mAdapterDeals); | 79 | +// mRecyclerDeals.setAdapter(mAdapterDeals); |
| 75 | - mAdapterDeals.getPositionClicks() | 80 | +// mAdapterDeals.getPositionClicks() |
| 76 | - .doOnNext(deal -> { | 81 | +// .doOnNext(deal -> { |
| 77 | - startActivity(WarpViewActivity.createIntentFromURL(getContext(), WarplyManagerHelper.constructCampaignUrl(deal))); | 82 | +// startActivity(WarpViewActivity.createIntentFromURL(getContext(), WarplyManagerHelper.constructCampaignUrl(deal))); |
| 78 | - }) | 83 | +// }) |
| 79 | - .doOnError(error -> { | 84 | +// .doOnError(error -> { |
| 80 | - }) | 85 | +// }) |
| 81 | - .subscribe(); | 86 | +// .subscribe(); |
| 82 | - } else { | 87 | +// } else { |
| 83 | - mClDealsOuter.setVisibility(View.GONE); | 88 | +// mClDealsOuter.setVisibility(View.GONE); |
| 84 | - } | 89 | +// } |
| 85 | 90 | ||
| 86 | mClGiftsOuter = view.findViewById(R.id.cl_recycler_inner2); | 91 | mClGiftsOuter = view.findViewById(R.id.cl_recycler_inner2); |
| 87 | mRecyclerGifts = view.findViewById(R.id.rv_gifts); | 92 | mRecyclerGifts = view.findViewById(R.id.rv_gifts); |
| 88 | - if (WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you").size() > 0) { | 93 | + if (WarplyManagerHelper.getCampaignList() != null && WarplyManagerHelper.getCampaignList().size() > 0) { |
| 94 | + CampaignList gfyList = new CampaignList(); | ||
| 95 | + for (Campaign camp : WarplyManagerHelper.getCampaignList()) { | ||
| 96 | + if (camp.getOfferCategory().equals("gifts_for_you")) { | ||
| 97 | + gfyList.add(camp); | ||
| 98 | + } | ||
| 99 | + } | ||
| 100 | + | ||
| 89 | mRecyclerGifts.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); | 101 | mRecyclerGifts.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); |
| 90 | - mAdapterGifts = new ProfileCampaignAdapter(getContext(), WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you")); | 102 | + mAdapterGifts = new ProfileCampaignAdapter(getContext(), gfyList); |
| 91 | mRecyclerGifts.setAdapter(mAdapterGifts); | 103 | mRecyclerGifts.setAdapter(mAdapterGifts); |
| 92 | mAdapterGifts.getPositionClicks() | 104 | mAdapterGifts.getPositionClicks() |
| 93 | .doOnNext(gift -> { | 105 | .doOnNext(gift -> { |
| ... | @@ -102,9 +114,16 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener { | ... | @@ -102,9 +114,16 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener { |
| 102 | 114 | ||
| 103 | mClMoreOuter = view.findViewById(R.id.cl_recycler_inner3); | 115 | mClMoreOuter = view.findViewById(R.id.cl_recycler_inner3); |
| 104 | mRecyclerMore = view.findViewById(R.id.rv_more); | 116 | mRecyclerMore = view.findViewById(R.id.rv_more); |
| 105 | - if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) { | 117 | + if (WarplyManagerHelper.getCampaignList() != null && WarplyManagerHelper.getCampaignList().size() > 0) { |
| 118 | + CampaignList mfyList = new CampaignList(); | ||
| 119 | + for (Campaign camp : WarplyManagerHelper.getCampaignList()) { | ||
| 120 | + if (camp.getOfferCategory().equals("more_for_you")) { | ||
| 121 | + mfyList.add(camp); | ||
| 122 | + } | ||
| 123 | + } | ||
| 124 | + | ||
| 106 | mRecyclerMore.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); | 125 | mRecyclerMore.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); |
| 107 | - mAdapterMore = new ProfileCampaignAdapter(getContext(), WarplyManagerHelper.getUniqueCampaignList().get("more_for_you")); | 126 | + mAdapterMore = new ProfileCampaignAdapter(getContext(), mfyList); |
| 108 | mRecyclerMore.setAdapter(mAdapterMore); | 127 | mRecyclerMore.setAdapter(mAdapterMore); |
| 109 | mAdapterMore.getPositionClicks() | 128 | mAdapterMore.getPositionClicks() |
| 110 | .doOnNext(more -> { | 129 | .doOnNext(more -> { |
| ... | @@ -127,15 +146,12 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener { | ... | @@ -127,15 +146,12 @@ public class LoyaltyFragment extends Fragment implements View.OnClickListener { |
| 127 | } | 146 | } |
| 128 | if (view.getId() == R.id.iv_more2) { | 147 | if (view.getId() == R.id.iv_more2) { |
| 129 | Intent intent = new Intent(getContext(), GiftsForYouActivity.class); | 148 | Intent intent = new Intent(getContext(), GiftsForYouActivity.class); |
| 130 | - intent.putExtra("title", getString(R.string.cos_gifts_title)); | ||
| 131 | startActivity(intent); | 149 | startActivity(intent); |
| 132 | return; | 150 | return; |
| 133 | } | 151 | } |
| 134 | if (view.getId() == R.id.iv_more3) { | 152 | if (view.getId() == R.id.iv_more3) { |
| 135 | Intent intent = new Intent(getContext(), MoreForYouActivity.class); | 153 | Intent intent = new Intent(getContext(), MoreForYouActivity.class); |
| 136 | - intent.putExtra("title", getString(R.string.cos_more_title)); | ||
| 137 | startActivity(intent); | 154 | startActivity(intent); |
| 138 | - return; | ||
| 139 | } | 155 | } |
| 140 | } | 156 | } |
| 141 | 157 | ... | ... |
| ... | @@ -128,6 +128,44 @@ public class Consumer implements Parcelable, Serializable { | ... | @@ -128,6 +128,44 @@ public class Consumer implements Parcelable, Serializable { |
| 128 | this(new JSONObject(json)); | 128 | this(new JSONObject(json)); |
| 129 | } | 129 | } |
| 130 | 130 | ||
| 131 | + public Consumer() { | ||
| 132 | + this.ackOptin = false; | ||
| 133 | + this.billingInfo = new JSONObject(); | ||
| 134 | + this.birthday = ""; | ||
| 135 | + this.burntPoints = 0.0d; | ||
| 136 | + this.companyName = ""; | ||
| 137 | + this.consumerMetadata = new JSONObject(); | ||
| 138 | + this.displayName = ""; | ||
| 139 | + this.email = ""; | ||
| 140 | + this.firstName = ""; | ||
| 141 | + this.gender = ""; | ||
| 142 | + this.imageUrl = ""; | ||
| 143 | + this.language = ""; | ||
| 144 | + this.lastName =""; | ||
| 145 | + this.loyaltyId = ""; | ||
| 146 | + this.msisdn = ""; | ||
| 147 | + this.nameday = ""; | ||
| 148 | + this.nickname = ""; | ||
| 149 | + this.optin = new JSONObject(); | ||
| 150 | + if (this.optin != null) { | ||
| 151 | + this.newsletter = false; | ||
| 152 | + this.sms = false; | ||
| 153 | + this.segmentation = false; | ||
| 154 | + this.sms_segmentation = false; | ||
| 155 | + } | ||
| 156 | + this.passwordSet = false; | ||
| 157 | + this.profileMetadata = ""; | ||
| 158 | + this.redeemedPoints = 0.0d; | ||
| 159 | + this.retrievedPoints = 0.0d; | ||
| 160 | + this.salutation = ""; | ||
| 161 | + this.subscribe = false; | ||
| 162 | + this.tags = new JSONObject(); | ||
| 163 | + this.taxId = ""; | ||
| 164 | + this.userPoints = 0.0d; | ||
| 165 | + this.uuid = ""; | ||
| 166 | + this.verified = false; | ||
| 167 | + } | ||
| 168 | + | ||
| 131 | /** | 169 | /** |
| 132 | * Constructor used to create an Object from a given JSON Object | 170 | * Constructor used to create an Object from a given JSON Object |
| 133 | * | 171 | * | ... | ... |
| ... | @@ -301,6 +301,14 @@ public class PacingDetails { | ... | @@ -301,6 +301,14 @@ public class PacingDetails { |
| 301 | // ================================================================================ | 301 | // ================================================================================ |
| 302 | 302 | ||
| 303 | 303 | ||
| 304 | + public boolean isEnabled() { | ||
| 305 | + return enabled; | ||
| 306 | + } | ||
| 307 | + | ||
| 308 | + public void setEnabled(boolean enabled) { | ||
| 309 | + this.enabled = enabled; | ||
| 310 | + } | ||
| 311 | + | ||
| 304 | public PacingInner getSteps() { | 312 | public PacingInner getSteps() { |
| 305 | return steps; | 313 | return steps; |
| 306 | } | 314 | } | ... | ... |
| ... | @@ -38,6 +38,10 @@ public class WarplyIntegrationRequest { | ... | @@ -38,6 +38,10 @@ public class WarplyIntegrationRequest { |
| 38 | 38 | ||
| 39 | private HashMap<String, String> mFilters; | 39 | private HashMap<String, String> mFilters; |
| 40 | private long mCacheUpdateInterval = 0; | 40 | private long mCacheUpdateInterval = 0; |
| 41 | + private boolean isNonTelco = false; | ||
| 42 | + private boolean hasAcceptedConsent = false; | ||
| 43 | + private String guid = ""; | ||
| 44 | + private ArrayList<String> phoneList = new ArrayList<>(); | ||
| 41 | 45 | ||
| 42 | // =========================================================== | 46 | // =========================================================== |
| 43 | // Constructor | 47 | // Constructor |
| ... | @@ -83,6 +87,26 @@ public class WarplyIntegrationRequest { | ... | @@ -83,6 +87,26 @@ public class WarplyIntegrationRequest { |
| 83 | // Getter & Setter | 87 | // Getter & Setter |
| 84 | // =========================================================== | 88 | // =========================================================== |
| 85 | 89 | ||
| 90 | + public WarplyIntegrationRequest setIsNoTelco(boolean isNonTelco) { | ||
| 91 | + isNonTelco = isNonTelco; | ||
| 92 | + return this; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + public WarplyIntegrationRequest setHasAcceptedConsent(boolean hasAcceptedConsent) { | ||
| 96 | + hasAcceptedConsent = hasAcceptedConsent; | ||
| 97 | + return this; | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + public WarplyIntegrationRequest setMsisdnList(ArrayList<String> phoneList) { | ||
| 101 | + phoneList = phoneList; | ||
| 102 | + return this; | ||
| 103 | + } | ||
| 104 | + | ||
| 105 | + public WarplyIntegrationRequest setGuid(String guid) { | ||
| 106 | + guid = guid; | ||
| 107 | + return this; | ||
| 108 | + } | ||
| 109 | + | ||
| 86 | /** | 110 | /** |
| 87 | * Call this to get how often the cached data will be updated. | 111 | * Call this to get how often the cached data will be updated. |
| 88 | * | 112 | * |
| ... | @@ -147,10 +171,10 @@ public class WarplyIntegrationRequest { | ... | @@ -147,10 +171,10 @@ public class WarplyIntegrationRequest { |
| 147 | extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE); | 171 | extraJson.putOpt(KEY_ACTION, KEY_ACTION_VALUE); |
| 148 | extraJson.putOpt(KEY_METHOD, KEY_METHOD_VALUE); | 172 | extraJson.putOpt(KEY_METHOD, KEY_METHOD_VALUE); |
| 149 | JSONObject data = new JSONObject(); | 173 | JSONObject data = new JSONObject(); |
| 150 | - data.putOpt("nonTelco", WarplyManagerHelper.loadCustomerState().isNonTelco()); | 174 | + data.putOpt("nonTelco", isNonTelco); |
| 151 | - data.putOpt("acceptedConsent", WarplyManagerHelper.loadCustomerState().isAcceptedConsent()); | 175 | + data.putOpt("acceptedConsent", hasAcceptedConsent); |
| 152 | - data.putOpt("msisdnList", new JSONArray(WarplyManagerHelper.loadCustomerState().getMsisdnList())); | 176 | + data.putOpt("msisdnList", new JSONArray(phoneList)); |
| 153 | - data.putOpt("guid", WarplyManagerHelper.loadCustomerState().getGuid()); | 177 | + data.putOpt("guid", guid); |
| 154 | 178 | ||
| 155 | extraJson.putOpt(KEY_DATA, data); | 179 | extraJson.putOpt(KEY_DATA, data); |
| 156 | bodyJsonObject.putOpt(KEY_MAPP, extraJson); | 180 | bodyJsonObject.putOpt(KEY_MAPP, extraJson); | ... | ... |
| ... | @@ -53,6 +53,7 @@ import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; | ... | @@ -53,6 +53,7 @@ import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; |
| 53 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage; | 53 | import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage; |
| 54 | import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest; | 54 | import ly.warp.sdk.io.request.CosmoteRetrieveSharingRequest; |
| 55 | import ly.warp.sdk.io.request.CosmoteSharingRequest; | 55 | import ly.warp.sdk.io.request.CosmoteSharingRequest; |
| 56 | +import ly.warp.sdk.io.request.WarplyIntegrationRequest; | ||
| 56 | import ly.warp.sdk.utils.managers.WarplyManager; | 57 | import ly.warp.sdk.utils.managers.WarplyManager; |
| 57 | 58 | ||
| 58 | /** | 59 | /** |
| ... | @@ -69,12 +70,12 @@ public class WarplyManagerHelper { | ... | @@ -69,12 +70,12 @@ public class WarplyManagerHelper { |
| 69 | // Fields | 70 | // Fields |
| 70 | // =========================================================== | 71 | // =========================================================== |
| 71 | 72 | ||
| 72 | - private static Consumer mConsumer; | 73 | + private static Consumer mConsumer = new Consumer(); |
| 73 | private static HashMap<String, CampaignList> mUniqueCampaignList = new HashMap<String, CampaignList>(); | 74 | private static HashMap<String, CampaignList> mUniqueCampaignList = new HashMap<String, CampaignList>(); |
| 74 | private static CouponList mCouponList = new CouponList(); | 75 | private static CouponList mCouponList = new CouponList(); |
| 75 | private static CouponsetsList mCouponsetsList = new CouponsetsList(); | 76 | private static CouponsetsList mCouponsetsList = new CouponsetsList(); |
| 76 | - private static CustomerStateModel mCustomerStateModel; | 77 | + private static CustomerStateModel mCustomerStateModel = new CustomerStateModel(); |
| 77 | - private static CampaignList mCampaignList; | 78 | + private static CampaignList mCampaignList = new CampaignList(); |
| 78 | private static ArrayList<ActiveDFYCouponModel> mDfyCoupons = new ArrayList(); | 79 | private static ArrayList<ActiveDFYCouponModel> mDfyCoupons = new ArrayList(); |
| 79 | private static ArrayList<LoyaltyGiftsForYouPackage> mSeasonalList = new ArrayList<>(); | 80 | private static ArrayList<LoyaltyGiftsForYouPackage> mSeasonalList = new ArrayList<>(); |
| 80 | private static ArrayList<LoyaltyContextualOfferModel> mCCMSList = new ArrayList<>(); | 81 | private static ArrayList<LoyaltyContextualOfferModel> mCCMSList = new ArrayList<>(); |
| ... | @@ -403,73 +404,73 @@ public class WarplyManagerHelper { | ... | @@ -403,73 +404,73 @@ public class WarplyManagerHelper { |
| 403 | */ | 404 | */ |
| 404 | public static void setCCMSLoyaltyCampaigns(ArrayList<LoyaltyContextualOfferModel> list) { | 405 | public static void setCCMSLoyaltyCampaigns(ArrayList<LoyaltyContextualOfferModel> list) { |
| 405 | mCCMSList.clear(); | 406 | mCCMSList.clear(); |
| 406 | - mCCMSList = list; | 407 | + mCCMSList.addAll(list); |
| 407 | - | 408 | + |
| 408 | - if (list == null || list.size() == 0) { | 409 | +// if (list == null || list.size() == 0) { |
| 409 | - CampaignList tempGifts = new CampaignList(); | 410 | +// CampaignList tempGifts = new CampaignList(); |
| 410 | - if (mUniqueCampaignList != null && mUniqueCampaignList.get("gifts_for_you") != null && mUniqueCampaignList.get("gifts_for_you").size() > 0) { | 411 | +// if (mUniqueCampaignList != null && mUniqueCampaignList.get("gifts_for_you") != null && mUniqueCampaignList.get("gifts_for_you").size() > 0) { |
| 411 | - for (Campaign camp : mUniqueCampaignList.get("gifts_for_you")) { | 412 | +// for (Campaign camp : mUniqueCampaignList.get("gifts_for_you")) { |
| 412 | - try { | 413 | +// try { |
| 413 | - String key = WarpJSONParser.getJSONFromString(camp.getExtraFields()).keys().next(); | 414 | +// String key = WarpJSONParser.getJSONFromString(camp.getExtraFields()).keys().next(); |
| 414 | - if (!TextUtils.isEmpty(key)) { | 415 | +// if (!TextUtils.isEmpty(key)) { |
| 415 | - String value = WarpJSONParser.getJSONFromString(camp.getExtraFields()).optString(key); | 416 | +// String value = WarpJSONParser.getJSONFromString(camp.getExtraFields()).optString(key); |
| 416 | - if (!(key.equals("ccms_offer") && value.equals("true"))) { | 417 | +// if (!(key.equals("ccms_offer") && value.equals("true"))) { |
| 417 | - tempGifts.add(camp); | 418 | +// tempGifts.add(camp); |
| 418 | - } | 419 | +// } |
| 419 | - } | 420 | +// } |
| 420 | - } catch (Exception exception) { | 421 | +// } catch (Exception exception) { |
| 421 | - tempGifts.add(camp); | 422 | +// tempGifts.add(camp); |
| 422 | - } | 423 | +// } |
| 423 | - } | 424 | +// } |
| 424 | - | 425 | +// |
| 425 | - Log.v("Got L:{" + String.valueOf(mCampaignList.size()) + "}", " LOYALTY campaigns"); | 426 | +// Log.v("Got L:{" + String.valueOf(mCampaignList.size()) + "}", " LOYALTY campaigns"); |
| 426 | - Log.v("Got C:{0}", " CCMS campaigns"); | 427 | +// Log.v("Got C:{0}", " CCMS campaigns"); |
| 427 | - Log.v("Matched M:{0}", " CCMS campaigns"); | 428 | +// Log.v("Matched M:{0}", " CCMS campaigns"); |
| 428 | - Log.v("=====================================", ""); | 429 | +// Log.v("=====================================", ""); |
| 429 | - Log.v("TOTAL: Campaigns Sum=" + String.valueOf(mCampaignList.size()), " campaigns to display"); | 430 | +// Log.v("TOTAL: Campaigns Sum=" + String.valueOf(mCampaignList.size()), " campaigns to display"); |
| 430 | - mUniqueCampaignList.get("gifts_for_you").removeAll(tempGifts); | 431 | +// mUniqueCampaignList.get("gifts_for_you").removeAll(tempGifts); |
| 431 | - } | 432 | +// } |
| 432 | - return; | 433 | +// return; |
| 433 | - } | 434 | +// } |
| 434 | - | 435 | +// |
| 435 | - CampaignList tempGifts = new CampaignList(); | 436 | +// CampaignList tempGifts = new CampaignList(); |
| 436 | - if (mUniqueCampaignList != null && mUniqueCampaignList.get("gifts_for_you") != null && mUniqueCampaignList.get("gifts_for_you").size() > 0) { | 437 | +// if (mUniqueCampaignList != null && mUniqueCampaignList.get("gifts_for_you") != null && mUniqueCampaignList.get("gifts_for_you").size() > 0) { |
| 437 | - int ccmsCount = 0; | 438 | +// int ccmsCount = 0; |
| 438 | - int loyaltyCount = 0; | 439 | +// int loyaltyCount = 0; |
| 439 | - for (Campaign camp : mUniqueCampaignList.get("gifts_for_you")) { | 440 | +// for (Campaign camp : mUniqueCampaignList.get("gifts_for_you")) { |
| 440 | - try { | 441 | +// try { |
| 441 | - String key = WarpJSONParser.getJSONFromString(camp.getExtraFields()).keys().next(); | 442 | +// String key = WarpJSONParser.getJSONFromString(camp.getExtraFields()).keys().next(); |
| 442 | - if (!TextUtils.isEmpty(key) && key.equals("ccms_offer")) { | 443 | +// if (!TextUtils.isEmpty(key) && key.equals("ccms_offer")) { |
| 443 | - String value = WarpJSONParser.getJSONFromString(camp.getExtraFields()).optString(key); | 444 | +// String value = WarpJSONParser.getJSONFromString(camp.getExtraFields()).optString(key); |
| 444 | - if (!TextUtils.isEmpty(value) && value.equals("true")) { | 445 | +// if (!TextUtils.isEmpty(value) && value.equals("true")) { |
| 445 | - for (LoyaltyContextualOfferModel ccms : list) { | 446 | +// for (LoyaltyContextualOfferModel ccms : list) { |
| 446 | - if (ccms.getLoyaltyCampaignId().equals(camp.getSessionUUID())) { | 447 | +// if (ccms.getLoyaltyCampaignId().equals(camp.getSessionUUID())) { |
| 447 | - tempGifts.add(camp); | 448 | +// tempGifts.add(camp); |
| 448 | - ccmsCount++; | 449 | +// ccmsCount++; |
| 449 | - break; | 450 | +// break; |
| 450 | - } | 451 | +// } |
| 451 | - } | 452 | +// } |
| 452 | - } else { | 453 | +// } else { |
| 453 | - tempGifts.add(camp); | 454 | +// tempGifts.add(camp); |
| 454 | - loyaltyCount++; | 455 | +// loyaltyCount++; |
| 455 | - } | 456 | +// } |
| 456 | - } else { | 457 | +// } else { |
| 457 | - tempGifts.add(camp); | 458 | +// tempGifts.add(camp); |
| 458 | - loyaltyCount++; | 459 | +// loyaltyCount++; |
| 459 | - } | 460 | +// } |
| 460 | - } catch (Exception exception) { | 461 | +// } catch (Exception exception) { |
| 461 | - tempGifts.add(camp); | 462 | +// tempGifts.add(camp); |
| 462 | - loyaltyCount++; | 463 | +// loyaltyCount++; |
| 463 | - } | 464 | +// } |
| 464 | - } | 465 | +// } |
| 465 | - | 466 | +// |
| 466 | - Log.v("Got L:{" + String.valueOf(mCampaignList.size()) + "}", " LOYALTY campaigns"); | 467 | +// Log.v("Got L:{" + String.valueOf(mCampaignList.size()) + "}", " LOYALTY campaigns"); |
| 467 | - Log.v("Got C:{" + String.valueOf(list.size()) + "}", " CCMS campaigns"); | 468 | +// Log.v("Got C:{" + String.valueOf(list.size()) + "}", " CCMS campaigns"); |
| 468 | - Log.v("Matched M:{" + String.valueOf(ccmsCount) + "}", " CCMS campaigns"); | 469 | +// Log.v("Matched M:{" + String.valueOf(ccmsCount) + "}", " CCMS campaigns"); |
| 469 | - Log.v("=====================================", ""); | 470 | +// Log.v("=====================================", ""); |
| 470 | - Log.v("TOTAL: Campaigns Sum=" + String.valueOf(mCampaignList.size() - loyaltyCount + ccmsCount), " campaigns to display"); | 471 | +// Log.v("TOTAL: Campaigns Sum=" + String.valueOf(mCampaignList.size() - loyaltyCount + ccmsCount), " campaigns to display"); |
| 471 | - mUniqueCampaignList.get("gifts_for_you").retainAll(tempGifts); | 472 | +// mUniqueCampaignList.get("gifts_for_you").retainAll(tempGifts); |
| 472 | - } | 473 | +// } |
| 473 | } | 474 | } |
| 474 | 475 | ||
| 475 | /** | 476 | /** |
| ... | @@ -497,8 +498,12 @@ public class WarplyManagerHelper { | ... | @@ -497,8 +498,12 @@ public class WarplyManagerHelper { |
| 497 | * Open Questionnaire | 498 | * Open Questionnaire |
| 498 | */ | 499 | */ |
| 499 | public static String openQuestionnaire() { | 500 | public static String openQuestionnaire() { |
| 500 | - if (mUniqueCampaignList != null && mUniqueCampaignList.get("questionnaire") != null && mUniqueCampaignList.get("questionnaire").size() > 0) { | 501 | + if (mCampaignList != null && mCampaignList.size() > 0) { |
| 501 | - return constructCampaignUrl(mUniqueCampaignList.get("questionnaire").get(0)); | 502 | + for (Campaign camp : mCampaignList) { |
| 503 | + if (camp.getOfferCategory().equals("questionnaire")) { | ||
| 504 | + return constructCampaignUrl(camp); | ||
| 505 | + } | ||
| 506 | + } | ||
| 502 | } | 507 | } |
| 503 | 508 | ||
| 504 | return ""; | 509 | return ""; |
| ... | @@ -508,8 +513,12 @@ public class WarplyManagerHelper { | ... | @@ -508,8 +513,12 @@ public class WarplyManagerHelper { |
| 508 | * Open Pacing | 513 | * Open Pacing |
| 509 | */ | 514 | */ |
| 510 | public static String openPacing() { | 515 | public static String openPacing() { |
| 511 | - if (mUniqueCampaignList != null && mUniqueCampaignList.get("pacing") != null && mUniqueCampaignList.get("pacing").size() > 0) { | 516 | + if (mCampaignList != null && mCampaignList.size() > 0) { |
| 512 | - return constructCampaignUrl(mUniqueCampaignList.get("pacing").get(0)); | 517 | + for (Campaign camp : mCampaignList) { |
| 518 | + if (camp.getOfferCategory().equals("pacing")) { | ||
| 519 | + return constructCampaignUrl(camp); | ||
| 520 | + } | ||
| 521 | + } | ||
| 513 | } | 522 | } |
| 514 | 523 | ||
| 515 | return ""; | 524 | return ""; |
| ... | @@ -521,6 +530,23 @@ public class WarplyManagerHelper { | ... | @@ -521,6 +530,23 @@ public class WarplyManagerHelper { |
| 521 | */ | 530 | */ |
| 522 | public static void saveCustomerState(CustomerStateModel customerState) { | 531 | public static void saveCustomerState(CustomerStateModel customerState) { |
| 523 | mCustomerStateModel = customerState; | 532 | mCustomerStateModel = customerState; |
| 533 | + | ||
| 534 | + WarplyIntegrationRequest request = new WarplyIntegrationRequest(); | ||
| 535 | + request.setIsNoTelco(customerState.isNonTelco()); | ||
| 536 | + request.setHasAcceptedConsent(customerState.isAcceptedConsent()); | ||
| 537 | + request.setGuid(customerState.getGuid()); | ||
| 538 | + request.setMsisdnList(customerState.getMsisdnList()); | ||
| 539 | + WarplyManager.consumerIntegration(request, new CallbackReceiver<JSONObject>() { | ||
| 540 | + @Override | ||
| 541 | + public void onSuccess(JSONObject result) { | ||
| 542 | + WarpUtils.log("CUSTOMER STATE SUCCESS"); | ||
| 543 | + } | ||
| 544 | + | ||
| 545 | + @Override | ||
| 546 | + public void onFailure(int errorCode) { | ||
| 547 | + WarpUtils.log("CUSTOMER STATE ERROR"); | ||
| 548 | + } | ||
| 549 | + }); | ||
| 524 | } | 550 | } |
| 525 | 551 | ||
| 526 | /** | 552 | /** |
| ... | @@ -569,24 +595,28 @@ public class WarplyManagerHelper { | ... | @@ -569,24 +595,28 @@ public class WarplyManagerHelper { |
| 569 | } | 595 | } |
| 570 | 596 | ||
| 571 | public static void setUniqueCampaignList(CampaignList campaignList) { | 597 | public static void setUniqueCampaignList(CampaignList campaignList) { |
| 572 | - mCampaignList = campaignList; | 598 | + mCampaignList.clear(); |
| 573 | - if (campaignList != null) { | 599 | + mCampaignList.addAll(campaignList); |
| 574 | - for (Campaign campaign : campaignList) { | 600 | + |
| 575 | - if (mUniqueCampaignList.containsKey(campaign.getOfferCategory().trim())) { | 601 | + |
| 576 | - CampaignList tempCampaignList = (CampaignList) mUniqueCampaignList.get(campaign.getOfferCategory().trim()); | 602 | +// if (campaignList != null) { |
| 577 | - tempCampaignList.add(campaign); | 603 | +// for (Campaign campaign : campaignList) { |
| 578 | - mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList); | 604 | +// if (mUniqueCampaignList.containsKey(campaign.getOfferCategory().trim())) { |
| 579 | - } else { | 605 | +// CampaignList tempCampaignList = (CampaignList) mUniqueCampaignList.get(campaign.getOfferCategory().trim()); |
| 580 | - CampaignList tempCampaignList = new CampaignList(); | 606 | +// tempCampaignList.add(campaign); |
| 581 | - tempCampaignList.add(campaign); | 607 | +// mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList); |
| 582 | - mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList); | 608 | +// } else { |
| 583 | - } | 609 | +// CampaignList tempCampaignList = new CampaignList(); |
| 584 | - } | 610 | +// tempCampaignList.add(campaign); |
| 585 | - } | 611 | +// mUniqueCampaignList.put(campaign.getOfferCategory().trim(), tempCampaignList); |
| 612 | +// } | ||
| 613 | +// } | ||
| 614 | +// } | ||
| 586 | } | 615 | } |
| 587 | 616 | ||
| 588 | public static void setCampaignList(CampaignList campaignList) { | 617 | public static void setCampaignList(CampaignList campaignList) { |
| 589 | - mCampaignList = campaignList; | 618 | + mCampaignList.clear(); |
| 619 | + mCampaignList.addAll(campaignList); | ||
| 590 | } | 620 | } |
| 591 | 621 | ||
| 592 | public static CampaignList getCampaignList() { | 622 | public static CampaignList getCampaignList() { | ... | ... |
| ... | @@ -29,6 +29,7 @@ import org.json.JSONException; | ... | @@ -29,6 +29,7 @@ import org.json.JSONException; |
| 29 | import org.json.JSONObject; | 29 | import org.json.JSONObject; |
| 30 | 30 | ||
| 31 | import ly.warp.sdk.Warply; | 31 | import ly.warp.sdk.Warply; |
| 32 | +import ly.warp.sdk.activities.BaseFragmentActivity; | ||
| 32 | import ly.warp.sdk.db.WarplyDBHelper; | 33 | import ly.warp.sdk.db.WarplyDBHelper; |
| 33 | import ly.warp.sdk.io.callbacks.AddressHook; | 34 | import ly.warp.sdk.io.callbacks.AddressHook; |
| 34 | import ly.warp.sdk.io.callbacks.CallbackReceiver; | 35 | import ly.warp.sdk.io.callbacks.CallbackReceiver; |
| ... | @@ -107,6 +108,7 @@ import ly.warp.sdk.io.request.WarplyVerifyOTPRequest; | ... | @@ -107,6 +108,7 @@ import ly.warp.sdk.io.request.WarplyVerifyOTPRequest; |
| 107 | import ly.warp.sdk.io.request.WarplyVerifyTicketRequest; | 108 | import ly.warp.sdk.io.request.WarplyVerifyTicketRequest; |
| 108 | import ly.warp.sdk.utils.WarpUtils; | 109 | import ly.warp.sdk.utils.WarpUtils; |
| 109 | import ly.warp.sdk.utils.WarplyManagerHelper; | 110 | import ly.warp.sdk.utils.WarplyManagerHelper; |
| 111 | +import ly.warp.sdk.utils.WarplyProperty; | ||
| 110 | import ly.warp.sdk.utils.constants.WarpConstants; | 112 | import ly.warp.sdk.utils.constants.WarpConstants; |
| 111 | 113 | ||
| 112 | /** | 114 | /** |
| ... | @@ -1524,4 +1526,63 @@ public class WarplyManager { | ... | @@ -1524,4 +1526,63 @@ public class WarplyManager { |
| 1524 | } | 1526 | } |
| 1525 | }); | 1527 | }); |
| 1526 | } | 1528 | } |
| 1529 | + | ||
| 1530 | + public static void getUserCouponsWithCouponsets(WarplyUserCouponsRequest request, final CallbackReceiver<CouponList> receiver) { | ||
| 1531 | + WarpUtils.log("************* WARPLY User Coupons Request ********************"); | ||
| 1532 | + WarpUtils.log("[WARP Trace] WARPLY User Coupons Request is active"); | ||
| 1533 | + WarpUtils.log("**************************************************"); | ||
| 1534 | + | ||
| 1535 | + WarplyManager.getCouponsets(new WarplyGetCouponsetsRequest() | ||
| 1536 | + .setLanguage(WarplyProperty.getLanguage(Warply.getWarplyContext())), new CallbackReceiver<CouponsetsList>() { | ||
| 1537 | + @Override | ||
| 1538 | + public void onSuccess(CouponsetsList result) { | ||
| 1539 | + Warply.postReceiveMicroappData(WarpConstants.MICROAPP_COUPONS, true, "context", request.toJson(), new CouponsHook(new CallbackReceiver<CouponList>() { | ||
| 1540 | + @Override | ||
| 1541 | + public void onSuccess(CouponList response) { | ||
| 1542 | + CouponList mCouponList = new CouponList(); | ||
| 1543 | + for (Coupon coupon : response) { | ||
| 1544 | + for (Couponset couponset : result) { | ||
| 1545 | + if (coupon.getCouponsetUuid().equals(couponset.getUuid())) { | ||
| 1546 | + coupon.setDescription(couponset.getShortDescription()); | ||
| 1547 | + coupon.setImage(couponset.getImgPreview()); | ||
| 1548 | + coupon.setName(couponset.getName()); | ||
| 1549 | + mCouponList.add(coupon); | ||
| 1550 | + } | ||
| 1551 | + } | ||
| 1552 | + } | ||
| 1553 | + WarplyManagerHelper.setCouponList(mCouponList); | ||
| 1554 | + receiver.onSuccess(mCouponList); | ||
| 1555 | + } | ||
| 1556 | + | ||
| 1557 | + @Override | ||
| 1558 | + public void onFailure(int errorCode) { | ||
| 1559 | + if (errorCode == 401) { | ||
| 1560 | + refreshToken(new WarplyRefreshTokenRequest(), new CallbackReceiver<JSONObject>() { | ||
| 1561 | + @Override | ||
| 1562 | + public void onSuccess(JSONObject result) { | ||
| 1563 | + int status = result.optInt("status", 2); | ||
| 1564 | + if (status == 1) | ||
| 1565 | + getUserCoupons(request, receiver); | ||
| 1566 | + else | ||
| 1567 | + receiver.onFailure(status); | ||
| 1568 | + } | ||
| 1569 | + | ||
| 1570 | + @Override | ||
| 1571 | + public void onFailure(int errorCode) { | ||
| 1572 | + receiver.onFailure(errorCode); | ||
| 1573 | + } | ||
| 1574 | + }); | ||
| 1575 | + } else | ||
| 1576 | + receiver.onFailure(errorCode); | ||
| 1577 | + } | ||
| 1578 | + }, | ||
| 1579 | + request.getSignature())); | ||
| 1580 | + } | ||
| 1581 | + | ||
| 1582 | + @Override | ||
| 1583 | + public void onFailure(int errorCode) { | ||
| 1584 | + receiver.onFailure(errorCode); | ||
| 1585 | + } | ||
| 1586 | + }); | ||
| 1587 | + } | ||
| 1527 | } | 1588 | } | ... | ... |
| ... | @@ -383,10 +383,17 @@ public class WarpView extends WebView { | ... | @@ -383,10 +383,17 @@ public class WarpView extends WebView { |
| 383 | EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent)); | 383 | EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent)); |
| 384 | } else if (parts[1].equals("addUserTag")) { | 384 | } else if (parts[1].equals("addUserTag")) { |
| 385 | QuestionnaireEventModel questionnaireEvent = new QuestionnaireEventModel(); | 385 | QuestionnaireEventModel questionnaireEvent = new QuestionnaireEventModel(); |
| 386 | + try { | ||
| 386 | questionnaireEvent.setName(parts[1]); | 387 | questionnaireEvent.setName(parts[1]); |
| 387 | questionnaireEvent.setParameter(parts[2]); | 388 | questionnaireEvent.setParameter(parts[2]); |
| 388 | WarpUtils.setUserTag(Warply.getWarplyContext(), parts[2]); | 389 | WarpUtils.setUserTag(Warply.getWarplyContext(), parts[2]); |
| 389 | EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent)); | 390 | EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent)); |
| 391 | + } catch (IndexOutOfBoundsException e) { | ||
| 392 | + questionnaireEvent.setName(parts[1]); | ||
| 393 | + questionnaireEvent.setParameter(""); | ||
| 394 | + WarpUtils.setUserTag(Warply.getWarplyContext(), ""); | ||
| 395 | + EventBus.getDefault().post(new WarplyEventBusManager(questionnaireEvent)); | ||
| 396 | + } | ||
| 390 | } else if (parts[1].equals("couponRetrieved")) { | 397 | } else if (parts[1].equals("couponRetrieved")) { |
| 391 | // EventBus.getDefault().post(new WarplyEventBusManager(new CouponEventModel())); | 398 | // EventBus.getDefault().post(new WarplyEventBusManager(new CouponEventModel())); |
| 392 | } else if (parts[2].equals("serviceDisabled")) { | 399 | } else if (parts[2].equals("serviceDisabled")) { | ... | ... |
| ... | @@ -32,6 +32,7 @@ | ... | @@ -32,6 +32,7 @@ |
| 32 | android:textColor="@color/grey" | 32 | android:textColor="@color/grey" |
| 33 | android:textSize="17sp" | 33 | android:textSize="17sp" |
| 34 | android:textStyle="bold" | 34 | android:textStyle="bold" |
| 35 | + android:text="@string/cos_gifts_title" | ||
| 35 | app:layout_constraintBottom_toBottomOf="parent" | 36 | app:layout_constraintBottom_toBottomOf="parent" |
| 36 | app:layout_constraintEnd_toEndOf="parent" | 37 | app:layout_constraintEnd_toEndOf="parent" |
| 37 | app:layout_constraintHorizontal_bias="0.356" | 38 | app:layout_constraintHorizontal_bias="0.356" | ... | ... |
| ... | @@ -31,6 +31,7 @@ | ... | @@ -31,6 +31,7 @@ |
| 31 | android:textColor="@color/grey" | 31 | android:textColor="@color/grey" |
| 32 | android:textSize="17sp" | 32 | android:textSize="17sp" |
| 33 | android:textStyle="bold" | 33 | android:textStyle="bold" |
| 34 | + android:text="@string/cos_more_title" | ||
| 34 | app:layout_constraintBottom_toBottomOf="parent" | 35 | app:layout_constraintBottom_toBottomOf="parent" |
| 35 | app:layout_constraintEnd_toEndOf="parent" | 36 | app:layout_constraintEnd_toEndOf="parent" |
| 36 | app:layout_constraintHorizontal_bias="0.356" | 37 | app:layout_constraintHorizontal_bias="0.356" | ... | ... |
-
Please register or login to post a comment