Toggle navigation
Toggle navigation
This project
Loading...
Sign in
open-source
/
warply_android_sdk_maven_plugin
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Panagiotis Triantafyllou
2022-09-07 19:01:02 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8b713b909facd16bc1c8a5b312f00a77558348d9
8b713b90
1 parent
579ef8b5
new mfy ui
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
609 additions
and
81 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/activities/MoreForYouActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/HealthEventModel.java
warply_android_sdk/src/main/java/ly/warp/sdk/services/WarplyHealthService.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
warply_android_sdk/src/main/java/ly/warp/sdk/views/adapters/MoreCampaignAdapter.java
warply_android_sdk/src/main/java/ly/warp/sdk/views/adapters/MoreContextualAdapter.java
warply_android_sdk/src/main/res/layout/activity_more_for_you.xml
warply_android_sdk/src/main/res/values/strings.xml
warply_android_sdk/src/main/java/ly/warp/sdk/activities/MoreForYouActivity.java
View file @
8b713b9
...
...
@@ -4,7 +4,6 @@ import android.app.Activity;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.os.Parcelable
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.view.View
;
...
...
@@ -21,24 +20,24 @@ import org.json.JSONObject;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.TreeMap
;
import
io.github.inflationx.viewpump.ViewPumpContextWrapper
;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.io.models.Campaign
;
import
ly.warp.sdk.io.models.CampaignList
;
import
ly.warp.sdk.io.models.LoyaltyContextualOfferModel
;
import
ly.warp.sdk.io.models.LoyaltyGiftsForYouPackage
;
import
ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel
;
import
ly.warp.sdk.io.models.MergedGifts
;
import
ly.warp.sdk.io.models.MergedMore
;
import
ly.warp.sdk.utils.WarpJSONParser
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.utils.WarplyManagerHelper
;
import
ly.warp.sdk.utils.managers.WarplyEventBusManager
;
import
ly.warp.sdk.views.adapters.MergedGiftsAdapter
;
import
ly.warp.sdk.views.adapters.MergedMoreAdapter
;
import
ly.warp.sdk.views.adapters.MoreCampaignAdapter
;
import
ly.warp.sdk.views.adapters.MoreContextualAdapter
;
public
class
MoreForYouActivity
extends
Activity
implements
View
.
OnClickListener
{
...
...
@@ -58,14 +57,35 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
private
MergedMoreAdapter
mAdapterMergedMore
;
private
LinearLayout
mLlMorePopup
;
private
ArrayList
<
Campaign
>
mValuesList
=
new
ArrayList
<>();
// private HashSet<Campaign> mHashSetList = new HashSet<>();
private
ArrayList
<
LoyaltyContextualOfferModel
>
mContextualList
=
new
ArrayList
<>();
private
ArrayList
<
MergedMore
>
mData
=
new
ArrayList
();
/**
* New Implementation
*/
private
Map
<
String
,
ArrayList
<
Campaign
>>
mUniqueSectionList
=
new
HashMap
<>();
private
RecyclerView
mResearchItems
;
private
TextView
mTvResearchSection
;
private
LinearLayout
mLlResearchItems
;
private
RecyclerView
mExclusiveItems
;
private
TextView
mTvExclusiveSection
;
private
LinearLayout
mLlExclusiveItems
;
private
RecyclerView
mContestItems
;
private
TextView
mTvContestSection
;
private
LinearLayout
mLlContestItems
;
private
MoreCampaignAdapter
mAdapterResearch
,
mAdapterExclusive
,
mAdapterContest
;
private
RecyclerView
mContextualItems
;
private
TextView
mTvContextualSection
;
private
LinearLayout
mLlContextualItems
;
private
MoreContextualAdapter
mAdapterContextual
;
/**
* New Implementation
*/
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
...
...
@@ -78,13 +98,26 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mRecyclerMore
=
findViewById
(
R
.
id
.
rv_more_items
);
// if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) {
// mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("more_for_you"));
// mValuesList.clear();
// mValuesList.addAll(mHashSetList);
// }
filterItems
();
/** New Implementation */
mTvResearchSection
=
findViewById
(
R
.
id
.
tv_research_section
);
mLlResearchItems
=
findViewById
(
R
.
id
.
ll_research_items
);
mResearchItems
=
findViewById
(
R
.
id
.
rv_research_items
);
mTvExclusiveSection
=
findViewById
(
R
.
id
.
tv_exclusive_section
);
mLlExclusiveItems
=
findViewById
(
R
.
id
.
ll_exclusive_items
);
mExclusiveItems
=
findViewById
(
R
.
id
.
rv_exclusive_items
);
mTvContestSection
=
findViewById
(
R
.
id
.
tv_contest_section
);
mLlContestItems
=
findViewById
(
R
.
id
.
ll_contest_items
);
mContestItems
=
findViewById
(
R
.
id
.
rv_contest_items
);
mTvContextualSection
=
findViewById
(
R
.
id
.
tv_contextual_section
);
mLlContextualItems
=
findViewById
(
R
.
id
.
ll_contextual_items
);
mContextualItems
=
findViewById
(
R
.
id
.
rv_contextual_items
);
/** New Implementation */
// filterItems();
/** New Implementation */
filterItemsNew
();
/** New Implementation */
if
(
WarplyManagerHelper
.
getCCMSLoyaltyCampaigns
()
!=
null
&&
WarplyManagerHelper
.
getCCMSLoyaltyCampaigns
().
size
()
>
0
)
{
mContextualList
.
clear
();
...
...
@@ -95,12 +128,16 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
}
}
mergeDatasets
(
mValuesList
,
mContextualList
);
//
mergeDatasets(
//
mValuesList,
//
mContextualList
//
);
initViews
();
// initViews();
/** New Implementation */
initViewsNew
();
/** New Implementation */
}
@Override
...
...
@@ -140,7 +177,11 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
@Subscribe
()
public
void
onMessageEvent
(
WarplyEventBusManager
event
)
{
if
(
event
.
getCcmsAdded
()
!=
null
||
event
.
getCampaignsAdded
()
!=
null
)
{
filterItems
();
// filterItems();
/** New Implementation */
filterItemsNew
();
/** New Implementation */
if
(
WarplyManagerHelper
.
getCCMSLoyaltyCampaigns
()
!=
null
&&
WarplyManagerHelper
.
getCCMSLoyaltyCampaigns
().
size
()
>
0
)
{
mContextualList
.
clear
();
...
...
@@ -151,14 +192,33 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
}
}
mergeDatasets
(
mValuesList
,
mContextualList
);
// mergeDatasets(
// mValuesList,
// mContextualList
// );
// initViews2();
/** New Implementation */
initViewsNew2
();
/** New Implementation */
}
}
// ===========================================================
// Methods
// ===========================================================
private
void
initViews
()
{
mIvBack
.
setOnClickListener
(
this
);
mIvPopupClose
.
setOnClickListener
(
this
);
// if (WarpUtils.getMorePopup(this))
// mLlMorePopup.setVisibility(View.VISIBLE);
runOnUiThread
(()
->
{
// if (mValuesList != null && mValuesList.size() > 0) {
if
(
mData
!=
null
&&
mData
.
size
()
>
0
)
{
mRecyclerMore
.
setLayoutManager
(
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
));
// mAdapterMore = new MoreCampaignAdapter(this, mValuesList);
mAdapterMergedMore
=
new
MergedMoreAdapter
(
MoreForYouActivity
.
this
,
mData
);
// mRecyclerMore.setAdapter(mAdapterMore);
...
...
@@ -212,24 +272,12 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
}
else
{
mRecyclerMore
.
setVisibility
(
View
.
GONE
);
}
});
}
}
// ===========================================================
// Methods
// ===========================================================
private
void
initViews
()
{
mIvBack
.
setOnClickListener
(
this
);
mIvPopupClose
.
setOnClickListener
(
this
);
// if (WarpUtils.getMorePopup(this))
// mLlMorePopup.setVisibility(View.VISIBLE);
private
void
initViews2
()
{
runOnUiThread
(()
->
{
// if (mValuesList != null && mValuesList.size() > 0) {
if
(
mData
!=
null
&&
mData
.
size
()
>
0
)
{
mRecyclerMore
.
setLayoutManager
(
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
));
// mAdapterMore = new MoreCampaignAdapter(this, mValuesList);
mAdapterMergedMore
=
new
MergedMoreAdapter
(
MoreForYouActivity
.
this
,
mData
);
// mRecyclerMore.setAdapter(mAdapterMore);
...
...
@@ -283,6 +331,188 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
}
else
{
mRecyclerMore
.
setVisibility
(
View
.
GONE
);
}
});
}
private
void
initViewsNew
()
{
mIvBack
.
setOnClickListener
(
this
);
mIvPopupClose
.
setOnClickListener
(
this
);
if
(
mUniqueSectionList
!=
null
)
{
String
firstKey
=
(
String
)
mUniqueSectionList
.
keySet
().
toArray
()[
0
];
if
(
mUniqueSectionList
.
get
(
firstKey
)
!=
null
&&
mUniqueSectionList
.
get
(
firstKey
).
size
()
>
0
)
{
mTvResearchSection
.
setText
(
firstKey
.
substring
(
1
));
mResearchItems
.
setNestedScrollingEnabled
(
false
);
mResearchItems
.
setLayoutManager
(
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
));
mAdapterResearch
=
new
MoreCampaignAdapter
(
this
,
mUniqueSectionList
.
get
(
firstKey
));
mResearchItems
.
setAdapter
(
mAdapterResearch
);
mAdapterResearch
.
getPositionClicks
()
.
doOnNext
(
this
::
handleMoreItemClick
)
.
doOnError
(
error
->
{
})
.
subscribe
();
mLlResearchItems
.
setVisibility
(
View
.
VISIBLE
);
}
String
secondKey
=
(
String
)
mUniqueSectionList
.
keySet
().
toArray
()[
1
];
if
(
mUniqueSectionList
.
get
(
secondKey
)
!=
null
&&
mUniqueSectionList
.
get
(
secondKey
).
size
()
>
0
)
{
mTvExclusiveSection
.
setText
(
secondKey
.
substring
(
1
));
mExclusiveItems
.
setNestedScrollingEnabled
(
false
);
mExclusiveItems
.
setLayoutManager
(
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
));
mAdapterExclusive
=
new
MoreCampaignAdapter
(
this
,
mUniqueSectionList
.
get
(
secondKey
));
mExclusiveItems
.
setAdapter
(
mAdapterExclusive
);
mAdapterExclusive
.
getPositionClicks
()
.
doOnNext
(
this
::
handleMoreItemClick
)
.
doOnError
(
error
->
{
})
.
subscribe
();
mLlExclusiveItems
.
setVisibility
(
View
.
VISIBLE
);
}
String
thirdKey
=
(
String
)
mUniqueSectionList
.
keySet
().
toArray
()[
2
];
if
(
mUniqueSectionList
.
get
(
thirdKey
)
!=
null
&&
mUniqueSectionList
.
get
(
thirdKey
).
size
()
>
0
)
{
mTvContestSection
.
setText
(
thirdKey
.
substring
(
1
));
mContestItems
.
setNestedScrollingEnabled
(
false
);
mContestItems
.
setLayoutManager
(
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
));
mAdapterContest
=
new
MoreCampaignAdapter
(
this
,
mUniqueSectionList
.
get
(
thirdKey
));
mContestItems
.
setAdapter
(
mAdapterContest
);
mAdapterContest
.
getPositionClicks
()
.
doOnNext
(
this
::
handleMoreItemClick
)
.
doOnError
(
error
->
{
})
.
subscribe
();
mLlContestItems
.
setVisibility
(
View
.
VISIBLE
);
}
if
(
mContextualList
!=
null
&&
mContextualList
.
size
()
>
0
)
{
mTvContextualSection
.
setText
(
getString
(
R
.
string
.
cos_mfy_other
));
mContextualItems
.
setNestedScrollingEnabled
(
false
);
mContextualItems
.
setLayoutManager
(
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
VERTICAL
,
false
));
mAdapterContextual
=
new
MoreContextualAdapter
(
this
,
mContextualList
);
mContextualItems
.
setAdapter
(
mAdapterContextual
);
mAdapterContextual
.
getPositionClicks
()
.
doOnNext
(
this
::
handleMoreContextualItemClick
)
.
doOnError
(
error
->
{
})
.
subscribe
();
mLlContextualItems
.
setVisibility
(
View
.
VISIBLE
);
}
}
}
private
void
initViewsNew2
()
{
mIvBack
.
setOnClickListener
(
this
);
mIvPopupClose
.
setOnClickListener
(
this
);
if
(
mUniqueSectionList
!=
null
)
{
String
firstKey
=
(
String
)
mUniqueSectionList
.
keySet
().
toArray
()[
0
];
if
(
mUniqueSectionList
.
get
(
firstKey
)
!=
null
&&
mUniqueSectionList
.
get
(
firstKey
).
size
()
>
0
)
{
mTvResearchSection
.
setText
(
firstKey
.
substring
(
1
));
mResearchItems
.
setNestedScrollingEnabled
(
false
);
mAdapterResearch
=
new
MoreCampaignAdapter
(
this
,
mUniqueSectionList
.
get
(
firstKey
));
mResearchItems
.
setAdapter
(
mAdapterResearch
);
mAdapterResearch
.
getPositionClicks
()
.
doOnNext
(
this
::
handleMoreItemClick
)
.
doOnError
(
error
->
{
})
.
subscribe
();
mAdapterResearch
.
notifyDataSetChanged
();
mLlResearchItems
.
setVisibility
(
View
.
VISIBLE
);
}
String
secondKey
=
(
String
)
mUniqueSectionList
.
keySet
().
toArray
()[
1
];
if
(
mUniqueSectionList
.
get
(
secondKey
)
!=
null
&&
mUniqueSectionList
.
get
(
secondKey
).
size
()
>
0
)
{
mTvExclusiveSection
.
setText
(
secondKey
.
substring
(
1
));
mExclusiveItems
.
setNestedScrollingEnabled
(
false
);
mAdapterExclusive
=
new
MoreCampaignAdapter
(
this
,
mUniqueSectionList
.
get
(
secondKey
));
mExclusiveItems
.
setAdapter
(
mAdapterExclusive
);
mAdapterExclusive
.
getPositionClicks
()
.
doOnNext
(
this
::
handleMoreItemClick
)
.
doOnError
(
error
->
{
})
.
subscribe
();
mAdapterExclusive
.
notifyDataSetChanged
();
mLlExclusiveItems
.
setVisibility
(
View
.
VISIBLE
);
}
String
thirdKey
=
(
String
)
mUniqueSectionList
.
keySet
().
toArray
()[
2
];
if
(
mUniqueSectionList
.
get
(
thirdKey
)
!=
null
&&
mUniqueSectionList
.
get
(
thirdKey
).
size
()
>
0
)
{
mTvContestSection
.
setText
(
thirdKey
.
substring
(
1
));
mContestItems
.
setNestedScrollingEnabled
(
false
);
mAdapterContest
=
new
MoreCampaignAdapter
(
this
,
mUniqueSectionList
.
get
(
thirdKey
));
mContestItems
.
setAdapter
(
mAdapterContest
);
mAdapterContest
.
getPositionClicks
()
.
doOnNext
(
this
::
handleMoreItemClick
)
.
doOnError
(
error
->
{
})
.
subscribe
();
mAdapterContest
.
notifyDataSetChanged
();
mLlContestItems
.
setVisibility
(
View
.
VISIBLE
);
}
if
(
mContextualList
!=
null
&&
mContextualList
.
size
()
>
0
)
{
mTvContextualSection
.
setText
(
getString
(
R
.
string
.
cos_mfy_other
));
mContextualItems
.
setNestedScrollingEnabled
(
false
);
mAdapterContextual
=
new
MoreContextualAdapter
(
this
,
mContextualList
);
mContextualItems
.
setAdapter
(
mAdapterContextual
);
mAdapterContextual
.
getPositionClicks
()
.
doOnNext
(
this
::
handleMoreContextualItemClick
)
.
doOnError
(
error
->
{
})
.
subscribe
();
mAdapterContextual
.
notifyDataSetChanged
();
mLlContextualItems
.
setVisibility
(
View
.
VISIBLE
);
}
}
}
private
void
handleMoreItemClick
(
Campaign
moreItem
)
{
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
new
LoyaltySDKFirebaseEventModel
()));
try
{
JSONObject
extraFields
=
WarpJSONParser
.
getJSONFromString
(
moreItem
.
getExtraFields
());
if
(
extraFields
!=
null
)
{
if
(
extraFields
.
has
(
"type"
)
&&
extraFields
.
optString
(
"type"
).
equals
(
"telco"
))
{
for
(
LoyaltyContextualOfferModel
ccms
:
WarplyManagerHelper
.
getCCMSLoyaltyCampaigns
())
{
if
(
ccms
.
getLoyaltyCampaignId
().
equals
(
moreItem
.
getSessionUUID
()))
{
Intent
intent
=
new
Intent
(
MoreForYouActivity
.
this
,
TelcoActivity
.
class
);
intent
.
putExtra
(
"ccms"
,
ccms
);
intent
.
putExtra
(
"loyalty"
,
(
Serializable
)
moreItem
);
startActivity
(
intent
);
break
;
}
}
return
;
}
if
(
extraFields
.
has
(
"ccms_offer"
)
&&
extraFields
.
optString
(
"ccms_offer"
).
equals
(
"true"
))
{
for
(
LoyaltyContextualOfferModel
ccms
:
WarplyManagerHelper
.
getCCMSLoyaltyCampaigns
())
{
if
(
ccms
.
getLoyaltyCampaignId
().
equals
(
moreItem
.
getSessionUUID
()))
{
WarpUtils
.
log
(
"CCMS_CLICK "
+
ccms
.
toString
());
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
this
,
WarplyManagerHelper
.
constructCcmsUrl
(
moreItem
,
ccms
)));
break
;
}
}
}
else
{
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
this
,
WarplyManagerHelper
.
constructCampaignUrl
(
moreItem
)));
}
}
}
catch
(
Exception
exception
)
{
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
this
,
WarplyManagerHelper
.
constructCampaignUrl
(
moreItem
)));
}
}
private
void
handleMoreContextualItemClick
(
LoyaltyContextualOfferModel
ccmsItem
)
{
Intent
intent
=
new
Intent
(
MoreForYouActivity
.
this
,
ContextualActivity
.
class
);
intent
.
putExtra
(
"ccms"
,
ccmsItem
);
startActivity
(
intent
);
}
private
void
mergeDatasets
(
ArrayList
<
Campaign
>
campaignList
,
...
...
@@ -310,30 +540,82 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
}
}
private
void
filterItems
()
{
mValuesList
.
clear
();
ArrayList
<
Campaign
>
gfyList
=
new
ArrayList
<>();
// private void filterItems() {
// mValuesList.clear();
// ArrayList<Campaign> gfyList = new ArrayList<>();
// if (WarplyManagerHelper.getCampaignListAll() != null && WarplyManagerHelper.getCampaignListAll().size() > 0) {
// Log.v("Got L:{" + String.valueOf(WarplyManagerHelper.getCampaignListAll().size()) + "}", " LOYALTY campaigns");
// if (WarplyManagerHelper.getCCMSLoyaltyCampaigns() == null || WarplyManagerHelper.getCCMSLoyaltyCampaigns().size() == 0) {
// Log.v("Got C:{0}", " CCMS campaigns");
// for (Campaign camp : WarplyManagerHelper.getCampaignListAll()) {
// if (camp.getOfferCategory().equals("more_for_you")) {
// try {
// JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields());
// if (extraFields != null) {
// if (extraFields.length() == 0 || !(extraFields.has("ccms_offer") || extraFields.has("type"))) {
// gfyList.add(camp);
// }
// }
// } catch (Exception exception) {
// gfyList.add(camp);
// }
// }
// }
// } else {
// int ccmsCount = 0;
// Log.v("Got C:{" + String.valueOf(WarplyManagerHelper.getCCMSLoyaltyCampaigns().size()) + "}", " CCMS campaigns");
// for (Campaign camp : WarplyManagerHelper.getCampaignListAll()) {
// if (camp.getOfferCategory().equals("more_for_you")) {
// try {
// JSONObject extraFields = WarpJSONParser.getJSONFromString(camp.getExtraFields());
// if (extraFields != null) {
// if (extraFields.has("ccms_offer") && extraFields.optString("ccms_offer").equals("true")) {
// for (LoyaltyContextualOfferModel ccms : WarplyManagerHelper.getCCMSLoyaltyCampaigns()) {
// if (ccms.getLoyaltyCampaignId().equals(camp.getSessionUUID())) {
// gfyList.add(camp);
// ccmsCount++;
// break;
// }
// }
// } else {
// gfyList.add(camp);
// }
// }
// } catch (Exception exception) {
// gfyList.add(camp);
// }
// }
// }
// Log.v("Got M:{" + String.valueOf(ccmsCount) + "}", " Matched campaigns");
// }
//
// mValuesList.addAll(gfyList);
// }
// }
/**
* New Implementation
*/
private
void
filterItemsNew
()
{
mUniqueSectionList
.
clear
();
ArrayList
<
Campaign
>
mfyList
=
new
ArrayList
<>();
if
(
WarplyManagerHelper
.
getCampaignListAll
()
!=
null
&&
WarplyManagerHelper
.
getCampaignListAll
().
size
()
>
0
)
{
Log
.
v
(
"Got L:{"
+
String
.
valueOf
(
WarplyManagerHelper
.
getCampaignListAll
().
size
())
+
"}"
,
" LOYALTY campaigns"
);
if
(
WarplyManagerHelper
.
getCCMSLoyaltyCampaigns
()
==
null
||
WarplyManagerHelper
.
getCCMSLoyaltyCampaigns
().
size
()
==
0
)
{
Log
.
v
(
"Got C:{0}"
,
" CCMS campaigns"
);
for
(
Campaign
camp
:
WarplyManagerHelper
.
getCampaignListAll
())
{
if
(
camp
.
getOfferCategory
().
equals
(
"more_for_you"
))
{
try
{
JSONObject
extraFields
=
WarpJSONParser
.
getJSONFromString
(
camp
.
getExtraFields
());
if
(
extraFields
!=
null
)
{
if
(
extraFields
.
length
()
==
0
||
!(
extraFields
.
has
(
"ccms_offer"
)
||
extraFields
.
has
(
"type"
)))
{
g
fyList
.
add
(
camp
);
m
fyList
.
add
(
camp
);
}
}
}
catch
(
Exception
exception
)
{
g
fyList
.
add
(
camp
);
m
fyList
.
add
(
camp
);
}
}
}
}
else
{
int
ccmsCount
=
0
;
Log
.
v
(
"Got C:{"
+
String
.
valueOf
(
WarplyManagerHelper
.
getCCMSLoyaltyCampaigns
().
size
())
+
"}"
,
" CCMS campaigns"
);
for
(
Campaign
camp
:
WarplyManagerHelper
.
getCampaignListAll
())
{
if
(
camp
.
getOfferCategory
().
equals
(
"more_for_you"
))
{
try
{
...
...
@@ -342,26 +624,46 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
if
(
extraFields
.
has
(
"ccms_offer"
)
&&
extraFields
.
optString
(
"ccms_offer"
).
equals
(
"true"
))
{
for
(
LoyaltyContextualOfferModel
ccms
:
WarplyManagerHelper
.
getCCMSLoyaltyCampaigns
())
{
if
(
ccms
.
getLoyaltyCampaignId
().
equals
(
camp
.
getSessionUUID
()))
{
gfyList
.
add
(
camp
);
ccmsCount
++;
mfyList
.
add
(
camp
);
break
;
}
}
}
else
{
g
fyList
.
add
(
camp
);
m
fyList
.
add
(
camp
);
}
}
}
catch
(
Exception
exception
)
{
gfyList
.
add
(
camp
);
mfyList
.
add
(
camp
);
}
}
}
}
if
(
mfyList
!=
null
&&
mfyList
.
size
()
>
0
)
{
for
(
Campaign
campaignItem
:
mfyList
)
{
JSONObject
extraFields
=
WarpJSONParser
.
getJSONFromString
(
campaignItem
.
getExtraFields
());
if
(
extraFields
!=
null
&&
extraFields
.
has
(
"category_title"
))
{
String
categoryTitle
=
extraFields
.
optString
(
"category_title"
);
if
(
mUniqueSectionList
.
containsKey
(
categoryTitle
.
trim
()))
{
CampaignList
tempCampaignList
=
(
CampaignList
)
mUniqueSectionList
.
get
(
categoryTitle
.
trim
());
tempCampaignList
.
add
(
campaignItem
);
mUniqueSectionList
.
put
(
categoryTitle
.
trim
(),
tempCampaignList
);
}
else
{
CampaignList
tempCampaignList
=
new
CampaignList
();
tempCampaignList
.
add
(
campaignItem
);
mUniqueSectionList
.
put
(
categoryTitle
.
trim
(),
tempCampaignList
);
}
}
}
Log
.
v
(
"Got M:{"
+
String
.
valueOf
(
ccmsCount
)
+
"}"
,
" Matched campaigns"
);
}
mValuesList
.
addAll
(
gfyList
);
Map
<
String
,
ArrayList
<
Campaign
>>
treeMap
=
new
TreeMap
<
String
,
ArrayList
<
Campaign
>>(
mUniqueSectionList
);
mUniqueSectionList
.
clear
();
mUniqueSectionList
=
treeMap
;
}
}
/** New Implementation */
// ===========================================================
// Inner and Anonymous Classes
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/HealthEventModel.java
View file @
8b713b9
...
...
@@ -31,17 +31,17 @@ package ly.warp.sdk.io.models;
*/
public
class
HealthEventModel
{
private
double
step
s
;
private
double
meter
s
;
public
HealthEventModel
()
{
this
.
step
s
=
0.0d
;
this
.
meter
s
=
0.0d
;
}
public
double
get
Step
s
()
{
return
step
s
;
public
double
get
Meter
s
()
{
return
meter
s
;
}
public
void
set
Steps
(
double
step
s
)
{
this
.
steps
=
step
s
;
public
void
set
Meters
(
double
meter
s
)
{
this
.
meters
=
meter
s
;
}
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/services/WarplyHealthService.java
View file @
8b713b9
...
...
@@ -211,7 +211,7 @@ public class WarplyHealthService extends Service implements SensorEventListener
mSteps
++;
mStepsAll
++;
HealthEventModel
healthSteps
=
new
HealthEventModel
();
healthSteps
.
set
Step
s
((
mStepsAll
*
0.762
));
healthSteps
.
set
Meter
s
((
mStepsAll
*
0.762
));
EventBus
.
getDefault
().
post
(
new
WarplyEventBusManager
(
healthSteps
));
WarpUtils
.
setStepsMetersCounter
(
this
,
(
mStepsAll
*
0.762
));
WarpUtils
.
setStepsCounter
(
this
,
mSteps
);
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
View file @
8b713b9
...
...
@@ -745,7 +745,7 @@ public class WarplyManagerHelper {
*/
public
static
void
setSeasonalList
(
ArrayList
<
LoyaltyGiftsForYouPackage
>
seasonalCoupons
)
{
mSeasonalList
.
clear
();
mSeasonalList
.
addAll
(
seasonalCoupons
)
;
mSeasonalList
=
seasonalCoupons
;
}
/**
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/views/adapters/MoreCampaignAdapter.java
View file @
8b713b9
...
...
@@ -22,8 +22,7 @@ import io.reactivex.subjects.PublishSubject;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.io.models.Campaign
;
public
class
MoreCampaignAdapter
extends
RecyclerView
.
Adapter
<
MoreCampaignAdapter
.
ProfileCampaignViewHolder
>
{
public
class
MoreCampaignAdapter
extends
RecyclerView
.
Adapter
<
MoreCampaignAdapter
.
MoreCampaignViewHolder
>
{
private
Context
mContext
;
private
ArrayList
<
Campaign
>
mCampaigns
;
...
...
@@ -34,27 +33,19 @@ public class MoreCampaignAdapter extends RecyclerView.Adapter<MoreCampaignAdapte
this
.
mCampaigns
=
campaignList
;
}
public
class
Profil
eCampaignViewHolder
extends
RecyclerView
.
ViewHolder
{
public
class
Mor
eCampaignViewHolder
extends
RecyclerView
.
ViewHolder
{
private
ImageView
ivCampaignTitle
,
ivIsNew
;
private
TextView
tvCampaignTitle
,
tvCampaignSubtitle
,
tvCampaignMessage
;
public
ProfileCampaignViewHolder
(
View
view
)
{
super
(
view
);
ivCampaignTitle
=
view
.
findViewById
(
R
.
id
.
iv_campaign_logo
);
tvCampaignTitle
=
view
.
findViewById
(
R
.
id
.
tv_campaign_title
);
}
public
ProfileCampaignViewHolder
(
View
view
,
boolean
vertical
)
{
public
MoreCampaignViewHolder
(
View
view
)
{
super
(
view
);
ivCampaignTitle
=
view
.
findViewById
(
R
.
id
.
iv_campaign_logo
);
tvCampaignTitle
=
view
.
findViewById
(
R
.
id
.
tv_campaign_title
);
ivIsNew
=
view
.
findViewById
(
R
.
id
.
iv_campaign_new
);
if
(
vertical
)
{
tvCampaignSubtitle
=
view
.
findViewById
(
R
.
id
.
tv_campaign_subtitle
);
tvCampaignMessage
=
view
.
findViewById
(
R
.
id
.
tv_campaign_message
);
}
}
}
@Override
public
int
getItemCount
()
{
...
...
@@ -76,15 +67,15 @@ public class MoreCampaignAdapter extends RecyclerView.Adapter<MoreCampaignAdapte
}
@Override
public
Profil
eCampaignViewHolder
onCreateViewHolder
(
ViewGroup
parent
,
int
viewType
)
{
public
Mor
eCampaignViewHolder
onCreateViewHolder
(
ViewGroup
parent
,
int
viewType
)
{
View
itemView
;
itemView
=
LayoutInflater
.
from
(
parent
.
getContext
()).
inflate
(
R
.
layout
.
item_profile_recycler_vertical
,
parent
,
false
);
return
new
ProfileCampaignViewHolder
(
itemView
,
true
);
return
new
MoreCampaignViewHolder
(
itemView
);
}
@Override
public
void
onBindViewHolder
(
final
Profil
eCampaignViewHolder
holder
,
int
position
)
{
public
void
onBindViewHolder
(
final
Mor
eCampaignViewHolder
holder
,
int
position
)
{
Campaign
campaignItem
=
mCampaigns
.
get
(
position
);
if
(
campaignItem
!=
null
)
{
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/views/adapters/MoreContextualAdapter.java
0 → 100644
View file @
8b713b9
package
ly
.
warp
.
sdk
.
views
.
adapters
;
import
android.content.Context
;
import
android.text.TextUtils
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.bumptech.glide.load.resource.bitmap.CenterCrop
;
import
com.bumptech.glide.load.resource.bitmap.RoundedCorners
;
import
java.util.ArrayList
;
import
io.reactivex.Observable
;
import
io.reactivex.subjects.PublishSubject
;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.io.models.Campaign
;
import
ly.warp.sdk.io.models.LoyaltyContextualOfferModel
;
public
class
MoreContextualAdapter
extends
RecyclerView
.
Adapter
<
MoreContextualAdapter
.
MoreContextualViewHolder
>
{
private
Context
mContext
;
private
ArrayList
<
LoyaltyContextualOfferModel
>
mCampaigns
;
private
final
PublishSubject
<
LoyaltyContextualOfferModel
>
onClickSubject
=
PublishSubject
.
create
();
public
MoreContextualAdapter
(
Context
mContext
,
ArrayList
<
LoyaltyContextualOfferModel
>
campaignList
)
{
this
.
mContext
=
mContext
;
this
.
mCampaigns
=
campaignList
;
}
public
class
MoreContextualViewHolder
extends
RecyclerView
.
ViewHolder
{
private
ImageView
ivCampaignTitle
,
ivIsNew
;
private
TextView
tvCampaignTitle
,
tvCampaignSubtitle
,
tvCampaignMessage
;
public
MoreContextualViewHolder
(
View
view
)
{
super
(
view
);
ivCampaignTitle
=
view
.
findViewById
(
R
.
id
.
iv_campaign_logo
);
tvCampaignTitle
=
view
.
findViewById
(
R
.
id
.
tv_campaign_title
);
ivIsNew
=
view
.
findViewById
(
R
.
id
.
iv_campaign_new
);
tvCampaignSubtitle
=
view
.
findViewById
(
R
.
id
.
tv_campaign_subtitle
);
tvCampaignMessage
=
view
.
findViewById
(
R
.
id
.
tv_campaign_message
);
}
}
@Override
public
int
getItemCount
()
{
if
(
mCampaigns
==
null
)
return
0
;
else
return
mCampaigns
.
size
();
}
public
LoyaltyContextualOfferModel
getItem
(
int
id
)
{
return
mCampaigns
.
get
(
id
);
}
public
void
updateData
(
ArrayList
<
LoyaltyContextualOfferModel
>
campaignList
)
{
mCampaigns
.
clear
();
mCampaigns
.
addAll
(
campaignList
);
notifyDataSetChanged
();
}
@Override
public
MoreContextualViewHolder
onCreateViewHolder
(
ViewGroup
parent
,
int
viewType
)
{
View
itemView
;
itemView
=
LayoutInflater
.
from
(
parent
.
getContext
()).
inflate
(
R
.
layout
.
item_profile_recycler_vertical
,
parent
,
false
);
return
new
MoreContextualViewHolder
(
itemView
);
}
@Override
public
void
onBindViewHolder
(
final
MoreContextualViewHolder
holder
,
int
position
)
{
LoyaltyContextualOfferModel
campaignItem
=
mCampaigns
.
get
(
position
);
if
(
campaignItem
!=
null
)
{
if
(!
TextUtils
.
isEmpty
(
campaignItem
.
getImageUrl
()))
{
Glide
.
with
(
mContext
)
.
load
(
campaignItem
.
getImageUrl
())
.
transform
(
new
CenterCrop
(),
new
RoundedCorners
(
4
))
.
diskCacheStrategy
(
DiskCacheStrategy
.
DATA
)
.
into
(
holder
.
ivCampaignTitle
);
}
else
{
Glide
.
with
(
mContext
)
.
load
(
R
.
drawable
.
ic_cosmote_logo_horizontal_grey
)
.
into
(
holder
.
ivCampaignTitle
);
}
holder
.
tvCampaignTitle
.
setText
(
campaignItem
.
getTitle
());
holder
.
tvCampaignSubtitle
.
setText
(
campaignItem
.
getSubtitle
());
holder
.
tvCampaignMessage
.
setText
(
campaignItem
.
getMessage
());
holder
.
ivIsNew
.
setVisibility
(
View
.
GONE
);
holder
.
itemView
.
setOnClickListener
(
v
->
onClickSubject
.
onNext
(
campaignItem
));
}
}
public
Observable
<
LoyaltyContextualOfferModel
>
getPositionClicks
()
{
return
onClickSubject
.
cache
();
}
}
warply_android_sdk/src/main/res/layout/activity_more_for_you.xml
View file @
8b713b9
...
...
@@ -25,13 +25,13 @@
<TextView
android:id=
"@+id/textView3"
fontPath=
"fonts/pf_square_sans_pro_bold.ttf"
android:layout_width=
"206dp"
android:layout_height=
"32dp"
android:gravity=
"center"
android:text=
"@string/cos_more_title"
android:textColor=
"@color/grey"
android:textSize=
"17sp"
fontPath=
"fonts/pf_square_sans_pro_bold.ttf"
android:text=
"@string/cos_more_title"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_bias=
"0.356"
...
...
@@ -46,6 +46,16 @@
android:background=
"@drawable/shape_cos_loyalty"
android:orientation=
"vertical"
>
<ScrollView
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:fillViewport=
"true"
>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:orientation=
"vertical"
>
<LinearLayout
android:id=
"@+id/ll_more_popup"
android:layout_width=
"match_parent"
...
...
@@ -55,7 +65,7 @@
android:orientation=
"vertical"
android:paddingVertical=
"16dp"
android:visibility=
"gone"
tools:visibility=
"visibl
e"
>
tools:visibility=
"gon
e"
>
<ImageView
android:id=
"@+id/iv_popup_more_close"
...
...
@@ -102,6 +112,122 @@
android:clipToPadding=
"false"
android:orientation=
"vertical"
android:paddingTop=
"44dp"
android:paddingBottom=
"24dp"
/>
android:paddingBottom=
"24dp"
android:visibility=
"gone"
/>
<LinearLayout
android:id=
"@+id/ll_research_items"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_more_popup"
android:orientation=
"vertical"
android:paddingTop=
"44dp"
android:visibility=
"gone"
>
<TextView
android:id=
"@+id/tv_research_section"
fontPath=
"fonts/pf_square_sans_pro_bold.ttf"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"16dp"
android:textColor=
"@android:color/white"
android:textSize=
"16sp"
tools:text=
"ΕΡΕΥΝΑ"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_research_items"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"4dp"
android:clipToPadding=
"false"
android:orientation=
"vertical"
android:paddingBottom=
"4dp"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_exclusive_items"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_research_items"
android:orientation=
"vertical"
android:visibility=
"gone"
>
<TextView
android:id=
"@+id/tv_exclusive_section"
fontPath=
"fonts/pf_square_sans_pro_bold.ttf"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"16dp"
android:textColor=
"@android:color/white"
android:textSize=
"16sp"
tools:text=
"ΕΡΕΥΝΑ"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_exclusive_items"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"4dp"
android:clipToPadding=
"false"
android:orientation=
"vertical"
android:paddingBottom=
"4dp"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_contest_items"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_exclusive_items"
android:orientation=
"vertical"
android:visibility=
"gone"
>
<TextView
android:id=
"@+id/tv_contest_section"
fontPath=
"fonts/pf_square_sans_pro_bold.ttf"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"16dp"
android:textColor=
"@android:color/white"
android:textSize=
"16sp"
tools:text=
"ΕΡΕΥΝΑ"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_contest_items"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"4dp"
android:clipToPadding=
"false"
android:orientation=
"vertical"
android:paddingBottom=
"4dp"
/>
</LinearLayout>
<LinearLayout
android:id=
"@+id/ll_contextual_items"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_contest_items"
android:orientation=
"vertical"
android:visibility=
"gone"
>
<TextView
android:id=
"@+id/tv_contextual_section"
fontPath=
"fonts/pf_square_sans_pro_bold.ttf"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginHorizontal=
"16dp"
android:textColor=
"@android:color/white"
android:textSize=
"16sp"
tools:text=
"ΕΡΕΥΝΑ"
/>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_contextual_items"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"4dp"
android:clipToPadding=
"false"
android:orientation=
"vertical"
android:paddingBottom=
"4dp"
/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
</RelativeLayout>
\ No newline at end of file
...
...
warply_android_sdk/src/main/res/values/strings.xml
View file @
8b713b9
...
...
@@ -132,6 +132,7 @@
<string
name=
"cos_empty_shared_coupons"
>
Δεν έχεις μοιραστεί ακόμη κουπόνια
</string>
<string
name=
"cos_empty_expired_coupons"
>
Δεν έχεις εξαργυρώσει ακόμη κουπόνια
</string>
<string
name=
"cos_dlg_pacing_goal"
>
Πέτυχες το στόχο του μήνα! Διάλεξε το δώρο που επιθυμείς να ενεργοποιήσεις!
</string>
<string
name=
"cos_mfy_other"
>
ΆΛΛΕΣ
</string>
<string-array
name=
"coupons_array"
>
<item>
Κουπόνια
</item>
...
...
Please
register
or
login
to post a comment