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
2026-03-18 11:49:08 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
47fecc12da3f093142b7b0ca007d945572099676
47fecc12
1 parent
3fe6fd92
categories fixes
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
20 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/activities/HomeActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/HomeActivity.java
View file @
47fecc1
...
...
@@ -94,7 +94,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
WarplyManager
.
getCoupons
(
mCouponsCallback
);
WarplyManager
.
getCarousel
(
mCarouselCallback
);
WarplyManager
.
getCouponsets
(
null
,
null
,
mCouponsetsCallback
);
WarplyManager
.
getFilters
(
mFiltersCallback
);
//
WarplyManager.getFilters(mFiltersCallback);
}
@Override
...
...
@@ -299,8 +299,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
TypedValue
.
COMPLEX_UNIT_DIP
,
8
,
getResources
().
getDisplayMetrics
());
int
sectionMarginTopPx
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
40
,
getResources
().
getDisplayMetrics
());
int
sectionMarginTopFirstPx
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
24
,
getResources
().
getDisplayMetrics
());
//
int sectionIndex = 0;
int
sectionIndex
=
0
;
for
(
Map
.
Entry
<
String
,
ArrayList
<
Couponset
>>
entry
:
categorizedMap
.
entrySet
())
{
String
categoryName
=
entry
.
getKey
();
ArrayList
<
Couponset
>
couponsets
=
entry
.
getValue
();
...
...
@@ -311,11 +313,15 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
View
sectionView
=
inflater
.
inflate
(
R
.
layout
.
item_couponset_section
,
mSectionsContainer
,
false
);
// if (sectionIndex > 0) {
if
(
sectionIndex
==
0
)
{
LinearLayout
.
LayoutParams
sectionParams
=
(
LinearLayout
.
LayoutParams
)
sectionView
.
getLayoutParams
();
sectionParams
.
topMargin
=
sectionMarginTopFirstPx
;
sectionView
.
setLayoutParams
(
sectionParams
);
}
else
if
(
sectionIndex
>
0
)
{
LinearLayout
.
LayoutParams
sectionParams
=
(
LinearLayout
.
LayoutParams
)
sectionView
.
getLayoutParams
();
sectionParams
.
topMargin
=
sectionMarginTopPx
;
sectionView
.
setLayoutParams
(
sectionParams
);
//
}
}
TextView
tvTitle
=
sectionView
.
findViewById
(
R
.
id
.
tv_section_title
);
String
titleText
=
categoryName
+
" ("
+
couponsets
.
size
()
+
")"
;
...
...
@@ -344,7 +350,7 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
rvSection
.
setAdapter
(
adapter
);
mSectionsContainer
.
addView
(
sectionView
);
//
sectionIndex++;
sectionIndex
++;
}
mSectionsLoading
.
setVisibility
(
View
.
GONE
);
}
...
...
@@ -422,15 +428,15 @@ public class HomeActivity extends Activity implements View.OnClickListener, Coup
}
};
private
final
CallbackReceiver
<
Filter
>
mFiltersCallback
=
new
CallbackReceiver
<
Filter
>()
{
@Override
public
void
onSuccess
(
Filter
result
)
{
Toast
.
makeText
(
HomeActivity
.
this
,
"FILTERS SUCCESS"
,
Toast
.
LENGTH_SHORT
).
show
();
}
@Override
public
void
onFailure
(
int
errorCode
)
{
Toast
.
makeText
(
HomeActivity
.
this
,
"FILTERS ERROR"
,
Toast
.
LENGTH_SHORT
).
show
();
}
};
//
private final CallbackReceiver<Filter> mFiltersCallback = new CallbackReceiver<Filter>() {
//
@Override
//
public void onSuccess(Filter result) {
//
Toast.makeText(HomeActivity.this, "FILTERS SUCCESS", Toast.LENGTH_SHORT).show();
//
}
//
//
@Override
//
public void onFailure(int errorCode) {
//
Toast.makeText(HomeActivity.this, "FILTERS ERROR", Toast.LENGTH_SHORT).show();
//
}
//
};
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
47fecc1
...
...
@@ -407,7 +407,7 @@ public class WarplyManager {
},
executorService
);
}
private
static
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
mergeCouponsetsResults
(
ArrayList
<
Couponset
>
resultCouponsets
)
{
private
static
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
mergeCouponsetsResults
(
ArrayList
<
Couponset
>
resultCouponsets
,
Filter
resultFilter
)
{
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
categorizedMap
=
new
LinkedHashMap
<>();
if
(
resultCouponsets
==
null
||
resultCouponsets
.
isEmpty
())
{
...
...
@@ -415,6 +415,20 @@ public class WarplyManager {
return
categorizedMap
;
}
// Build child admin_name -> parent admin_name lookup map from Filter
HashMap
<
String
,
String
>
childToParentMap
=
new
HashMap
<>();
if
(
resultFilter
!=
null
&&
resultFilter
.
getOfferCategories
()
!=
null
)
{
for
(
Filter
.
OfferCategory
parent
:
resultFilter
.
getOfferCategories
())
{
if
(
parent
.
getChildren
()
!=
null
)
{
for
(
Filter
.
OfferCategory
child
:
parent
.
getChildren
())
{
if
(
child
.
getAdminName
()
!=
null
&&
parent
.
getAdminName
()
!=
null
)
{
childToParentMap
.
put
(
child
.
getAdminName
(),
parent
.
getAdminName
());
}
}
}
}
}
ArrayList
<
Couponset
>
topOffers
=
new
ArrayList
<>();
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
categoryGroups
=
new
LinkedHashMap
<>();
...
...
@@ -426,6 +440,10 @@ public class WarplyManager {
if
(
category
==
null
||
category
.
isEmpty
())
{
category
=
"Other"
;
}
// If this category is a child, map it to its parent
if
(
childToParentMap
.
containsKey
(
category
))
{
category
=
childToParentMap
.
get
(
category
);
}
categoryGroups
.
computeIfAbsent
(
category
,
k
->
new
ArrayList
<>()).
add
(
couponset
);
}
}
...
...
@@ -490,14 +508,16 @@ public class WarplyManager {
WarpUtils
.
log
(
"**************************************************"
);
ApiService
service
=
ApiClient
.
getRetrofitInstance
().
create
(
ApiService
.
class
);
ListeningExecutorService
executorService
=
MoreExecutors
.
listeningDecorator
(
Executors
.
newFixedThreadPool
(
1
));
ListeningExecutorService
executorService
=
MoreExecutors
.
listeningDecorator
(
Executors
.
newFixedThreadPool
(
2
));
ListenableFuture
<
ArrayList
<
Couponset
>>
futureCouponsets
=
getCouponsetsRetro
(
region
,
offerCategory
,
service
,
0
);
ListenableFuture
<
Filter
>
futureFilters
=
getFiltersRetro
(
service
);
ListenableFuture
<
List
<
Object
>>
allResultsFuture
=
Futures
.
allAsList
(
futureCouponsets
);
ListenableFuture
<
List
<
Object
>>
allResultsFuture
=
Futures
.
allAsList
(
futureCouponsets
,
futureFilters
);
ListenableFuture
<
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>>
mergedResultFuture
=
Futures
.
transformAsync
(
allResultsFuture
,
results
->
{
ArrayList
<
Couponset
>
resultCouponsets
=
(
ArrayList
<
Couponset
>)
results
.
get
(
0
);
return
executorService
.
submit
(()
->
mergeCouponsetsResults
(
resultCouponsets
));
Filter
resultFilter
=
(
Filter
)
results
.
get
(
1
);
return
executorService
.
submit
(()
->
mergeCouponsetsResults
(
resultCouponsets
,
resultFilter
));
},
executorService
);
Futures
.
addCallback
(
mergedResultFuture
,
new
FutureCallback
<
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>>()
{
...
...
Please
register
or
login
to post a comment