Showing
8 changed files
with
705 additions
and
177 deletions
| ... | @@ -4,7 +4,6 @@ import android.app.Activity; | ... | @@ -4,7 +4,6 @@ import android.app.Activity; |
| 4 | import android.content.Context; | 4 | import android.content.Context; |
| 5 | import android.content.Intent; | 5 | import android.content.Intent; |
| 6 | import android.os.Bundle; | 6 | import android.os.Bundle; |
| 7 | -import android.os.Parcelable; | ||
| 8 | import android.text.TextUtils; | 7 | import android.text.TextUtils; |
| 9 | import android.util.Log; | 8 | import android.util.Log; |
| 10 | import android.view.View; | 9 | import android.view.View; |
| ... | @@ -21,24 +20,24 @@ import org.json.JSONObject; | ... | @@ -21,24 +20,24 @@ import org.json.JSONObject; |
| 21 | 20 | ||
| 22 | import java.io.Serializable; | 21 | import java.io.Serializable; |
| 23 | import java.util.ArrayList; | 22 | import java.util.ArrayList; |
| 24 | -import java.util.HashSet; | 23 | +import java.util.HashMap; |
| 24 | +import java.util.Map; | ||
| 25 | +import java.util.TreeMap; | ||
| 25 | 26 | ||
| 26 | import io.github.inflationx.viewpump.ViewPumpContextWrapper; | 27 | import io.github.inflationx.viewpump.ViewPumpContextWrapper; |
| 27 | import ly.warp.sdk.R; | 28 | import ly.warp.sdk.R; |
| 28 | import ly.warp.sdk.io.models.Campaign; | 29 | import ly.warp.sdk.io.models.Campaign; |
| 29 | import ly.warp.sdk.io.models.CampaignList; | 30 | import ly.warp.sdk.io.models.CampaignList; |
| 30 | import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; | 31 | import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; |
| 31 | -import ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage; | ||
| 32 | import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; | 32 | import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; |
| 33 | -import ly.warp.sdk.io.models.MergedGifts; | ||
| 34 | import ly.warp.sdk.io.models.MergedMore; | 33 | import ly.warp.sdk.io.models.MergedMore; |
| 35 | import ly.warp.sdk.utils.WarpJSONParser; | 34 | import ly.warp.sdk.utils.WarpJSONParser; |
| 36 | import ly.warp.sdk.utils.WarpUtils; | 35 | import ly.warp.sdk.utils.WarpUtils; |
| 37 | import ly.warp.sdk.utils.WarplyManagerHelper; | 36 | import ly.warp.sdk.utils.WarplyManagerHelper; |
| 38 | import ly.warp.sdk.utils.managers.WarplyEventBusManager; | 37 | import ly.warp.sdk.utils.managers.WarplyEventBusManager; |
| 39 | -import ly.warp.sdk.views.adapters.MergedGiftsAdapter; | ||
| 40 | import ly.warp.sdk.views.adapters.MergedMoreAdapter; | 38 | import ly.warp.sdk.views.adapters.MergedMoreAdapter; |
| 41 | import ly.warp.sdk.views.adapters.MoreCampaignAdapter; | 39 | import ly.warp.sdk.views.adapters.MoreCampaignAdapter; |
| 40 | +import ly.warp.sdk.views.adapters.MoreContextualAdapter; | ||
| 42 | 41 | ||
| 43 | 42 | ||
| 44 | public class MoreForYouActivity extends Activity implements View.OnClickListener { | 43 | public class MoreForYouActivity extends Activity implements View.OnClickListener { |
| ... | @@ -58,14 +57,35 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -58,14 +57,35 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 58 | private MergedMoreAdapter mAdapterMergedMore; | 57 | private MergedMoreAdapter mAdapterMergedMore; |
| 59 | private LinearLayout mLlMorePopup; | 58 | private LinearLayout mLlMorePopup; |
| 60 | private ArrayList<Campaign> mValuesList = new ArrayList<>(); | 59 | private ArrayList<Campaign> mValuesList = new ArrayList<>(); |
| 61 | - // private HashSet<Campaign> mHashSetList = new HashSet<>(); | ||
| 62 | private ArrayList<LoyaltyContextualOfferModel> mContextualList = new ArrayList<>(); | 60 | private ArrayList<LoyaltyContextualOfferModel> mContextualList = new ArrayList<>(); |
| 63 | private ArrayList<MergedMore> mData = new ArrayList(); | 61 | private ArrayList<MergedMore> mData = new ArrayList(); |
| 64 | 62 | ||
| 63 | + /** | ||
| 64 | + * New Implementation | ||
| 65 | + */ | ||
| 66 | + private Map<String, ArrayList<Campaign>> mUniqueSectionList = new HashMap<>(); | ||
| 67 | + private RecyclerView mResearchItems; | ||
| 68 | + private TextView mTvResearchSection; | ||
| 69 | + private LinearLayout mLlResearchItems; | ||
| 70 | + private RecyclerView mExclusiveItems; | ||
| 71 | + private TextView mTvExclusiveSection; | ||
| 72 | + private LinearLayout mLlExclusiveItems; | ||
| 73 | + private RecyclerView mContestItems; | ||
| 74 | + private TextView mTvContestSection; | ||
| 75 | + private LinearLayout mLlContestItems; | ||
| 76 | + private MoreCampaignAdapter mAdapterResearch, mAdapterExclusive, mAdapterContest; | ||
| 77 | + private RecyclerView mContextualItems; | ||
| 78 | + private TextView mTvContextualSection; | ||
| 79 | + private LinearLayout mLlContextualItems; | ||
| 80 | + private MoreContextualAdapter mAdapterContextual; | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * New Implementation | ||
| 84 | + */ | ||
| 85 | + | ||
| 65 | // =========================================================== | 86 | // =========================================================== |
| 66 | // Methods for/from SuperClass/Interfaces | 87 | // Methods for/from SuperClass/Interfaces |
| 67 | // =========================================================== | 88 | // =========================================================== |
| 68 | - | ||
| 69 | @Override | 89 | @Override |
| 70 | public void onCreate(Bundle savedInstanceState) { | 90 | public void onCreate(Bundle savedInstanceState) { |
| 71 | super.onCreate(savedInstanceState); | 91 | super.onCreate(savedInstanceState); |
| ... | @@ -78,13 +98,26 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -78,13 +98,26 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 78 | 98 | ||
| 79 | mRecyclerMore = findViewById(R.id.rv_more_items); | 99 | mRecyclerMore = findViewById(R.id.rv_more_items); |
| 80 | 100 | ||
| 81 | -// if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) { | 101 | + /** New Implementation */ |
| 82 | -// mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("more_for_you")); | 102 | + mTvResearchSection = findViewById(R.id.tv_research_section); |
| 83 | -// mValuesList.clear(); | 103 | + mLlResearchItems = findViewById(R.id.ll_research_items); |
| 84 | -// mValuesList.addAll(mHashSetList); | 104 | + mResearchItems = findViewById(R.id.rv_research_items); |
| 85 | -// } | 105 | + mTvExclusiveSection = findViewById(R.id.tv_exclusive_section); |
| 86 | - | 106 | + mLlExclusiveItems = findViewById(R.id.ll_exclusive_items); |
| 87 | - filterItems(); | 107 | + mExclusiveItems = findViewById(R.id.rv_exclusive_items); |
| 108 | + mTvContestSection = findViewById(R.id.tv_contest_section); | ||
| 109 | + mLlContestItems = findViewById(R.id.ll_contest_items); | ||
| 110 | + mContestItems = findViewById(R.id.rv_contest_items); | ||
| 111 | + mTvContextualSection = findViewById(R.id.tv_contextual_section); | ||
| 112 | + mLlContextualItems = findViewById(R.id.ll_contextual_items); | ||
| 113 | + mContextualItems = findViewById(R.id.rv_contextual_items); | ||
| 114 | + /** New Implementation */ | ||
| 115 | + | ||
| 116 | +// filterItems(); | ||
| 117 | + | ||
| 118 | + /** New Implementation */ | ||
| 119 | + filterItemsNew(); | ||
| 120 | + /** New Implementation */ | ||
| 88 | 121 | ||
| 89 | if (WarplyManagerHelper.getCCMSLoyaltyCampaigns() != null && WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() > 0) { | 122 | if (WarplyManagerHelper.getCCMSLoyaltyCampaigns() != null && WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() > 0) { |
| 90 | mContextualList.clear(); | 123 | mContextualList.clear(); |
| ... | @@ -95,12 +128,16 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -95,12 +128,16 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 95 | } | 128 | } |
| 96 | } | 129 | } |
| 97 | 130 | ||
| 98 | - mergeDatasets( | 131 | +// mergeDatasets( |
| 99 | - mValuesList, | 132 | +// mValuesList, |
| 100 | - mContextualList | 133 | +// mContextualList |
| 101 | - ); | 134 | +// ); |
| 135 | + | ||
| 136 | +// initViews(); | ||
| 102 | 137 | ||
| 103 | - initViews(); | 138 | + /** New Implementation */ |
| 139 | + initViewsNew(); | ||
| 140 | + /** New Implementation */ | ||
| 104 | } | 141 | } |
| 105 | 142 | ||
| 106 | @Override | 143 | @Override |
| ... | @@ -140,7 +177,11 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -140,7 +177,11 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 140 | @Subscribe() | 177 | @Subscribe() |
| 141 | public void onMessageEvent(WarplyEventBusManager event) { | 178 | public void onMessageEvent(WarplyEventBusManager event) { |
| 142 | if (event.getCcmsAdded() != null || event.getCampaignsAdded() != null) { | 179 | if (event.getCcmsAdded() != null || event.getCampaignsAdded() != null) { |
| 143 | - filterItems(); | 180 | +// filterItems(); |
| 181 | + | ||
| 182 | + /** New Implementation */ | ||
| 183 | + filterItemsNew(); | ||
| 184 | + /** New Implementation */ | ||
| 144 | 185 | ||
| 145 | if (WarplyManagerHelper.getCCMSLoyaltyCampaigns() != null && WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() > 0) { | 186 | if (WarplyManagerHelper.getCCMSLoyaltyCampaigns() != null && WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() > 0) { |
| 146 | mContextualList.clear(); | 187 | mContextualList.clear(); |
| ... | @@ -151,68 +192,16 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -151,68 +192,16 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 151 | } | 192 | } |
| 152 | } | 193 | } |
| 153 | 194 | ||
| 154 | - mergeDatasets( | 195 | +// mergeDatasets( |
| 155 | - mValuesList, | 196 | +// mValuesList, |
| 156 | - mContextualList | 197 | +// mContextualList |
| 157 | - ); | 198 | +// ); |
| 158 | 199 | ||
| 159 | - runOnUiThread(() -> { | 200 | +// initViews2(); |
| 160 | -// if (mValuesList != null && mValuesList.size() > 0) { | 201 | + |
| 161 | - if (mData != null && mData.size() > 0) { | 202 | + /** New Implementation */ |
| 162 | -// mAdapterMore = new MoreCampaignAdapter(this, mValuesList); | 203 | + initViewsNew2(); |
| 163 | - mAdapterMergedMore = new MergedMoreAdapter(MoreForYouActivity.this, mData); | 204 | + /** New Implementation */ |
| 164 | -// mRecyclerMore.setAdapter(mAdapterMore); | ||
| 165 | - mRecyclerMore.setAdapter(mAdapterMergedMore); | ||
| 166 | - mAdapterMergedMore.getPositionClicks() | ||
| 167 | - .doOnNext(dataItem -> { | ||
| 168 | - if (dataItem.getDataType() == 1) { | ||
| 169 | - WarpUtils.log("MFY_CLICK " + dataItem.getCampaign().toString()); | ||
| 170 | - EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltySDKFirebaseEventModel())); | ||
| 171 | - | ||
| 172 | - try { | ||
| 173 | - JSONObject extraFields = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()); | ||
| 174 | - if (extraFields != null) { | ||
| 175 | - if (extraFields.has("type") && extraFields.optString("type").equals("telco")) { | ||
| 176 | - for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | ||
| 177 | - if (ccms.getLoyaltyCampaignId().equals(dataItem.getCampaign().getSessionUUID())) { | ||
| 178 | - Intent intent = new Intent(MoreForYouActivity.this, TelcoActivity.class); | ||
| 179 | - intent.putExtra("ccms", ccms); | ||
| 180 | - intent.putExtra("loyalty", (Serializable) dataItem.getCampaign()); | ||
| 181 | - startActivity(intent); | ||
| 182 | - break; | ||
| 183 | - } | ||
| 184 | - } | ||
| 185 | - return; | ||
| 186 | - } | ||
| 187 | - if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { | ||
| 188 | - for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | ||
| 189 | - if (ccms.getLoyaltyCampaignId().equals(dataItem.getCampaign().getSessionUUID())) { | ||
| 190 | - WarpUtils.log("CCMS_CLICK " + ccms.toString()); | ||
| 191 | - startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms))); | ||
| 192 | - break; | ||
| 193 | - } | ||
| 194 | - } | ||
| 195 | - } else { | ||
| 196 | - startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | ||
| 197 | - } | ||
| 198 | - } | ||
| 199 | - } catch (Exception exception) { | ||
| 200 | - startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | ||
| 201 | - } | ||
| 202 | - } else if (dataItem.getDataType() == 2) { | ||
| 203 | - Intent intent = new Intent(MoreForYouActivity.this, ContextualActivity.class); | ||
| 204 | - intent.putExtra("ccms", dataItem.getCCMS()); | ||
| 205 | - startActivity(intent); | ||
| 206 | - } | ||
| 207 | - }) | ||
| 208 | - .doOnError(error -> { | ||
| 209 | - }) | ||
| 210 | - .subscribe(); | ||
| 211 | - mAdapterMergedMore.notifyDataSetChanged(); | ||
| 212 | - } else { | ||
| 213 | - mRecyclerMore.setVisibility(View.GONE); | ||
| 214 | - } | ||
| 215 | - }); | ||
| 216 | } | 205 | } |
| 217 | } | 206 | } |
| 218 | 207 | ||
| ... | @@ -285,6 +274,247 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -285,6 +274,247 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 285 | } | 274 | } |
| 286 | } | 275 | } |
| 287 | 276 | ||
| 277 | + private void initViews2() { | ||
| 278 | + runOnUiThread(() -> { | ||
| 279 | +// if (mValuesList != null && mValuesList.size() > 0) { | ||
| 280 | + if (mData != null && mData.size() > 0) { | ||
| 281 | +// mAdapterMore = new MoreCampaignAdapter(this, mValuesList); | ||
| 282 | + mAdapterMergedMore = new MergedMoreAdapter(MoreForYouActivity.this, mData); | ||
| 283 | +// mRecyclerMore.setAdapter(mAdapterMore); | ||
| 284 | + mRecyclerMore.setAdapter(mAdapterMergedMore); | ||
| 285 | + mAdapterMergedMore.getPositionClicks() | ||
| 286 | + .doOnNext(dataItem -> { | ||
| 287 | + if (dataItem.getDataType() == 1) { | ||
| 288 | + WarpUtils.log("MFY_CLICK " + dataItem.getCampaign().toString()); | ||
| 289 | + EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltySDKFirebaseEventModel())); | ||
| 290 | + | ||
| 291 | + try { | ||
| 292 | + JSONObject extraFields = WarpJSONParser.getJSONFromString(dataItem.getCampaign().getExtraFields()); | ||
| 293 | + if (extraFields != null) { | ||
| 294 | + if (extraFields.has("type") && extraFields.optString("type").equals("telco")) { | ||
| 295 | + for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | ||
| 296 | + if (ccms.getLoyaltyCampaignId().equals(dataItem.getCampaign().getSessionUUID())) { | ||
| 297 | + Intent intent = new Intent(MoreForYouActivity.this, TelcoActivity.class); | ||
| 298 | + intent.putExtra("ccms", ccms); | ||
| 299 | + intent.putExtra("loyalty", (Serializable) dataItem.getCampaign()); | ||
| 300 | + startActivity(intent); | ||
| 301 | + break; | ||
| 302 | + } | ||
| 303 | + } | ||
| 304 | + return; | ||
| 305 | + } | ||
| 306 | + if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { | ||
| 307 | + for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | ||
| 308 | + if (ccms.getLoyaltyCampaignId().equals(dataItem.getCampaign().getSessionUUID())) { | ||
| 309 | + WarpUtils.log("CCMS_CLICK " + ccms.toString()); | ||
| 310 | + startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(dataItem.getCampaign(), ccms))); | ||
| 311 | + break; | ||
| 312 | + } | ||
| 313 | + } | ||
| 314 | + } else { | ||
| 315 | + startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | ||
| 316 | + } | ||
| 317 | + } | ||
| 318 | + } catch (Exception exception) { | ||
| 319 | + startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign()))); | ||
| 320 | + } | ||
| 321 | + } else if (dataItem.getDataType() == 2) { | ||
| 322 | + Intent intent = new Intent(MoreForYouActivity.this, ContextualActivity.class); | ||
| 323 | + intent.putExtra("ccms", dataItem.getCCMS()); | ||
| 324 | + startActivity(intent); | ||
| 325 | + } | ||
| 326 | + }) | ||
| 327 | + .doOnError(error -> { | ||
| 328 | + }) | ||
| 329 | + .subscribe(); | ||
| 330 | + mAdapterMergedMore.notifyDataSetChanged(); | ||
| 331 | + } else { | ||
| 332 | + mRecyclerMore.setVisibility(View.GONE); | ||
| 333 | + } | ||
| 334 | + }); | ||
| 335 | + } | ||
| 336 | + | ||
| 337 | + private void initViewsNew() { | ||
| 338 | + mIvBack.setOnClickListener(this); | ||
| 339 | + mIvPopupClose.setOnClickListener(this); | ||
| 340 | + | ||
| 341 | + if (mUniqueSectionList != null) { | ||
| 342 | + String firstKey = (String) mUniqueSectionList.keySet().toArray()[0]; | ||
| 343 | + if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) { | ||
| 344 | + mTvResearchSection.setText(firstKey.substring(1)); | ||
| 345 | + mResearchItems.setNestedScrollingEnabled(false); | ||
| 346 | + mResearchItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); | ||
| 347 | + mAdapterResearch = new MoreCampaignAdapter(this, mUniqueSectionList.get(firstKey)); | ||
| 348 | + mResearchItems.setAdapter(mAdapterResearch); | ||
| 349 | + mAdapterResearch.getPositionClicks() | ||
| 350 | + .doOnNext(this::handleMoreItemClick) | ||
| 351 | + .doOnError(error -> { | ||
| 352 | + }) | ||
| 353 | + .subscribe(); | ||
| 354 | + | ||
| 355 | + mLlResearchItems.setVisibility(View.VISIBLE); | ||
| 356 | + } | ||
| 357 | + | ||
| 358 | + String secondKey = (String) mUniqueSectionList.keySet().toArray()[1]; | ||
| 359 | + if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) { | ||
| 360 | + mTvExclusiveSection.setText(secondKey.substring(1)); | ||
| 361 | + mExclusiveItems.setNestedScrollingEnabled(false); | ||
| 362 | + mExclusiveItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); | ||
| 363 | + mAdapterExclusive = new MoreCampaignAdapter(this, mUniqueSectionList.get(secondKey)); | ||
| 364 | + mExclusiveItems.setAdapter(mAdapterExclusive); | ||
| 365 | + mAdapterExclusive.getPositionClicks() | ||
| 366 | + .doOnNext(this::handleMoreItemClick) | ||
| 367 | + .doOnError(error -> { | ||
| 368 | + }) | ||
| 369 | + .subscribe(); | ||
| 370 | + | ||
| 371 | + mLlExclusiveItems.setVisibility(View.VISIBLE); | ||
| 372 | + } | ||
| 373 | + | ||
| 374 | + String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2]; | ||
| 375 | + if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) { | ||
| 376 | + mTvContestSection.setText(thirdKey.substring(1)); | ||
| 377 | + mContestItems.setNestedScrollingEnabled(false); | ||
| 378 | + mContestItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); | ||
| 379 | + mAdapterContest = new MoreCampaignAdapter(this, mUniqueSectionList.get(thirdKey)); | ||
| 380 | + mContestItems.setAdapter(mAdapterContest); | ||
| 381 | + mAdapterContest.getPositionClicks() | ||
| 382 | + .doOnNext(this::handleMoreItemClick) | ||
| 383 | + .doOnError(error -> { | ||
| 384 | + }) | ||
| 385 | + .subscribe(); | ||
| 386 | + | ||
| 387 | + mLlContestItems.setVisibility(View.VISIBLE); | ||
| 388 | + } | ||
| 389 | + | ||
| 390 | + if (mContextualList != null && mContextualList.size() > 0) { | ||
| 391 | + mTvContextualSection.setText(getString(R.string.cos_mfy_other)); | ||
| 392 | + mContextualItems.setNestedScrollingEnabled(false); | ||
| 393 | + mContextualItems.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); | ||
| 394 | + mAdapterContextual = new MoreContextualAdapter(this, mContextualList); | ||
| 395 | + mContextualItems.setAdapter(mAdapterContextual); | ||
| 396 | + mAdapterContextual.getPositionClicks() | ||
| 397 | + .doOnNext(this::handleMoreContextualItemClick) | ||
| 398 | + .doOnError(error -> { | ||
| 399 | + }) | ||
| 400 | + .subscribe(); | ||
| 401 | + | ||
| 402 | + mLlContextualItems.setVisibility(View.VISIBLE); | ||
| 403 | + } | ||
| 404 | + } | ||
| 405 | + } | ||
| 406 | + | ||
| 407 | + private void initViewsNew2() { | ||
| 408 | + mIvBack.setOnClickListener(this); | ||
| 409 | + mIvPopupClose.setOnClickListener(this); | ||
| 410 | + | ||
| 411 | + if (mUniqueSectionList != null) { | ||
| 412 | + String firstKey = (String) mUniqueSectionList.keySet().toArray()[0]; | ||
| 413 | + if (mUniqueSectionList.get(firstKey) != null && mUniqueSectionList.get(firstKey).size() > 0) { | ||
| 414 | + mTvResearchSection.setText(firstKey.substring(1)); | ||
| 415 | + mResearchItems.setNestedScrollingEnabled(false); | ||
| 416 | + mAdapterResearch = new MoreCampaignAdapter(this, mUniqueSectionList.get(firstKey)); | ||
| 417 | + mResearchItems.setAdapter(mAdapterResearch); | ||
| 418 | + mAdapterResearch.getPositionClicks() | ||
| 419 | + .doOnNext(this::handleMoreItemClick) | ||
| 420 | + .doOnError(error -> { | ||
| 421 | + }) | ||
| 422 | + .subscribe(); | ||
| 423 | + mAdapterResearch.notifyDataSetChanged(); | ||
| 424 | + | ||
| 425 | + mLlResearchItems.setVisibility(View.VISIBLE); | ||
| 426 | + } | ||
| 427 | + | ||
| 428 | + String secondKey = (String) mUniqueSectionList.keySet().toArray()[1]; | ||
| 429 | + if (mUniqueSectionList.get(secondKey) != null && mUniqueSectionList.get(secondKey).size() > 0) { | ||
| 430 | + mTvExclusiveSection.setText(secondKey.substring(1)); | ||
| 431 | + mExclusiveItems.setNestedScrollingEnabled(false); | ||
| 432 | + mAdapterExclusive = new MoreCampaignAdapter(this, mUniqueSectionList.get(secondKey)); | ||
| 433 | + mExclusiveItems.setAdapter(mAdapterExclusive); | ||
| 434 | + mAdapterExclusive.getPositionClicks() | ||
| 435 | + .doOnNext(this::handleMoreItemClick) | ||
| 436 | + .doOnError(error -> { | ||
| 437 | + }) | ||
| 438 | + .subscribe(); | ||
| 439 | + mAdapterExclusive.notifyDataSetChanged(); | ||
| 440 | + | ||
| 441 | + mLlExclusiveItems.setVisibility(View.VISIBLE); | ||
| 442 | + } | ||
| 443 | + | ||
| 444 | + String thirdKey = (String) mUniqueSectionList.keySet().toArray()[2]; | ||
| 445 | + if (mUniqueSectionList.get(thirdKey) != null && mUniqueSectionList.get(thirdKey).size() > 0) { | ||
| 446 | + mTvContestSection.setText(thirdKey.substring(1)); | ||
| 447 | + mContestItems.setNestedScrollingEnabled(false); | ||
| 448 | + mAdapterContest = new MoreCampaignAdapter(this, mUniqueSectionList.get(thirdKey)); | ||
| 449 | + mContestItems.setAdapter(mAdapterContest); | ||
| 450 | + mAdapterContest.getPositionClicks() | ||
| 451 | + .doOnNext(this::handleMoreItemClick) | ||
| 452 | + .doOnError(error -> { | ||
| 453 | + }) | ||
| 454 | + .subscribe(); | ||
| 455 | + mAdapterContest.notifyDataSetChanged(); | ||
| 456 | + | ||
| 457 | + mLlContestItems.setVisibility(View.VISIBLE); | ||
| 458 | + } | ||
| 459 | + | ||
| 460 | + if (mContextualList != null && mContextualList.size() > 0) { | ||
| 461 | + mTvContextualSection.setText(getString(R.string.cos_mfy_other)); | ||
| 462 | + mContextualItems.setNestedScrollingEnabled(false); | ||
| 463 | + mAdapterContextual = new MoreContextualAdapter(this, mContextualList); | ||
| 464 | + mContextualItems.setAdapter(mAdapterContextual); | ||
| 465 | + mAdapterContextual.getPositionClicks() | ||
| 466 | + .doOnNext(this::handleMoreContextualItemClick) | ||
| 467 | + .doOnError(error -> { | ||
| 468 | + }) | ||
| 469 | + .subscribe(); | ||
| 470 | + mAdapterContextual.notifyDataSetChanged(); | ||
| 471 | + | ||
| 472 | + mLlContextualItems.setVisibility(View.VISIBLE); | ||
| 473 | + } | ||
| 474 | + } | ||
| 475 | + } | ||
| 476 | + | ||
| 477 | + private void handleMoreItemClick(Campaign moreItem) { | ||
| 478 | + EventBus.getDefault().post(new WarplyEventBusManager(new LoyaltySDKFirebaseEventModel())); | ||
| 479 | + | ||
| 480 | + try { | ||
| 481 | + JSONObject extraFields = WarpJSONParser.getJSONFromString(moreItem.getExtraFields()); | ||
| 482 | + if (extraFields != null) { | ||
| 483 | + if (extraFields.has("type") && extraFields.optString("type").equals("telco")) { | ||
| 484 | + for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | ||
| 485 | + if (ccms.getLoyaltyCampaignId().equals(moreItem.getSessionUUID())) { | ||
| 486 | + Intent intent = new Intent(MoreForYouActivity.this, TelcoActivity.class); | ||
| 487 | + intent.putExtra("ccms", ccms); | ||
| 488 | + intent.putExtra("loyalty", (Serializable) moreItem); | ||
| 489 | + startActivity(intent); | ||
| 490 | + break; | ||
| 491 | + } | ||
| 492 | + } | ||
| 493 | + return; | ||
| 494 | + } | ||
| 495 | + if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { | ||
| 496 | + for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | ||
| 497 | + if (ccms.getLoyaltyCampaignId().equals(moreItem.getSessionUUID())) { | ||
| 498 | + WarpUtils.log("CCMS_CLICK " + ccms.toString()); | ||
| 499 | + startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCcmsUrl(moreItem, ccms))); | ||
| 500 | + break; | ||
| 501 | + } | ||
| 502 | + } | ||
| 503 | + } else { | ||
| 504 | + startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(moreItem))); | ||
| 505 | + } | ||
| 506 | + } | ||
| 507 | + } catch (Exception exception) { | ||
| 508 | + startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(moreItem))); | ||
| 509 | + } | ||
| 510 | + } | ||
| 511 | + | ||
| 512 | + private void handleMoreContextualItemClick(LoyaltyContextualOfferModel ccmsItem) { | ||
| 513 | + Intent intent = new Intent(MoreForYouActivity.this, ContextualActivity.class); | ||
| 514 | + intent.putExtra("ccms", ccmsItem); | ||
| 515 | + startActivity(intent); | ||
| 516 | + } | ||
| 517 | + | ||
| 288 | private void mergeDatasets(ArrayList<Campaign> campaignList, | 518 | private void mergeDatasets(ArrayList<Campaign> campaignList, |
| 289 | ArrayList<LoyaltyContextualOfferModel> ccmsList) { | 519 | ArrayList<LoyaltyContextualOfferModel> ccmsList) { |
| 290 | mData.clear(); | 520 | mData.clear(); |
| ... | @@ -310,30 +540,82 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -310,30 +540,82 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 310 | } | 540 | } |
| 311 | } | 541 | } |
| 312 | 542 | ||
| 313 | - private void filterItems() { | 543 | +// private void filterItems() { |
| 314 | - mValuesList.clear(); | 544 | +// mValuesList.clear(); |
| 315 | - ArrayList<Campaign> gfyList = new ArrayList<>(); | 545 | +// ArrayList<Campaign> gfyList = new ArrayList<>(); |
| 546 | +// if (WarplyManagerHelper.getCampaignListAll() != null && WarplyManagerHelper.getCampaignListAll().size() > 0) { | ||
| 547 | +// Log.v("Got L:{" + String.valueOf(WarplyManagerHelper.getCampaignListAll().size()) + "}", " LOYALTY campaigns"); | ||
| 548 | +// if (WarplyManagerHelper.getCCMSLoyaltyCampaigns() == null || WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() == 0) { | ||
| 549 | +// Log.v("Got C:{0}", " CCMS campaigns"); | ||
| 550 | +// for (Campaign camp : WarplyManagerHelper.getCampaignListAll()) { | ||
| 551 | +// if (camp.getOfferCategory().equals("more_for_you")) { | ||
| 552 | +// try { | ||
| 553 | +// JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); | ||
| 554 | +// if (extraFields != null) { | ||
| 555 | +// if (extraFields.length() == 0 || !(extraFields.has("ccms_offer") || extraFields.has("type"))) { | ||
| 556 | +// gfyList.add(camp); | ||
| 557 | +// } | ||
| 558 | +// } | ||
| 559 | +// } catch (Exception exception) { | ||
| 560 | +// gfyList.add(camp); | ||
| 561 | +// } | ||
| 562 | +// } | ||
| 563 | +// } | ||
| 564 | +// } else { | ||
| 565 | +// int ccmsCount = 0; | ||
| 566 | +// Log.v("Got C:{" + String.valueOf(WarplyManagerHelper.getCCMSLoyaltyCampaigns().size()) + "}", " CCMS campaigns"); | ||
| 567 | +// for (Campaign camp : WarplyManagerHelper.getCampaignListAll()) { | ||
| 568 | +// if (camp.getOfferCategory().equals("more_for_you")) { | ||
| 569 | +// try { | ||
| 570 | +// JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); | ||
| 571 | +// if (extraFields != null) { | ||
| 572 | +// if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { | ||
| 573 | +// for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | ||
| 574 | +// if (ccms.getLoyaltyCampaignId().equals(camp.getSessionUUID())) { | ||
| 575 | +// gfyList.add(camp); | ||
| 576 | +// ccmsCount++; | ||
| 577 | +// break; | ||
| 578 | +// } | ||
| 579 | +// } | ||
| 580 | +// } else { | ||
| 581 | +// gfyList.add(camp); | ||
| 582 | +// } | ||
| 583 | +// } | ||
| 584 | +// } catch (Exception exception) { | ||
| 585 | +// gfyList.add(camp); | ||
| 586 | +// } | ||
| 587 | +// } | ||
| 588 | +// } | ||
| 589 | +// Log.v("Got M:{" + String.valueOf(ccmsCount) + "}", " Matched campaigns"); | ||
| 590 | +// } | ||
| 591 | +// | ||
| 592 | +// mValuesList.addAll(gfyList); | ||
| 593 | +// } | ||
| 594 | +// } | ||
| 595 | + | ||
| 596 | + /** | ||
| 597 | + * New Implementation | ||
| 598 | + */ | ||
| 599 | + private void filterItemsNew() { | ||
| 600 | + mUniqueSectionList.clear(); | ||
| 601 | + ArrayList<Campaign> mfyList = new ArrayList<>(); | ||
| 316 | if (WarplyManagerHelper.getCampaignListAll() != null && WarplyManagerHelper.getCampaignListAll().size() > 0) { | 602 | if (WarplyManagerHelper.getCampaignListAll() != null && WarplyManagerHelper.getCampaignListAll().size() > 0) { |
| 317 | - Log.v("Got L:{" + String.valueOf(WarplyManagerHelper.getCampaignListAll().size()) + "}", " LOYALTY campaigns"); | ||
| 318 | if (WarplyManagerHelper.getCCMSLoyaltyCampaigns() == null || WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() == 0) { | 603 | if (WarplyManagerHelper.getCCMSLoyaltyCampaigns() == null || WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() == 0) { |
| 319 | - Log.v("Got C:{0}", " CCMS campaigns"); | ||
| 320 | for (Campaign camp : WarplyManagerHelper.getCampaignListAll()) { | 604 | for (Campaign camp : WarplyManagerHelper.getCampaignListAll()) { |
| 321 | if (camp.getOfferCategory().equals("more_for_you")) { | 605 | if (camp.getOfferCategory().equals("more_for_you")) { |
| 322 | try { | 606 | try { |
| 323 | JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); | 607 | JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields()); |
| 324 | if (extraFields != null) { | 608 | if (extraFields != null) { |
| 325 | if (extraFields.length() == 0 || !(extraFields.has("ccms_offer") || extraFields.has("type"))) { | 609 | if (extraFields.length() == 0 || !(extraFields.has("ccms_offer") || extraFields.has("type"))) { |
| 326 | - gfyList.add(camp); | 610 | + mfyList.add(camp); |
| 327 | } | 611 | } |
| 328 | } | 612 | } |
| 329 | } catch (Exception exception) { | 613 | } catch (Exception exception) { |
| 330 | - gfyList.add(camp); | 614 | + mfyList.add(camp); |
| 331 | } | 615 | } |
| 332 | } | 616 | } |
| 333 | } | 617 | } |
| 334 | } else { | 618 | } else { |
| 335 | - int ccmsCount = 0; | ||
| 336 | - Log.v("Got C:{" + String.valueOf(WarplyManagerHelper.getCCMSLoyaltyCampaigns().size()) + "}", " CCMS campaigns"); | ||
| 337 | for (Campaign camp : WarplyManagerHelper.getCampaignListAll()) { | 619 | for (Campaign camp : WarplyManagerHelper.getCampaignListAll()) { |
| 338 | if (camp.getOfferCategory().equals("more_for_you")) { | 620 | if (camp.getOfferCategory().equals("more_for_you")) { |
| 339 | try { | 621 | try { |
| ... | @@ -342,26 +624,46 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -342,26 +624,46 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
| 342 | if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { | 624 | if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) { |
| 343 | for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { | 625 | for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) { |
| 344 | if (ccms.getLoyaltyCampaignId().equals(camp.getSessionUUID())) { | 626 | if (ccms.getLoyaltyCampaignId().equals(camp.getSessionUUID())) { |
| 345 | - gfyList.add(camp); | 627 | + mfyList.add(camp); |
| 346 | - ccmsCount++; | ||
| 347 | break; | 628 | break; |
| 348 | } | 629 | } |
| 349 | } | 630 | } |
| 350 | } else { | 631 | } else { |
| 351 | - gfyList.add(camp); | 632 | + mfyList.add(camp); |
| 352 | } | 633 | } |
| 353 | } | 634 | } |
| 354 | } catch (Exception exception) { | 635 | } catch (Exception exception) { |
| 355 | - gfyList.add(camp); | 636 | + mfyList.add(camp); |
| 637 | + } | ||
| 638 | + } | ||
| 639 | + } | ||
| 640 | + } | ||
| 641 | + | ||
| 642 | + if (mfyList != null && mfyList.size() > 0) { | ||
| 643 | + for (Campaign campaignItem : mfyList) { | ||
| 644 | + JSONObject extraFields = WarpJSONParser.getJSONFromString(campaignItem.getExtraFields()); | ||
| 645 | + if (extraFields != null && extraFields.has("category_title")) { | ||
| 646 | + String categoryTitle = extraFields.optString("category_title"); | ||
| 647 | + | ||
| 648 | + if (mUniqueSectionList.containsKey(categoryTitle.trim())) { | ||
| 649 | + CampaignList tempCampaignList = (CampaignList) mUniqueSectionList.get(categoryTitle.trim()); | ||
| 650 | + tempCampaignList.add(campaignItem); | ||
| 651 | + mUniqueSectionList.put(categoryTitle.trim(), tempCampaignList); | ||
| 652 | + } else { | ||
| 653 | + CampaignList tempCampaignList = new CampaignList(); | ||
| 654 | + tempCampaignList.add(campaignItem); | ||
| 655 | + mUniqueSectionList.put(categoryTitle.trim(), tempCampaignList); | ||
| 356 | } | 656 | } |
| 357 | } | 657 | } |
| 358 | } | 658 | } |
| 359 | - Log.v("Got M:{" + String.valueOf(ccmsCount) + "}", " Matched campaigns"); | ||
| 360 | } | 659 | } |
| 361 | 660 | ||
| 362 | - mValuesList.addAll(gfyList); | 661 | + Map<String, ArrayList<Campaign>> treeMap = new TreeMap<String, ArrayList<Campaign>>(mUniqueSectionList); |
| 662 | + mUniqueSectionList.clear(); | ||
| 663 | + mUniqueSectionList = treeMap; | ||
| 363 | } | 664 | } |
| 364 | } | 665 | } |
| 666 | + /** New Implementation */ | ||
| 365 | 667 | ||
| 366 | // =========================================================== | 668 | // =========================================================== |
| 367 | // Inner and Anonymous Classes | 669 | // Inner and Anonymous Classes | ... | ... |
| ... | @@ -31,17 +31,17 @@ package ly.warp.sdk.io.models; | ... | @@ -31,17 +31,17 @@ package ly.warp.sdk.io.models; |
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | public class HealthEventModel { | 33 | public class HealthEventModel { |
| 34 | - private double steps; | 34 | + private double meters; |
| 35 | 35 | ||
| 36 | public HealthEventModel() { | 36 | public HealthEventModel() { |
| 37 | - this.steps = 0.0d; | 37 | + this.meters = 0.0d; |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | - public double getSteps() { | 40 | + public double getMeters() { |
| 41 | - return steps; | 41 | + return meters; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | - public void setSteps(double steps) { | 44 | + public void setMeters(double meters) { |
| 45 | - this.steps = steps; | 45 | + this.meters = meters; |
| 46 | } | 46 | } |
| 47 | } | 47 | } | ... | ... |
| ... | @@ -211,7 +211,7 @@ public class WarplyHealthService extends Service implements SensorEventListener | ... | @@ -211,7 +211,7 @@ public class WarplyHealthService extends Service implements SensorEventListener |
| 211 | mSteps++; | 211 | mSteps++; |
| 212 | mStepsAll++; | 212 | mStepsAll++; |
| 213 | HealthEventModel healthSteps = new HealthEventModel(); | 213 | HealthEventModel healthSteps = new HealthEventModel(); |
| 214 | - healthSteps.setSteps((mStepsAll * 0.762)); | 214 | + healthSteps.setMeters((mStepsAll * 0.762)); |
| 215 | EventBus.getDefault().post(new WarplyEventBusManager(healthSteps)); | 215 | EventBus.getDefault().post(new WarplyEventBusManager(healthSteps)); |
| 216 | WarpUtils.setStepsMetersCounter(this, (mStepsAll * 0.762)); | 216 | WarpUtils.setStepsMetersCounter(this, (mStepsAll * 0.762)); |
| 217 | WarpUtils.setStepsCounter(this, mSteps); | 217 | WarpUtils.setStepsCounter(this, mSteps); | ... | ... |
| ... | @@ -745,7 +745,7 @@ public class WarplyManagerHelper { | ... | @@ -745,7 +745,7 @@ public class WarplyManagerHelper { |
| 745 | */ | 745 | */ |
| 746 | public static void setSeasonalList(ArrayList<LoyaltyGiftsForYouPackage> seasonalCoupons) { | 746 | public static void setSeasonalList(ArrayList<LoyaltyGiftsForYouPackage> seasonalCoupons) { |
| 747 | mSeasonalList.clear(); | 747 | mSeasonalList.clear(); |
| 748 | - mSeasonalList.addAll(seasonalCoupons); | 748 | + mSeasonalList = seasonalCoupons; |
| 749 | } | 749 | } |
| 750 | 750 | ||
| 751 | /** | 751 | /** | ... | ... |
| ... | @@ -22,8 +22,7 @@ import io.reactivex.subjects.PublishSubject; | ... | @@ -22,8 +22,7 @@ import io.reactivex.subjects.PublishSubject; |
| 22 | import ly.warp.sdk.R; | 22 | import ly.warp.sdk.R; |
| 23 | import ly.warp.sdk.io.models.Campaign; | 23 | import ly.warp.sdk.io.models.Campaign; |
| 24 | 24 | ||
| 25 | - | 25 | +public class MoreCampaignAdapter extends RecyclerView.Adapter<MoreCampaignAdapter.MoreCampaignViewHolder> { |
| 26 | -public class MoreCampaignAdapter extends RecyclerView.Adapter<MoreCampaignAdapter.ProfileCampaignViewHolder> { | ||
| 27 | 26 | ||
| 28 | private Context mContext; | 27 | private Context mContext; |
| 29 | private ArrayList<Campaign> mCampaigns; | 28 | private ArrayList<Campaign> mCampaigns; |
| ... | @@ -34,25 +33,17 @@ public class MoreCampaignAdapter extends RecyclerView.Adapter<MoreCampaignAdapte | ... | @@ -34,25 +33,17 @@ public class MoreCampaignAdapter extends RecyclerView.Adapter<MoreCampaignAdapte |
| 34 | this.mCampaigns = campaignList; | 33 | this.mCampaigns = campaignList; |
| 35 | } | 34 | } |
| 36 | 35 | ||
| 37 | - public class ProfileCampaignViewHolder extends RecyclerView.ViewHolder { | 36 | + public class MoreCampaignViewHolder extends RecyclerView.ViewHolder { |
| 38 | private ImageView ivCampaignTitle, ivIsNew; | 37 | private ImageView ivCampaignTitle, ivIsNew; |
| 39 | private TextView tvCampaignTitle, tvCampaignSubtitle, tvCampaignMessage; | 38 | private TextView tvCampaignTitle, tvCampaignSubtitle, tvCampaignMessage; |
| 40 | 39 | ||
| 41 | - public ProfileCampaignViewHolder(View view) { | 40 | + public MoreCampaignViewHolder(View view) { |
| 42 | - super(view); | ||
| 43 | - ivCampaignTitle = view.findViewById(R.id.iv_campaign_logo); | ||
| 44 | - tvCampaignTitle = view.findViewById(R.id.tv_campaign_title); | ||
| 45 | - } | ||
| 46 | - | ||
| 47 | - public ProfileCampaignViewHolder(View view, boolean vertical) { | ||
| 48 | super(view); | 41 | super(view); |
| 49 | ivCampaignTitle = view.findViewById(R.id.iv_campaign_logo); | 42 | ivCampaignTitle = view.findViewById(R.id.iv_campaign_logo); |
| 50 | tvCampaignTitle = view.findViewById(R.id.tv_campaign_title); | 43 | tvCampaignTitle = view.findViewById(R.id.tv_campaign_title); |
| 51 | ivIsNew = view.findViewById(R.id.iv_campaign_new); | 44 | ivIsNew = view.findViewById(R.id.iv_campaign_new); |
| 52 | - if (vertical) { | 45 | + tvCampaignSubtitle = view.findViewById(R.id.tv_campaign_subtitle); |
| 53 | - tvCampaignSubtitle = view.findViewById(R.id.tv_campaign_subtitle); | 46 | + tvCampaignMessage = view.findViewById(R.id.tv_campaign_message); |
| 54 | - tvCampaignMessage = view.findViewById(R.id.tv_campaign_message); | ||
| 55 | - } | ||
| 56 | } | 47 | } |
| 57 | } | 48 | } |
| 58 | 49 | ||
| ... | @@ -76,15 +67,15 @@ public class MoreCampaignAdapter extends RecyclerView.Adapter<MoreCampaignAdapte | ... | @@ -76,15 +67,15 @@ public class MoreCampaignAdapter extends RecyclerView.Adapter<MoreCampaignAdapte |
| 76 | } | 67 | } |
| 77 | 68 | ||
| 78 | @Override | 69 | @Override |
| 79 | - public ProfileCampaignViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | 70 | + public MoreCampaignViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { |
| 80 | View itemView; | 71 | View itemView; |
| 81 | 72 | ||
| 82 | itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_profile_recycler_vertical, parent, false); | 73 | itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_profile_recycler_vertical, parent, false); |
| 83 | - return new ProfileCampaignViewHolder(itemView, true); | 74 | + return new MoreCampaignViewHolder(itemView); |
| 84 | } | 75 | } |
| 85 | 76 | ||
| 86 | @Override | 77 | @Override |
| 87 | - public void onBindViewHolder(final ProfileCampaignViewHolder holder, int position) { | 78 | + public void onBindViewHolder(final MoreCampaignViewHolder holder, int position) { |
| 88 | Campaign campaignItem = mCampaigns.get(position); | 79 | Campaign campaignItem = mCampaigns.get(position); |
| 89 | 80 | ||
| 90 | if (campaignItem != null) { | 81 | if (campaignItem != null) { | ... | ... |
| 1 | +package ly.warp.sdk.views.adapters; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.text.TextUtils; | ||
| 5 | +import android.view.LayoutInflater; | ||
| 6 | +import android.view.View; | ||
| 7 | +import android.view.ViewGroup; | ||
| 8 | +import android.widget.ImageView; | ||
| 9 | +import android.widget.TextView; | ||
| 10 | + | ||
| 11 | +import androidx.recyclerview.widget.RecyclerView; | ||
| 12 | + | ||
| 13 | +import com.bumptech.glide.Glide; | ||
| 14 | +import com.bumptech.glide.load.engine.DiskCacheStrategy; | ||
| 15 | +import com.bumptech.glide.load.resource.bitmap.CenterCrop; | ||
| 16 | +import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | ||
| 17 | + | ||
| 18 | +import java.util.ArrayList; | ||
| 19 | + | ||
| 20 | +import io.reactivex.Observable; | ||
| 21 | +import io.reactivex.subjects.PublishSubject; | ||
| 22 | +import ly.warp.sdk.R; | ||
| 23 | +import ly.warp.sdk.io.models.Campaign; | ||
| 24 | +import ly.warp.sdk.io.models.LoyaltyContextualOfferModel; | ||
| 25 | + | ||
| 26 | +public class MoreContextualAdapter extends RecyclerView.Adapter<MoreContextualAdapter.MoreContextualViewHolder> { | ||
| 27 | + | ||
| 28 | + private Context mContext; | ||
| 29 | + private ArrayList<LoyaltyContextualOfferModel> mCampaigns; | ||
| 30 | + private final PublishSubject<LoyaltyContextualOfferModel> onClickSubject = PublishSubject.create(); | ||
| 31 | + | ||
| 32 | + public MoreContextualAdapter(Context mContext, ArrayList<LoyaltyContextualOfferModel> campaignList) { | ||
| 33 | + this.mContext = mContext; | ||
| 34 | + this.mCampaigns = campaignList; | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + public class MoreContextualViewHolder extends RecyclerView.ViewHolder { | ||
| 38 | + private ImageView ivCampaignTitle, ivIsNew; | ||
| 39 | + private TextView tvCampaignTitle, tvCampaignSubtitle, tvCampaignMessage; | ||
| 40 | + | ||
| 41 | + public MoreContextualViewHolder(View view) { | ||
| 42 | + super(view); | ||
| 43 | + ivCampaignTitle = view.findViewById(R.id.iv_campaign_logo); | ||
| 44 | + tvCampaignTitle = view.findViewById(R.id.tv_campaign_title); | ||
| 45 | + ivIsNew = view.findViewById(R.id.iv_campaign_new); | ||
| 46 | + tvCampaignSubtitle = view.findViewById(R.id.tv_campaign_subtitle); | ||
| 47 | + tvCampaignMessage = view.findViewById(R.id.tv_campaign_message); | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + public int getItemCount() { | ||
| 53 | + if (mCampaigns == null) | ||
| 54 | + return 0; | ||
| 55 | + else | ||
| 56 | + return mCampaigns.size(); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + public LoyaltyContextualOfferModel getItem(int id) { | ||
| 61 | + return mCampaigns.get(id); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public void updateData(ArrayList<LoyaltyContextualOfferModel> campaignList) { | ||
| 65 | + mCampaigns.clear(); | ||
| 66 | + mCampaigns.addAll(campaignList); | ||
| 67 | + notifyDataSetChanged(); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + @Override | ||
| 71 | + public MoreContextualViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
| 72 | + View itemView; | ||
| 73 | + | ||
| 74 | + itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_profile_recycler_vertical, parent, false); | ||
| 75 | + return new MoreContextualViewHolder(itemView); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + @Override | ||
| 79 | + public void onBindViewHolder(final MoreContextualViewHolder holder, int position) { | ||
| 80 | + LoyaltyContextualOfferModel campaignItem = mCampaigns.get(position); | ||
| 81 | + | ||
| 82 | + if (campaignItem != null) { | ||
| 83 | + if (!TextUtils.isEmpty(campaignItem.getImageUrl())) { | ||
| 84 | + Glide.with(mContext) | ||
| 85 | + .load(campaignItem.getImageUrl()) | ||
| 86 | + .transform(new CenterCrop(), new RoundedCorners(4)) | ||
| 87 | + .diskCacheStrategy(DiskCacheStrategy.DATA) | ||
| 88 | + .into(holder.ivCampaignTitle); | ||
| 89 | + } else { | ||
| 90 | + Glide.with(mContext) | ||
| 91 | + .load(R.drawable.ic_cosmote_logo_horizontal_grey) | ||
| 92 | + .into(holder.ivCampaignTitle); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + holder.tvCampaignTitle.setText(campaignItem.getTitle()); | ||
| 96 | + holder.tvCampaignSubtitle.setText(campaignItem.getSubtitle()); | ||
| 97 | + holder.tvCampaignMessage.setText(campaignItem.getMessage()); | ||
| 98 | + holder.ivIsNew.setVisibility(View.GONE); | ||
| 99 | + | ||
| 100 | + holder.itemView.setOnClickListener(v -> onClickSubject.onNext(campaignItem)); | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public Observable<LoyaltyContextualOfferModel> getPositionClicks() { | ||
| 105 | + return onClickSubject.cache(); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | +} |
| ... | @@ -25,13 +25,13 @@ | ... | @@ -25,13 +25,13 @@ |
| 25 | 25 | ||
| 26 | <TextView | 26 | <TextView |
| 27 | android:id="@+id/textView3" | 27 | android:id="@+id/textView3" |
| 28 | + fontPath="fonts/pf_square_sans_pro_bold.ttf" | ||
| 28 | android:layout_width="206dp" | 29 | android:layout_width="206dp" |
| 29 | android:layout_height="32dp" | 30 | android:layout_height="32dp" |
| 30 | android:gravity="center" | 31 | android:gravity="center" |
| 32 | + android:text="@string/cos_more_title" | ||
| 31 | android:textColor="@color/grey" | 33 | android:textColor="@color/grey" |
| 32 | android:textSize="17sp" | 34 | android:textSize="17sp" |
| 33 | - fontPath="fonts/pf_square_sans_pro_bold.ttf" | ||
| 34 | - android:text="@string/cos_more_title" | ||
| 35 | app:layout_constraintBottom_toBottomOf="parent" | 35 | app:layout_constraintBottom_toBottomOf="parent" |
| 36 | app:layout_constraintEnd_toEndOf="parent" | 36 | app:layout_constraintEnd_toEndOf="parent" |
| 37 | app:layout_constraintHorizontal_bias="0.356" | 37 | app:layout_constraintHorizontal_bias="0.356" |
| ... | @@ -46,62 +46,188 @@ | ... | @@ -46,62 +46,188 @@ |
| 46 | android:background="@drawable/shape_cos_loyalty" | 46 | android:background="@drawable/shape_cos_loyalty" |
| 47 | android:orientation="vertical"> | 47 | android:orientation="vertical"> |
| 48 | 48 | ||
| 49 | - <LinearLayout | 49 | + <ScrollView |
| 50 | - android:id="@+id/ll_more_popup" | ||
| 51 | android:layout_width="match_parent" | 50 | android:layout_width="match_parent" |
| 52 | - android:layout_height="wrap_content" | 51 | + android:layout_height="match_parent" |
| 53 | - android:layout_marginTop="24dp" | 52 | + android:fillViewport="true"> |
| 54 | - android:background="@drawable/shape_cos_gradient5" | ||
| 55 | - android:orientation="vertical" | ||
| 56 | - android:paddingVertical="16dp" | ||
| 57 | - android:visibility="gone" | ||
| 58 | - tools:visibility="visible"> | ||
| 59 | - | ||
| 60 | - <ImageView | ||
| 61 | - android:id="@+id/iv_popup_more_close" | ||
| 62 | - android:layout_width="20dp" | ||
| 63 | - android:layout_height="20dp" | ||
| 64 | - android:layout_marginStart="16dp" | ||
| 65 | - android:src="@drawable/ic_close_white" /> | ||
| 66 | - | ||
| 67 | - <ImageView | ||
| 68 | - android:layout_width="48dp" | ||
| 69 | - android:layout_height="wrap_content" | ||
| 70 | - android:layout_gravity="center" | ||
| 71 | - android:scaleType="centerInside" | ||
| 72 | - android:src="@drawable/ic_heart" /> | ||
| 73 | 53 | ||
| 74 | - <TextView | 54 | + <RelativeLayout |
| 75 | - android:layout_width="wrap_content" | 55 | + android:layout_width="match_parent" |
| 76 | - android:layout_height="wrap_content" | ||
| 77 | - android:layout_gravity="center" | ||
| 78 | - android:layout_marginTop="8dp" | ||
| 79 | - android:layout_marginBottom="12dp" | ||
| 80 | - android:text="@string/cos_popup_more_title" | ||
| 81 | - android:textColor="@android:color/white" | ||
| 82 | - android:textSize="18sp" | ||
| 83 | - android:textStyle="bold" /> | ||
| 84 | - | ||
| 85 | - <TextView | ||
| 86 | - android:layout_width="wrap_content" | ||
| 87 | android:layout_height="wrap_content" | 56 | android:layout_height="wrap_content" |
| 88 | - android:layout_gravity="center" | 57 | + android:orientation="vertical"> |
| 89 | - android:layout_marginHorizontal="40dp" | 58 | + |
| 90 | - android:gravity="center" | 59 | + <LinearLayout |
| 91 | - android:text="@string/cos_popup_more_subtitle" | 60 | + android:id="@+id/ll_more_popup" |
| 92 | - android:textColor="@android:color/white" | 61 | + android:layout_width="match_parent" |
| 93 | - android:textSize="16sp" /> | 62 | + android:layout_height="wrap_content" |
| 94 | - </LinearLayout> | 63 | + android:layout_marginTop="24dp" |
| 95 | - | 64 | + android:background="@drawable/shape_cos_gradient5" |
| 96 | - <androidx.recyclerview.widget.RecyclerView | 65 | + android:orientation="vertical" |
| 97 | - android:id="@+id/rv_more_items" | 66 | + android:paddingVertical="16dp" |
| 98 | - android:layout_width="match_parent" | 67 | + android:visibility="gone" |
| 99 | - android:layout_height="match_parent" | 68 | + tools:visibility="gone"> |
| 100 | - android:layout_below="@+id/ll_more_popup" | 69 | + |
| 101 | - android:layout_marginTop="4dp" | 70 | + <ImageView |
| 102 | - android:clipToPadding="false" | 71 | + android:id="@+id/iv_popup_more_close" |
| 103 | - android:orientation="vertical" | 72 | + android:layout_width="20dp" |
| 104 | - android:paddingTop="44dp" | 73 | + android:layout_height="20dp" |
| 105 | - android:paddingBottom="24dp" /> | 74 | + android:layout_marginStart="16dp" |
| 75 | + android:src="@drawable/ic_close_white" /> | ||
| 76 | + | ||
| 77 | + <ImageView | ||
| 78 | + android:layout_width="48dp" | ||
| 79 | + android:layout_height="wrap_content" | ||
| 80 | + android:layout_gravity="center" | ||
| 81 | + android:scaleType="centerInside" | ||
| 82 | + android:src="@drawable/ic_heart" /> | ||
| 83 | + | ||
| 84 | + <TextView | ||
| 85 | + android:layout_width="wrap_content" | ||
| 86 | + android:layout_height="wrap_content" | ||
| 87 | + android:layout_gravity="center" | ||
| 88 | + android:layout_marginTop="8dp" | ||
| 89 | + android:layout_marginBottom="12dp" | ||
| 90 | + android:text="@string/cos_popup_more_title" | ||
| 91 | + android:textColor="@android:color/white" | ||
| 92 | + android:textSize="18sp" | ||
| 93 | + android:textStyle="bold" /> | ||
| 94 | + | ||
| 95 | + <TextView | ||
| 96 | + android:layout_width="wrap_content" | ||
| 97 | + android:layout_height="wrap_content" | ||
| 98 | + android:layout_gravity="center" | ||
| 99 | + android:layout_marginHorizontal="40dp" | ||
| 100 | + android:gravity="center" | ||
| 101 | + android:text="@string/cos_popup_more_subtitle" | ||
| 102 | + android:textColor="@android:color/white" | ||
| 103 | + android:textSize="16sp" /> | ||
| 104 | + </LinearLayout> | ||
| 105 | + | ||
| 106 | + <androidx.recyclerview.widget.RecyclerView | ||
| 107 | + android:id="@+id/rv_more_items" | ||
| 108 | + android:layout_width="match_parent" | ||
| 109 | + android:layout_height="match_parent" | ||
| 110 | + android:layout_below="@+id/ll_more_popup" | ||
| 111 | + android:layout_marginTop="4dp" | ||
| 112 | + android:clipToPadding="false" | ||
| 113 | + android:orientation="vertical" | ||
| 114 | + android:paddingTop="44dp" | ||
| 115 | + android:paddingBottom="24dp" | ||
| 116 | + android:visibility="gone" /> | ||
| 117 | + | ||
| 118 | + <LinearLayout | ||
| 119 | + android:id="@+id/ll_research_items" | ||
| 120 | + android:layout_width="match_parent" | ||
| 121 | + android:layout_height="wrap_content" | ||
| 122 | + android:layout_below="@+id/ll_more_popup" | ||
| 123 | + android:orientation="vertical" | ||
| 124 | + android:paddingTop="44dp" | ||
| 125 | + android:visibility="gone"> | ||
| 126 | + | ||
| 127 | + <TextView | ||
| 128 | + android:id="@+id/tv_research_section" | ||
| 129 | + fontPath="fonts/pf_square_sans_pro_bold.ttf" | ||
| 130 | + android:layout_width="wrap_content" | ||
| 131 | + android:layout_height="wrap_content" | ||
| 132 | + android:layout_marginHorizontal="16dp" | ||
| 133 | + android:textColor="@android:color/white" | ||
| 134 | + android:textSize="16sp" | ||
| 135 | + tools:text="ΕΡΕΥΝΑ" /> | ||
| 136 | + | ||
| 137 | + <androidx.recyclerview.widget.RecyclerView | ||
| 138 | + android:id="@+id/rv_research_items" | ||
| 139 | + android:layout_width="match_parent" | ||
| 140 | + android:layout_height="wrap_content" | ||
| 141 | + android:layout_marginTop="4dp" | ||
| 142 | + android:clipToPadding="false" | ||
| 143 | + android:orientation="vertical" | ||
| 144 | + android:paddingBottom="4dp" /> | ||
| 145 | + </LinearLayout> | ||
| 146 | + | ||
| 147 | + <LinearLayout | ||
| 148 | + android:id="@+id/ll_exclusive_items" | ||
| 149 | + android:layout_width="match_parent" | ||
| 150 | + android:layout_height="wrap_content" | ||
| 151 | + android:layout_below="@+id/ll_research_items" | ||
| 152 | + android:orientation="vertical" | ||
| 153 | + android:visibility="gone"> | ||
| 154 | + | ||
| 155 | + <TextView | ||
| 156 | + android:id="@+id/tv_exclusive_section" | ||
| 157 | + fontPath="fonts/pf_square_sans_pro_bold.ttf" | ||
| 158 | + android:layout_width="wrap_content" | ||
| 159 | + android:layout_height="wrap_content" | ||
| 160 | + android:layout_marginHorizontal="16dp" | ||
| 161 | + android:textColor="@android:color/white" | ||
| 162 | + android:textSize="16sp" | ||
| 163 | + tools:text="ΕΡΕΥΝΑ" /> | ||
| 164 | + | ||
| 165 | + <androidx.recyclerview.widget.RecyclerView | ||
| 166 | + android:id="@+id/rv_exclusive_items" | ||
| 167 | + android:layout_width="match_parent" | ||
| 168 | + android:layout_height="wrap_content" | ||
| 169 | + android:layout_marginTop="4dp" | ||
| 170 | + android:clipToPadding="false" | ||
| 171 | + android:orientation="vertical" | ||
| 172 | + android:paddingBottom="4dp" /> | ||
| 173 | + </LinearLayout> | ||
| 174 | + | ||
| 175 | + <LinearLayout | ||
| 176 | + android:id="@+id/ll_contest_items" | ||
| 177 | + android:layout_width="match_parent" | ||
| 178 | + android:layout_height="wrap_content" | ||
| 179 | + android:layout_below="@+id/ll_exclusive_items" | ||
| 180 | + android:orientation="vertical" | ||
| 181 | + android:visibility="gone"> | ||
| 182 | + | ||
| 183 | + <TextView | ||
| 184 | + android:id="@+id/tv_contest_section" | ||
| 185 | + fontPath="fonts/pf_square_sans_pro_bold.ttf" | ||
| 186 | + android:layout_width="wrap_content" | ||
| 187 | + android:layout_height="wrap_content" | ||
| 188 | + android:layout_marginHorizontal="16dp" | ||
| 189 | + android:textColor="@android:color/white" | ||
| 190 | + android:textSize="16sp" | ||
| 191 | + tools:text="ΕΡΕΥΝΑ" /> | ||
| 192 | + | ||
| 193 | + <androidx.recyclerview.widget.RecyclerView | ||
| 194 | + android:id="@+id/rv_contest_items" | ||
| 195 | + android:layout_width="match_parent" | ||
| 196 | + android:layout_height="wrap_content" | ||
| 197 | + android:layout_marginTop="4dp" | ||
| 198 | + android:clipToPadding="false" | ||
| 199 | + android:orientation="vertical" | ||
| 200 | + android:paddingBottom="4dp" /> | ||
| 201 | + </LinearLayout> | ||
| 202 | + | ||
| 203 | + <LinearLayout | ||
| 204 | + android:id="@+id/ll_contextual_items" | ||
| 205 | + android:layout_width="match_parent" | ||
| 206 | + android:layout_height="wrap_content" | ||
| 207 | + android:layout_below="@+id/ll_contest_items" | ||
| 208 | + android:orientation="vertical" | ||
| 209 | + android:visibility="gone"> | ||
| 210 | + | ||
| 211 | + <TextView | ||
| 212 | + android:id="@+id/tv_contextual_section" | ||
| 213 | + fontPath="fonts/pf_square_sans_pro_bold.ttf" | ||
| 214 | + android:layout_width="wrap_content" | ||
| 215 | + android:layout_height="wrap_content" | ||
| 216 | + android:layout_marginHorizontal="16dp" | ||
| 217 | + android:textColor="@android:color/white" | ||
| 218 | + android:textSize="16sp" | ||
| 219 | + tools:text="ΕΡΕΥΝΑ" /> | ||
| 220 | + | ||
| 221 | + <androidx.recyclerview.widget.RecyclerView | ||
| 222 | + android:id="@+id/rv_contextual_items" | ||
| 223 | + android:layout_width="match_parent" | ||
| 224 | + android:layout_height="wrap_content" | ||
| 225 | + android:layout_marginTop="4dp" | ||
| 226 | + android:clipToPadding="false" | ||
| 227 | + android:orientation="vertical" | ||
| 228 | + android:paddingBottom="4dp" /> | ||
| 229 | + </LinearLayout> | ||
| 230 | + </RelativeLayout> | ||
| 231 | + </ScrollView> | ||
| 106 | </RelativeLayout> | 232 | </RelativeLayout> |
| 107 | </RelativeLayout> | 233 | </RelativeLayout> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -132,6 +132,7 @@ | ... | @@ -132,6 +132,7 @@ |
| 132 | <string name="cos_empty_shared_coupons">Δεν έχεις μοιραστεί ακόμη κουπόνια</string> | 132 | <string name="cos_empty_shared_coupons">Δεν έχεις μοιραστεί ακόμη κουπόνια</string> |
| 133 | <string name="cos_empty_expired_coupons">Δεν έχεις εξαργυρώσει ακόμη κουπόνια</string> | 133 | <string name="cos_empty_expired_coupons">Δεν έχεις εξαργυρώσει ακόμη κουπόνια</string> |
| 134 | <string name="cos_dlg_pacing_goal">Πέτυχες το στόχο του μήνα! Διάλεξε το δώρο που επιθυμείς να ενεργοποιήσεις!</string> | 134 | <string name="cos_dlg_pacing_goal">Πέτυχες το στόχο του μήνα! Διάλεξε το δώρο που επιθυμείς να ενεργοποιήσεις!</string> |
| 135 | + <string name="cos_mfy_other">ΆΛΛΕΣ</string> | ||
| 135 | 136 | ||
| 136 | <string-array name="coupons_array"> | 137 | <string-array name="coupons_array"> |
| 137 | <item>Κουπόνια</item> | 138 | <item>Κουπόνια</item> | ... | ... |
-
Please register or login to post a comment