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-02-27 16:32:33 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2b9f74ffe4c3cd52cee38f7ee0b134719d6ed0c0
2b9f74ff
1 parent
be96d491
deh requests, new models, dynamic couponsets in home activity
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
2197 additions
and
1467 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/activities/HomeActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/fragments/HomeFragment.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/adapters/BannerAdapter.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/adapters/CouponsetAdapter.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Campaign.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Content.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Couponset.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Merchant.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/User.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/volley/ApiClient.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/volley/ApiService.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
warply_android_sdk/src/main/res/layout/activity_home.xml
warply_android_sdk/src/main/res/layout/demo_item_offer.xml
warply_android_sdk/src/main/res/layout/fragment_home.xml
warply_android_sdk/src/main/res/layout/item_couponset_section.xml
warply_android_sdk/src/main/res/values/strings.xml
warply_android_sdk/src/main/java/ly/warp/sdk/activities/HomeActivity.java
View file @
2b9f74f
...
...
@@ -4,6 +4,7 @@ import android.app.Activity;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.util.TypedValue
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.widget.ImageView
;
import
android.widget.LinearLayout
;
...
...
@@ -19,27 +20,28 @@ import com.bumptech.glide.Glide;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
java.util.List
;
import
java.util.Map
;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.io.adapters.BannerAdapter
;
import
ly.warp.sdk.io.adapters.
Offer
Adapter
;
import
ly.warp.sdk.io.adapters.
Couponset
Adapter
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.models.BannerItem
;
import
ly.warp.sdk.io.models.Couponset
;
import
ly.warp.sdk.io.models.DummyDataProvider
;
import
ly.warp.sdk.io.models.OfferCategory
;
import
ly.warp.sdk.io.models.OfferItem
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.utils.WarplyManagerHelper
;
import
ly.warp.sdk.utils.managers.WarplyManager
;
import
ly.warp.sdk.views.HorizontalSpaceItemDecoration
;
public
class
HomeActivity
extends
Activity
implements
View
.
OnClickListener
,
OfferAdapter
.
OnOffer
ClickListener
{
public
class
HomeActivity
extends
Activity
implements
View
.
OnClickListener
,
CouponsetAdapter
.
OnCouponset
ClickListener
{
// ===========================================================
// Constants
// ===========================================================
private
static
final
int
MAX_ITEMS_PER_SECTION
=
5
;
// ===========================================================
// Fields
// ===========================================================
...
...
@@ -50,44 +52,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
private
BannerAdapter
mBannerAdapter
;
private
LinearLayout
mDotsContainer
;
private
List
<
ImageView
>
mDots
;
// Category sections
private
TextView
mTvCategoryTopOffers
;
private
RecyclerView
mRvTopOffers
;
private
OfferAdapter
mTopOffersAdapter
;
private
TextView
mTvCategoryFavorites
;
private
RecyclerView
mRvFavorites
;
private
OfferAdapter
mFavoritesAdapter
;
private
TextView
mTvCategoryViability
;
private
RecyclerView
mRvViability
;
private
OfferAdapter
mViabilityAdapter
;
private
TextView
mTvCategoryFamily
;
private
RecyclerView
mRvFamily
;
private
OfferAdapter
mFamilyAdapter
;
private
TextView
mTvCategoryFoodCoffee
;
private
RecyclerView
mRvFoodCoffee
;
private
OfferAdapter
mFoodCoffeeAdapter
;
private
TextView
mTvCategoryTravelling
;
private
RecyclerView
mRvTravelling
;
private
OfferAdapter
mTravellingAdapter
;
private
TextView
mTvCategoryKids
;
private
RecyclerView
mRvKids
;
private
OfferAdapter
mKidsAdapter
;
private
TextView
mTvCategoryPurchases
;
private
RecyclerView
mRvPurchases
;
private
OfferAdapter
mPurchasesAdapter
;
private
TextView
mTvAllOffers
,
mTvAllFavorites
,
mTvAllViability
,
mTvAllFamily
,
mTvAllCoffee
,
mTvAllTravelling
,
mTvAllKids
,
mTvAllPurchases
;
private
ImageView
mIvProfile
;
private
ConstraintLayout
mViewPager
;
private
LinearLayout
mSectionsContainer
;
private
RelativeLayout
mSectionsLoading
;
// ===========================================================
// Methods for/from SuperClass/Interfaces
...
...
@@ -105,18 +73,9 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
null
);
mPbLoading
.
setVisibility
(
View
.
VISIBLE
);
mSectionsLoading
.
setVisibility
(
View
.
VISIBLE
);
WarplyManager
.
getCampaigns
(
mCampaignsCallback
);
WarplyManager
.
getCouponsets
(
mCouponsetsCallback
);
// Setup all category sections
setupTopOffersSection
();
setupFavoritesSection
();
setupViabilitySection
();
setupFamilySection
();
setupFoodCoffeeSection
();
setupTravellingSection
();
setupKidsSection
();
setupPurchasesSection
();
}
@Override
...
...
@@ -133,15 +92,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
}
@Override
public
void
onOfferClick
(
OfferItem
offerItem
,
int
position
)
{
Intent
myIntent
=
new
Intent
(
HomeActivity
.
this
,
SingleCouponActivity
.
class
);
myIntent
.
putExtra
(
SingleCouponActivity
.
EXTRA_OFFER_ITEM
,
offerItem
);
startActivity
(
myIntent
);
}
@Override
public
void
onFavoriteClick
(
OfferItem
offerItem
,
int
position
)
{
// Toast.makeText(this, "Favorite clicked for: " + offerItem.getTitle(), Toast.LENGTH_SHORT).show();
public
void
onCouponsetClick
(
Couponset
couponset
,
int
position
)
{
// Intent myIntent = new Intent(HomeActivity.this, SingleCouponActivity.class);
// myIntent.putExtra(SingleCouponActivity.EXTRA_OFFER_ITEM, couponset);
// startActivity(myIntent);
}
// ===========================================================
...
...
@@ -153,281 +107,66 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
mPbLoading
.
setOnTouchListener
((
v
,
event
)
->
true
);
mViewPager
=
findViewById
(
R
.
id
.
cl_viewpager
);
mSectionsContainer
=
findViewById
(
R
.
id
.
ll_sections_container
);
mSectionsLoading
=
findViewById
(
R
.
id
.
rl_sections_loading
);
mIvProfile
=
findViewById
(
R
.
id
.
profile_icon
);
mIvProfile
.
setOnClickListener
(
this
);
// Initialize Top Offers section
mTvCategoryTopOffers
=
findViewById
(
R
.
id
.
tv_recycler_category1
);
mRvTopOffers
=
findViewById
(
R
.
id
.
rl_recycler1
);
mTvAllOffers
=
findViewById
(
R
.
id
.
tv_recycler_all1
);
// Initialize Favorites section
mTvCategoryFavorites
=
findViewById
(
R
.
id
.
tv_recycler_category2
);
mRvFavorites
=
findViewById
(
R
.
id
.
rl_recycler2
);
mTvAllFavorites
=
findViewById
(
R
.
id
.
tv_recycler_all2
);
// Initialize Viability section
mTvCategoryViability
=
findViewById
(
R
.
id
.
tv_recycler_category3
);
mRvViability
=
findViewById
(
R
.
id
.
rl_recycler3
);
mTvAllViability
=
findViewById
(
R
.
id
.
tv_recycler_all3
);
// Initialize Family section
mTvCategoryFamily
=
findViewById
(
R
.
id
.
tv_recycler_category4
);
mRvFamily
=
findViewById
(
R
.
id
.
rl_recycler4
);
mTvAllFamily
=
findViewById
(
R
.
id
.
tv_recycler_all4
);
// Initialize Food & Coffee section
mTvCategoryFoodCoffee
=
findViewById
(
R
.
id
.
tv_recycler_category5
);
mRvFoodCoffee
=
findViewById
(
R
.
id
.
rl_recycler5
);
mTvAllCoffee
=
findViewById
(
R
.
id
.
tv_recycler_all5
);
// Initialize Travelling section
mTvCategoryTravelling
=
findViewById
(
R
.
id
.
tv_recycler_category6
);
mRvTravelling
=
findViewById
(
R
.
id
.
rl_recycler6
);
mTvAllTravelling
=
findViewById
(
R
.
id
.
tv_recycler_all6
);
// Initialize Kids section
mTvCategoryKids
=
findViewById
(
R
.
id
.
tv_recycler_category7
);
mRvKids
=
findViewById
(
R
.
id
.
rl_recycler7
);
mTvAllKids
=
findViewById
(
R
.
id
.
tv_recycler_all7
);
// Initialize Purchases section
mTvCategoryPurchases
=
findViewById
(
R
.
id
.
tv_recycler_category8
);
mRvPurchases
=
findViewById
(
R
.
id
.
rl_recycler8
);
mTvAllPurchases
=
findViewById
(
R
.
id
.
tv_recycler_all8
);
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
ping_lcg_bold
,
mTvCategoryTopOffers
,
mTvCategoryFavorites
,
mTvCategoryViability
,
mTvCategoryFamily
,
mTvCategoryFoodCoffee
,
mTvCategoryTravelling
,
mTvCategoryKids
,
mTvCategoryPurchases
);
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
ping_lcg_regular
,
mTvAllOffers
,
mTvAllFavorites
,
mTvAllViability
,
mTvAllFamily
,
mTvAllCoffee
,
mTvAllTravelling
,
mTvAllKids
,
mTvAllPurchases
);
}
/**
* Set up the Top Offers section with dummy data
*/
private
void
setupTopOffersSection
()
{
// Get Top Offers data
OfferCategory
topOffersCategory
=
DummyDataProvider
.
getTopOffers
();
// Set category title with item count
String
categoryTitle
=
topOffersCategory
.
getName
()
+
" ("
+
topOffersCategory
.
getItems
().
size
()
+
")"
;
mTvCategoryTopOffers
.
setText
(
categoryTitle
);
// Set up RecyclerView
LinearLayoutManager
layoutManager
=
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
HORIZONTAL
,
false
);
mRvTopOffers
.
setLayoutManager
(
layoutManager
);
mRvTopOffers
.
setHasFixedSize
(
true
);
// Add spacing between items
int
spacingInPixels
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
8
,
getResources
().
getDisplayMetrics
());
mRvTopOffers
.
addItemDecoration
(
new
HorizontalSpaceItemDecoration
(
spacingInPixels
));
// Create and set adapter
mTopOffersAdapter
=
new
OfferAdapter
(
this
,
topOffersCategory
.
getItems
());
mTopOffersAdapter
.
setOnOfferClickListener
(
this
);
mRvTopOffers
.
setAdapter
(
mTopOffersAdapter
);
}
/**
* Set up the Favorites section with dummy data
*/
private
void
setupFavoritesSection
()
{
// Get Favorites data
OfferCategory
favoritesCategory
=
DummyDataProvider
.
getFavorites
();
// Set category title with item count
String
categoryTitle
=
favoritesCategory
.
getName
()
+
" ("
+
favoritesCategory
.
getItems
().
size
()
+
")"
;
mTvCategoryFavorites
.
setText
(
categoryTitle
);
// Set up RecyclerView
LinearLayoutManager
layoutManager
=
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
HORIZONTAL
,
false
);
mRvFavorites
.
setLayoutManager
(
layoutManager
);
mRvFavorites
.
setHasFixedSize
(
true
);
// Add spacing between items
int
spacingInPixels
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
8
,
getResources
().
getDisplayMetrics
());
mRvFavorites
.
addItemDecoration
(
new
HorizontalSpaceItemDecoration
(
spacingInPixels
));
// Create and set adapter
mFavoritesAdapter
=
new
OfferAdapter
(
this
,
favoritesCategory
.
getItems
());
mFavoritesAdapter
.
setOnOfferClickListener
(
this
);
mRvFavorites
.
setAdapter
(
mFavoritesAdapter
);
}
/**
* Set up the Viability section with dummy data
*/
private
void
setupViabilitySection
()
{
// Get Viability data
OfferCategory
viabilityCategory
=
DummyDataProvider
.
getViability
();
// Set category title with item count
String
categoryTitle
=
viabilityCategory
.
getName
()
+
" ("
+
viabilityCategory
.
getItems
().
size
()
+
")"
;
mTvCategoryViability
.
setText
(
categoryTitle
);
// Set up RecyclerView
LinearLayoutManager
layoutManager
=
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
HORIZONTAL
,
false
);
mRvViability
.
setLayoutManager
(
layoutManager
);
mRvViability
.
setHasFixedSize
(
true
);
// Add spacing between items
int
spacingInPixels
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
8
,
getResources
().
getDisplayMetrics
());
mRvViability
.
addItemDecoration
(
new
HorizontalSpaceItemDecoration
(
spacingInPixels
));
// Create and set adapter
mViabilityAdapter
=
new
OfferAdapter
(
this
,
viabilityCategory
.
getItems
());
mViabilityAdapter
.
setOnOfferClickListener
(
this
);
mRvViability
.
setAdapter
(
mViabilityAdapter
);
}
/**
* Set up the Family section with dummy data
*/
private
void
setupFamilySection
()
{
// Get Family data
OfferCategory
familyCategory
=
DummyDataProvider
.
getFamily
();
private
void
setupCouponsetSections
(
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
categorizedMap
)
{
mSectionsContainer
.
removeAllViews
();
// Set category title with item count
String
categoryTitle
=
familyCategory
.
getName
()
+
" ("
+
familyCategory
.
getItems
().
size
()
+
")"
;
mTvCategoryFamily
.
setText
(
categoryTitle
);
// Set up RecyclerView
LinearLayoutManager
layoutManager
=
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
HORIZONTAL
,
false
);
mRvFamily
.
setLayoutManager
(
layoutManager
);
mRvFamily
.
setHasFixedSize
(
true
);
// Add spacing between items
int
spacingInPixels
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
8
,
getResources
().
getDisplayMetrics
());
mRvFamily
.
addItemDecoration
(
new
HorizontalSpaceItemDecoration
(
spacingInPixels
));
// Create and set adapter
mFamilyAdapter
=
new
OfferAdapter
(
this
,
familyCategory
.
getItems
());
mFamilyAdapter
.
setOnOfferClickListener
(
this
);
mRvFamily
.
setAdapter
(
mFamilyAdapter
);
}
/**
* Set up the Food & Coffee section with dummy data
*/
private
void
setupFoodCoffeeSection
()
{
// Get Food & Coffee data
OfferCategory
foodCoffeeCategory
=
DummyDataProvider
.
getFoodAndCoffee
();
// Set category title with item count
String
categoryTitle
=
foodCoffeeCategory
.
getName
()
+
" ("
+
foodCoffeeCategory
.
getItems
().
size
()
+
")"
;
mTvCategoryFoodCoffee
.
setText
(
categoryTitle
);
// Set up RecyclerView
LinearLayoutManager
layoutManager
=
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
HORIZONTAL
,
false
);
mRvFoodCoffee
.
setLayoutManager
(
layoutManager
);
mRvFoodCoffee
.
setHasFixedSize
(
true
);
// Add spacing between items
int
spacingInPixels
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
8
,
getResources
().
getDisplayMetrics
());
mRvFoodCoffee
.
addItemDecoration
(
new
HorizontalSpaceItemDecoration
(
spacingInPixels
));
// Create and set adapter
mFoodCoffeeAdapter
=
new
OfferAdapter
(
this
,
foodCoffeeCategory
.
getItems
());
mFoodCoffeeAdapter
.
setOnOfferClickListener
(
this
);
mRvFoodCoffee
.
setAdapter
(
mFoodCoffeeAdapter
);
}
/**
* Set up the Travelling section with dummy data
*/
private
void
setupTravellingSection
()
{
// Get Travelling data
OfferCategory
travellingCategory
=
DummyDataProvider
.
getTravelling
();
// Set category title with item count
String
categoryTitle
=
travellingCategory
.
getName
()
+
" ("
+
travellingCategory
.
getItems
().
size
()
+
")"
;
mTvCategoryTravelling
.
setText
(
categoryTitle
);
// Set up RecyclerView
LinearLayoutManager
layoutManager
=
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
HORIZONTAL
,
false
);
mRvTravelling
.
setLayoutManager
(
layoutManager
);
mRvTravelling
.
setHasFixedSize
(
true
);
if
(
categorizedMap
==
null
||
categorizedMap
.
isEmpty
())
{
mSectionsLoading
.
setVisibility
(
View
.
GONE
);
return
;
}
// Add spacing between items
LayoutInflater
inflater
=
LayoutInflater
.
from
(
this
);
int
spacingInPixels
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
8
,
getResources
().
getDisplayMetrics
());
mRvTravelling
.
addItemDecoration
(
new
HorizontalSpaceItemDecoration
(
spacingInPixels
));
// Create and set adapter
mTravellingAdapter
=
new
OfferAdapter
(
this
,
travellingCategory
.
getItems
());
mTravellingAdapter
.
setOnOfferClickListener
(
this
);
mRvTravelling
.
setAdapter
(
mTravellingAdapter
);
}
/**
* Set up the Kids section with dummy data
*/
private
void
setupKidsSection
()
{
// Get Kids data
OfferCategory
kidsCategory
=
DummyDataProvider
.
getKids
();
// Set category title with item count
String
categoryTitle
=
kidsCategory
.
getName
()
+
" ("
+
kidsCategory
.
getItems
().
size
()
+
")"
;
mTvCategoryKids
.
setText
(
categoryTitle
);
for
(
Map
.
Entry
<
String
,
ArrayList
<
Couponset
>>
entry
:
categorizedMap
.
entrySet
())
{
String
categoryName
=
entry
.
getKey
()
;
ArrayList
<
Couponset
>
couponsets
=
entry
.
getValue
(
);
// Set up RecyclerView
LinearLayoutManager
layoutManager
=
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
HORIZONTAL
,
false
);
mRvKids
.
setLayoutManager
(
layoutManager
);
mRvKids
.
setHasFixedSize
(
true
);
if
(
couponsets
==
null
||
couponsets
.
isEmpty
())
{
continue
;
}
// Add spacing between items
int
spacingInPixels
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
8
,
getResources
().
getDisplayMetrics
());
mRvKids
.
addItemDecoration
(
new
HorizontalSpaceItemDecoration
(
spacingInPixels
));
View
sectionView
=
inflater
.
inflate
(
R
.
layout
.
item_couponset_section
,
mSectionsContainer
,
false
);
// Create and set adapter
mKidsAdapter
=
new
OfferAdapter
(
this
,
kidsCategory
.
getItems
());
mKidsAdapter
.
setOnOfferClickListener
(
this
);
mRvKids
.
setAdapter
(
mKidsAdapter
);
}
TextView
tvTitle
=
sectionView
.
findViewById
(
R
.
id
.
tv_section_title
);
String
titleText
=
categoryName
+
" ("
+
couponsets
.
size
()
+
")"
;
tvTitle
.
setText
(
titleText
);
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
ping_lcg_bold
,
tvTitle
);
/**
* Set up the Purchases section with dummy data
*/
private
void
setupPurchasesSection
()
{
// Get Purchases data
OfferCategory
purchasesCategory
=
DummyDataProvider
.
getPurchases
();
TextView
tvAll
=
sectionView
.
findViewById
(
R
.
id
.
tv_section_all
);
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
ping_lcg_regular
,
tvAll
);
// Set category title with item count
String
categoryTitle
=
purchasesCategory
.
getName
()
+
" ("
+
purchasesCategory
.
getItems
().
size
()
+
")"
;
mTvCategoryPurchases
.
setText
(
categoryTitle
);
RecyclerView
rvSection
=
sectionView
.
findViewById
(
R
.
id
.
rv_section_list
);
LinearLayoutManager
layoutManager
=
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
HORIZONTAL
,
false
);
rvSection
.
setLayoutManager
(
layoutManager
);
rvSection
.
setHasFixedSize
(
true
);
rvSection
.
addItemDecoration
(
new
HorizontalSpaceItemDecoration
(
spacingInPixels
));
// Set up RecyclerView
LinearLayoutManager
layoutManager
=
new
LinearLayoutManager
(
this
,
LinearLayoutManager
.
HORIZONTAL
,
false
);
mRvPurchases
.
setLayoutManager
(
layoutManager
);
mRvPurchases
.
setHasFixedSize
(
true
);
List
<
Couponset
>
displayList
=
couponsets
.
size
()
>
MAX_ITEMS_PER_SECTION
?
new
ArrayList
<>(
couponsets
.
subList
(
0
,
MAX_ITEMS_PER_SECTION
))
:
couponsets
;
// Add spacing between items
int
spacingInPixels
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
8
,
getResources
().
getDisplayMetrics
());
mRvPurchases
.
addItemDecoration
(
new
HorizontalSpaceItemDecoration
(
spacingInPixels
));
CouponsetAdapter
adapter
=
new
CouponsetAdapter
(
this
,
displayList
);
adapter
.
setOnCouponsetClickListener
(
this
);
rvSection
.
setAdapter
(
adapter
);
// Create and set adapter
mPurchasesAdapter
=
new
OfferAdapter
(
this
,
purchasesCategory
.
getItems
());
mPurchasesAdapter
.
setOnOfferClickListener
(
this
);
mRvPurchases
.
setAdapter
(
mPurchasesAdapter
);
mSectionsContainer
.
addView
(
sectionView
);
}
mSectionsLoading
.
setVisibility
(
View
.
GONE
);
}
// ===========================================================
// Methods
//
Banner
Methods
// ===========================================================
/**
* Sets up the banner carousel with ViewPager2 and pagination dots
*/
private
void
setupBannerCarousel
()
{
mBannerViewPager
=
findViewById
(
R
.
id
.
banner_viewpager
);
mDotsContainer
=
findViewById
(
R
.
id
.
dots_container
);
...
...
@@ -442,13 +181,10 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
// Set the number of pages to preload for adjacent items
mBannerViewPager
.
setOffscreenPageLimit
(
5
);
mBannerViewPager
.
setAdapter
(
mBannerAdapter
);
// Setup pagination dots
setupPaginationDots
(
WarplyManagerHelper
.
getBannerList
().
size
());
// Handle page changes
mBannerViewPager
.
registerOnPageChangeCallback
(
new
ViewPager2
.
OnPageChangeCallback
()
{
@Override
public
void
onPageSelected
(
int
position
)
{
...
...
@@ -457,50 +193,38 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
});
}
/**
* Sets up the pagination dots
*
* @param count Number of dots to display
*/
private
void
setupPaginationDots
(
int
count
)
{
mDots
=
new
ArrayList
<>();
mDotsContainer
.
removeAllViews
();
// Create dots
for
(
int
i
=
0
;
i
<
count
;
i
++)
{
ImageView
dot
=
new
ImageView
(
this
);
// Set dot appearance
LinearLayout
.
LayoutParams
params
=
new
LinearLayout
.
LayoutParams
(
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
,
LinearLayout
.
LayoutParams
.
WRAP_CONTENT
);
// Add margin between dots
params
.
setMargins
(
8
,
0
,
8
,
0
);
dot
.
setLayoutParams
(
params
);
// Set initial state (first dot active, others inactive)
dot
.
setImageResource
(
i
==
0
?
R
.
drawable
.
dot_active
:
R
.
drawable
.
dot_inactive
);
// Add to container and list
mDotsContainer
.
addView
(
dot
);
mDots
.
add
(
dot
);
}
}
/**
* Updates the dots to reflect the current page
*
* @param position Current page position
*/
private
void
updateDots
(
int
position
)
{
for
(
int
i
=
0
;
i
<
mDots
.
size
();
i
++)
{
mDots
.
get
(
i
).
setImageResource
(
i
==
position
?
R
.
drawable
.
dot_active
:
R
.
drawable
.
dot_inactive
);
}
}
private
CallbackReceiver
<
ArrayList
<
BannerItem
>>
mCampaignsCallback
=
new
CallbackReceiver
<
ArrayList
<
BannerItem
>>()
{
// ===========================================================
// Callbacks
// ===========================================================
private
final
CallbackReceiver
<
ArrayList
<
BannerItem
>>
mCampaignsCallback
=
new
CallbackReceiver
<
ArrayList
<
BannerItem
>>()
{
@Override
public
void
onSuccess
(
ArrayList
<
BannerItem
>
result
)
{
mPbLoading
.
setVisibility
(
View
.
GONE
);
...
...
@@ -526,15 +250,18 @@ public class HomeActivity extends Activity implements View.OnClickListener, Offe
}
};
private
CallbackReceiver
<
ArrayList
<
Couponset
>>
mCouponsetsCallback
=
new
CallbackReceiver
<
ArrayList
<
Couponset
>>()
{
private
final
CallbackReceiver
<
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>>
mCouponsetsCallback
=
new
CallbackReceiver
<
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>
>>()
{
@Override
public
void
onSuccess
(
ArrayList
<
Couponset
>
result
)
{
mPbLoading
.
setVisibility
(
View
.
GONE
);
public
void
onSuccess
(
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
result
)
{
mSectionsLoading
.
setVisibility
(
View
.
GONE
);
if
(
result
!=
null
&&
!
result
.
isEmpty
())
{
setupCouponsetSections
(
result
);
}
}
@Override
public
void
onFailure
(
int
errorCode
)
{
m
Pb
Loading
.
setVisibility
(
View
.
GONE
);
m
Sections
Loading
.
setVisibility
(
View
.
GONE
);
}
};
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/fragments/HomeFragment.java
View file @
2b9f74f
...
...
@@ -5,6 +5,7 @@ import android.os.Bundle;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.EditText
;
import
android.widget.LinearLayout
;
import
android.widget.RelativeLayout
;
import
android.widget.Toast
;
...
...
@@ -17,12 +18,15 @@ import org.json.JSONObject;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.activities.HomeActivity
;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.models.User
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.utils.managers.WarplyManager
;
public
class
HomeFragment
extends
Fragment
implements
View
.
OnClickListener
{
private
RelativeLayout
mPbLoading
;
private
LinearLayout
mRlSmFlow
;
private
EditText
mEtLogin
;
private
LinearLayout
mLlLogin
;
@Override
public
View
onCreateView
(
LayoutInflater
inflater
,
ViewGroup
container
,
Bundle
savedInstanceState
)
{
...
...
@@ -36,15 +40,13 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
mPbLoading
.
setOnTouchListener
((
v
,
event
)
->
true
);
mRlSmFlow
=
view
.
findViewById
(
R
.
id
.
ll_sm_flow
);
mRlSmFlow
.
setOnClickListener
(
this
);
mEtLogin
=
view
.
findViewById
(
R
.
id
.
et_login
);
mLlLogin
=
view
.
findViewById
(
R
.
id
.
ll_login
);
mLlLogin
.
setOnClickListener
(
this
);
WarpUtils
.
applyEdgeToEdge
(
getActivity
(),
view
.
findViewById
(
R
.
id
.
rl_header
),
null
);
// 6012049321, 6012049322, 6012049323, 7000000831 history, 7000000826
// prod 6006552990, prod 6005892749, live 3000184910,prod 7000070282, live 3000136179
// mPbLoading.setVisibility(View.VISIBLE);
// WarplyManager.getDehUser("aggeliki@warp.ly", mLoginReceiver);
}
@Override
...
...
@@ -59,6 +61,11 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
// WarplyManager.logout(mLogoutReceiver);
// return;
// }
if
(
view
.
getId
()
==
R
.
id
.
ll_login
)
{
mPbLoading
.
setVisibility
(
View
.
VISIBLE
);
WarplyManager
.
login
(
mEtLogin
.
getText
().
toString
(),
mLoginReceiver
);
return
;
}
if
(
view
.
getId
()
==
R
.
id
.
ll_sm_flow
)
{
Intent
myIntent
=
new
Intent
(
getContext
(),
HomeActivity
.
class
);
startActivity
(
myIntent
);
...
...
@@ -87,8 +94,9 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
private
final
CallbackReceiver
<
JSONObject
>
mLoginReceiver
=
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
mPbLoading
.
setVisibility
(
View
.
GONE
);
//
mPbLoading.setVisibility(View.GONE);
Toast
.
makeText
(
getActivity
(),
"LOGIN SUCCESS"
,
Toast
.
LENGTH_SHORT
).
show
();
WarplyManager
.
getUser
(
mUserReceiver
);
}
@Override
...
...
@@ -97,4 +105,20 @@ public class HomeFragment extends Fragment implements View.OnClickListener {
Toast
.
makeText
(
getActivity
(),
"LOGIN ERROR"
,
Toast
.
LENGTH_SHORT
).
show
();
}
};
private
final
CallbackReceiver
<
User
>
mUserReceiver
=
new
CallbackReceiver
<
User
>()
{
@Override
public
void
onSuccess
(
User
user
)
{
mPbLoading
.
setVisibility
(
View
.
GONE
);
Toast
.
makeText
(
getActivity
(),
"USER SUCCESS"
,
Toast
.
LENGTH_SHORT
).
show
();
Intent
myIntent
=
new
Intent
(
getContext
(),
HomeActivity
.
class
);
startActivity
(
myIntent
);
}
@Override
public
void
onFailure
(
int
errorCode
)
{
mPbLoading
.
setVisibility
(
View
.
GONE
);
Toast
.
makeText
(
getActivity
(),
"USER ERROR"
,
Toast
.
LENGTH_SHORT
).
show
();
}
};
}
\ No newline at end of file
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/adapters/BannerAdapter.java
View file @
2b9f74f
...
...
@@ -47,6 +47,24 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView
this
.
mListenerContent
=
listener
;
}
private
String
getCampaignImage
(
BannerItem
item
)
{
if
(
item
.
getCampaign
().
getExtraFields
()
!=
null
)
{
if
(!
item
.
getCampaign
().
getExtraFields
().
isNull
(
"banner_img_mobile"
))
{
return
item
.
getCampaign
().
getExtraFields
().
optString
(
"banner_img_mobile"
,
""
);
}
}
return
item
.
getCampaign
().
getLogoUrl
();
}
private
String
getContentImage
(
BannerItem
item
)
{
if
(!
item
.
getContent
().
getImg
().
isEmpty
())
{
return
item
.
getContent
().
getImg
().
get
(
0
);
}
return
item
.
getContent
().
getImgPreview
();
}
@NonNull
@Override
public
BannerViewHolder
onCreateViewHolder
(
@NonNull
ViewGroup
parent
,
int
viewType
)
{
...
...
@@ -64,7 +82,7 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView
// RequestOptions
// .placeholderOf(R.drawable.demo_logo)
// .error(R.drawable.demo_logo))
.
load
(
bannerItem
.
getCampaign
().
getLogoUrl
(
))
.
load
(
getCampaignImage
(
bannerItem
))
.
diskCacheStrategy
(
DiskCacheStrategy
.
DATA
)
.
into
(
holder
.
imageView
);
...
...
@@ -79,7 +97,7 @@ public class BannerAdapter extends RecyclerView.Adapter<BannerAdapter.BannerView
// RequestOptions
// .placeholderOf(R.drawable.demo_logo)
// .error(R.drawable.demo_logo))
.
load
(
bannerItem
.
getContent
().
getImgPreview
(
))
.
load
(
getContentImage
(
bannerItem
))
.
diskCacheStrategy
(
DiskCacheStrategy
.
DATA
)
.
into
(
holder
.
imageView
);
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/adapters/CouponsetAdapter.java
0 → 100644
View file @
2b9f74f
package
ly
.
warp
.
sdk
.
io
.
adapters
;
import
android.content.Context
;
import
android.util.TypedValue
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
androidx.annotation.NonNull
;
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
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.io.models.Couponset
;
import
ly.warp.sdk.utils.TopRoundedCornersTransformation
;
import
ly.warp.sdk.utils.WarpUtils
;
public
class
CouponsetAdapter
extends
RecyclerView
.
Adapter
<
CouponsetAdapter
.
CouponsetViewHolder
>
{
private
final
List
<
Couponset
>
couponsets
;
private
final
Context
context
;
private
OnCouponsetClickListener
listener
;
public
interface
OnCouponsetClickListener
{
void
onCouponsetClick
(
Couponset
couponset
,
int
position
);
}
public
CouponsetAdapter
(
Context
context
,
List
<
Couponset
>
couponsets
)
{
this
.
context
=
context
;
this
.
couponsets
=
couponsets
;
}
public
void
setOnCouponsetClickListener
(
OnCouponsetClickListener
listener
)
{
this
.
listener
=
listener
;
}
@NonNull
@Override
public
CouponsetViewHolder
onCreateViewHolder
(
@NonNull
ViewGroup
parent
,
int
viewType
)
{
View
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
demo_item_offer
,
parent
,
false
);
return
new
CouponsetViewHolder
(
view
);
}
@Override
public
void
onBindViewHolder
(
@NonNull
CouponsetViewHolder
holder
,
int
position
)
{
Couponset
couponset
=
couponsets
.
get
(
position
);
holder
.
bind
(
couponset
,
position
);
}
@Override
public
int
getItemCount
()
{
return
couponsets
.
size
();
}
public
class
CouponsetViewHolder
extends
RecyclerView
.
ViewHolder
{
private
final
ImageView
ivOfferImage
;
private
final
ImageView
ivFavorite
;
private
final
ImageView
ivLogo
;
private
final
TextView
tvPrice
;
private
final
TextView
tvTitle
;
private
final
TextView
tvDescription
;
private
final
TextView
tvValidity
;
CouponsetViewHolder
(
@NonNull
View
itemView
)
{
super
(
itemView
);
ivOfferImage
=
itemView
.
findViewById
(
R
.
id
.
iv_offer_image
);
ivFavorite
=
itemView
.
findViewById
(
R
.
id
.
iv_favorite
);
ivLogo
=
itemView
.
findViewById
(
R
.
id
.
iv_logo
);
tvPrice
=
itemView
.
findViewById
(
R
.
id
.
tv_price
);
tvTitle
=
itemView
.
findViewById
(
R
.
id
.
tv_title
);
tvDescription
=
itemView
.
findViewById
(
R
.
id
.
tv_description
);
tvValidity
=
itemView
.
findViewById
(
R
.
id
.
tv_validity
);
WarpUtils
.
renderCustomFont
(
context
,
R
.
font
.
ping_lcg_bold
,
tvPrice
,
tvTitle
);
WarpUtils
.
renderCustomFont
(
context
,
R
.
font
.
ping_lcg_regular
,
tvDescription
,
tvValidity
);
itemView
.
setOnClickListener
(
v
->
{
int
position
=
getAdapterPosition
();
if
(
listener
!=
null
&&
position
!=
RecyclerView
.
NO_POSITION
)
{
listener
.
onCouponsetClick
(
couponsets
.
get
(
position
),
position
);
}
});
}
private
void
bind
(
Couponset
couponset
,
int
position
)
{
tvTitle
.
setText
(
couponset
.
getName
()
!=
null
?
couponset
.
getName
()
:
""
);
tvDescription
.
setText
(
couponset
.
getShortDescription
()
!=
null
?
couponset
.
getShortDescription
()
:
""
);
tvPrice
.
setText
(
couponset
.
getDiscount
()
!=
null
?
couponset
.
getDiscount
()
:
""
);
if
(
couponset
.
getEndDate
()
!=
null
&&
!
couponset
.
getEndDate
().
isEmpty
())
{
tvValidity
.
setText
(
formatValidityDate
(
couponset
.
getEndDate
()));
tvValidity
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
tvValidity
.
setVisibility
(
View
.
GONE
);
}
ivFavorite
.
setImageResource
(
R
.
drawable
.
demo_heart
);
loadCouponsetImage
(
couponset
.
getImgPreview
());
if
(
couponset
.
getMerchant
()
!=
null
&&
couponset
.
getMerchant
().
getImgPreview
()
!=
null
)
{
loadMerchantLogo
(
couponset
.
getMerchant
().
getImgPreview
());
}
else
{
ivLogo
.
setVisibility
(
View
.
GONE
);
}
}
private
String
formatValidityDate
(
String
endDate
)
{
try
{
SimpleDateFormat
inputFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
,
Locale
.
getDefault
());
Date
date
=
inputFormat
.
parse
(
endDate
);
SimpleDateFormat
outputFormat
=
new
SimpleDateFormat
(
"dd-MM"
,
Locale
.
getDefault
());
return
"έως "
+
outputFormat
.
format
(
date
);
}
catch
(
ParseException
e
)
{
try
{
SimpleDateFormat
inputFormat2
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm"
,
Locale
.
getDefault
());
Date
date
=
inputFormat2
.
parse
(
endDate
);
SimpleDateFormat
outputFormat
=
new
SimpleDateFormat
(
"dd-MM"
,
Locale
.
getDefault
());
return
"έως "
+
outputFormat
.
format
(
date
);
}
catch
(
ParseException
e2
)
{
return
endDate
;
}
}
}
private
void
loadCouponsetImage
(
String
imageUrl
)
{
if
(
imageUrl
!=
null
&&
!
imageUrl
.
isEmpty
())
{
int
radiusInPixels
=
(
int
)
TypedValue
.
applyDimension
(
TypedValue
.
COMPLEX_UNIT_DIP
,
9
,
context
.
getResources
().
getDisplayMetrics
());
Glide
.
with
(
context
)
.
load
(
imageUrl
)
.
diskCacheStrategy
(
DiskCacheStrategy
.
DATA
)
.
transform
(
new
CenterCrop
(),
new
TopRoundedCornersTransformation
(
radiusInPixels
))
.
into
(
ivOfferImage
);
}
}
private
void
loadMerchantLogo
(
String
logoUrl
)
{
if
(
logoUrl
!=
null
&&
!
logoUrl
.
isEmpty
())
{
ivLogo
.
setVisibility
(
View
.
VISIBLE
);
Glide
.
with
(
context
)
.
load
(
logoUrl
)
.
diskCacheStrategy
(
DiskCacheStrategy
.
DATA
)
.
into
(
ivLogo
);
}
else
{
ivLogo
.
setVisibility
(
View
.
GONE
);
}
}
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Campaign.java
View file @
2b9f74f
...
...
@@ -42,6 +42,10 @@ import ly.warp.sdk.utils.WarpUtils;
import
ly.warp.sdk.utils.WarplyProperty
;
import
ly.warp.sdk.utils.constants.WarpConstants
;
/**
* Created by Panagiotis Triantafyllou on 27-Feb-26.
*/
public
class
Campaign
implements
Parcelable
,
Serializable
{
private
static
final
long
serialVersionUID
=
-
4754964462459705285L
;
...
...
@@ -74,6 +78,16 @@ public class Campaign implements Parcelable, Serializable {
private
static
final
String
CAMPAIGN_TYPE_SETTINGS
=
"campaign_type_settings"
;
private
static
final
String
CATEGORY_ID
=
"category_id"
;
private
static
final
String
COUPON_AVAILABILITY
=
"coupon_availability"
;
private
static
final
String
COMMUNICATION_UUID
=
"communication_uuid"
;
private
static
final
String
COMMUNICATION_NAME
=
"communication_name"
;
private
static
final
String
COMMUNICATION_CATEGORY
=
"communication_category"
;
private
static
final
String
CATEGORY
=
"category"
;
private
static
final
String
DESCRIPTION
=
"description"
;
private
static
final
String
WORKFLOW_SETTINGS
=
"workflow_settings"
;
private
static
final
String
SETTINGS
=
"settings"
;
private
static
final
String
AUDIENCE
=
"audience"
;
private
static
final
String
START_DATE
=
"start_date"
;
private
static
final
String
END_DATE
=
"end_date"
;
/* Member variables of the Campaign object */
...
...
@@ -91,7 +105,7 @@ public class Campaign implements Parcelable, Serializable {
private
int
opened
;
private
boolean
isNew
;
private
String
logoUrl
;
private
String
extraFields
;
private
JSONObject
extraFields
;
private
String
type
;
private
boolean
expired
;
private
boolean
show
;
...
...
@@ -103,10 +117,27 @@ public class Campaign implements Parcelable, Serializable {
private
String
campaignTypeSettings
;
private
String
categoryId
;
private
Integer
couponAvailability
;
private
String
endDate
,
startDate
;
private
String
endDate
;
private
String
startDate
;
private
boolean
showExpiration
;
private
String
couponImg
;
private
String
filter
=
""
;
private
String
filter
;
private
String
communicationUuid
;
private
String
communicationName
;
private
String
communicationCategory
;
private
String
category
;
private
String
description
;
private
JSONObject
workflowSettings
;
private
JSONObject
settings
;
private
String
audience
;
/**
* Helper method to get a nullable String from a JSONObject.
* Returns null if the JSON value is null, otherwise returns the String value.
*/
private
static
String
optNullableString
(
JSONObject
json
,
String
key
)
{
return
json
.
isNull
(
key
)
?
null
:
json
.
optString
(
key
);
}
/**
* Basic constructor used to create an object from a String, representing a
...
...
@@ -123,33 +154,41 @@ public class Campaign implements Parcelable, Serializable {
this
.
action
=
0
;
this
.
delivered
=
0.0d
;
this
.
expires
=
0.0d
;
this
.
message
=
""
;
this
.
offerCategory
=
""
;
this
.
offerMessage
=
""
;
this
.
sessionUUID
=
""
;
this
.
message
=
null
;
this
.
offerCategory
=
null
;
this
.
offerMessage
=
null
;
this
.
sessionUUID
=
null
;
this
.
starts
=
0.0d
;
this
.
subtitle
=
""
;
this
.
title
=
""
;
this
.
subtitle
=
null
;
this
.
title
=
null
;
this
.
sorting
=
0
;
this
.
opened
=
0
;
this
.
isNew
=
true
;
this
.
logoUrl
=
""
;
this
.
extraFields
=
""
;
this
.
type
=
""
;
this
.
logoUrl
=
null
;
this
.
extraFields
=
null
;
this
.
type
=
null
;
this
.
expired
=
false
;
this
.
show
=
true
;
this
.
deliveryMethod
=
""
;
this
.
displayType
=
""
;
this
.
indexUrl
=
""
;
this
.
busId
=
""
;
this
.
deliveryMethod
=
null
;
this
.
displayType
=
null
;
this
.
indexUrl
=
null
;
this
.
busId
=
null
;
this
.
actions
=
new
ArrayList
<>();
this
.
campaignTypeSettings
=
""
;
this
.
campaignTypeSettings
=
null
;
this
.
couponAvailability
=
null
;
this
.
categoryId
=
""
;
this
.
endDate
=
""
;
this
.
startDate
=
""
;
this
.
categoryId
=
null
;
this
.
endDate
=
null
;
this
.
startDate
=
null
;
this
.
showExpiration
=
false
;
this
.
couponImg
=
""
;
this
.
couponImg
=
null
;
this
.
communicationUuid
=
null
;
this
.
communicationName
=
null
;
this
.
communicationCategory
=
null
;
this
.
category
=
null
;
this
.
description
=
null
;
this
.
workflowSettings
=
null
;
this
.
settings
=
null
;
this
.
audience
=
null
;
}
/**
...
...
@@ -158,35 +197,35 @@ public class Campaign implements Parcelable, Serializable {
* @param json JSON Object used to create the Campaign
*/
public
Campaign
(
JSONObject
json
)
{
this
.
indexUrl
=
json
.
optString
(
INDEX_URL
);
this
.
logoUrl
=
json
.
optString
(
LOGO_URL
);
this
.
indexUrl
=
optNullableString
(
json
,
INDEX_URL
);
this
.
logoUrl
=
optNullableString
(
json
,
LOGO_URL
);
this
.
delivered
=
json
.
optDouble
(
DELIVERED
);
this
.
sessionUUID
=
json
.
optString
(
SESSION_UUID
);
this
.
subtitle
=
json
.
optString
(
SUBTITLE
);
this
.
sessionUUID
=
optNullableString
(
json
,
SESSION_UUID
);
this
.
subtitle
=
optNullableString
(
json
,
SUBTITLE
);
this
.
starts
=
json
.
optDouble
(
STARTS
);
this
.
message
=
json
.
optString
(
MESSAGE
);
this
.
message
=
optNullableString
(
json
,
MESSAGE
);
this
.
opened
=
json
.
optInt
(
OPENED
);
this
.
expires
=
json
.
optDouble
(
EXPIRES
);
this
.
offerCategory
=
json
.
optString
(
OFFER_CATEGORY
);
this
.
offerCategory
=
optNullableString
(
json
,
OFFER_CATEGORY
);
if
(
belongsInCategory
(
WarpConstants
.
MICROAPP_CAMPAIGNS_STANDARD_OFFER_NO_DATE
))
{
this
.
expires
=
0
;
this
.
offerCategory
=
WarpConstants
.
MICROAPP_CAMPAIGNS_STANDARD_OFFER
;
}
this
.
title
=
json
.
optString
(
TITLE
);
this
.
title
=
optNullableString
(
json
,
TITLE
);
this
.
action
=
json
.
optInt
(
ACTION
);
this
.
offerMessage
=
json
.
optString
(
OFFER_MESSAGE
);
this
.
offerMessage
=
optNullableString
(
json
,
OFFER_MESSAGE
);
this
.
isNew
=
json
.
optBoolean
(
IS_NEW
);
this
.
sorting
=
json
.
optInt
(
SORTING
);
this
.
extraFields
=
json
.
opt
String
(
EXTRA_FIELDS
);
this
.
type
=
json
.
optString
(
TYPE
);
this
.
extraFields
=
json
.
opt
JSONObject
(
EXTRA_FIELDS
);
this
.
type
=
optNullableString
(
json
,
TYPE
);
this
.
expired
=
json
.
optBoolean
(
EXPIRED
);
this
.
show
=
json
.
optBoolean
(
SHOW
);
this
.
deliveryMethod
=
json
.
optString
(
DELIVERY_METHOD
);
this
.
displayType
=
json
.
optString
(
DISPLAY_TYPE
);
this
.
busId
=
json
.
optString
(
BUS_ID
);
this
.
campaignTypeSettings
=
json
.
optString
(
CAMPAIGN_TYPE_SETTINGS
);
this
.
deliveryMethod
=
optNullableString
(
json
,
DELIVERY_METHOD
);
this
.
displayType
=
optNullableString
(
json
,
DISPLAY_TYPE
);
this
.
busId
=
optNullableString
(
json
,
BUS_ID
);
this
.
campaignTypeSettings
=
optNullableString
(
json
,
CAMPAIGN_TYPE_SETTINGS
);
JSONArray
actions
=
json
.
optJSONArray
(
ACTIONS
);
if
(
actions
!=
null
)
{
...
...
@@ -196,8 +235,18 @@ public class Campaign implements Parcelable, Serializable {
}
else
{
this
.
actions
=
null
;
}
this
.
categoryId
=
json
.
optString
(
CATEGORY_ID
);
this
.
categoryId
=
optNullableString
(
json
,
CATEGORY_ID
);
this
.
couponAvailability
=
json
.
optInt
(
COUPON_AVAILABILITY
);
this
.
communicationUuid
=
optNullableString
(
json
,
COMMUNICATION_UUID
);
this
.
communicationName
=
optNullableString
(
json
,
COMMUNICATION_NAME
);
this
.
communicationCategory
=
optNullableString
(
json
,
COMMUNICATION_CATEGORY
);
this
.
category
=
optNullableString
(
json
,
CATEGORY
);
this
.
description
=
optNullableString
(
json
,
DESCRIPTION
);
this
.
workflowSettings
=
json
.
optJSONObject
(
WORKFLOW_SETTINGS
);
this
.
settings
=
json
.
optJSONObject
(
SETTINGS
);
this
.
audience
=
optNullableString
(
json
,
AUDIENCE
);
this
.
startDate
=
optNullableString
(
json
,
START_DATE
);
this
.
endDate
=
optNullableString
(
json
,
END_DATE
);
}
public
Campaign
(
Parcel
source
)
{
...
...
@@ -216,7 +265,12 @@ public class Campaign implements Parcelable, Serializable {
this
.
opened
=
source
.
readInt
();
this
.
isNew
=
source
.
readInt
()
>
0
;
this
.
logoUrl
=
source
.
readString
();
this
.
extraFields
=
source
.
readString
();
try
{
String
extraFieldsStr
=
source
.
readString
();
this
.
extraFields
=
extraFieldsStr
!=
null
?
new
JSONObject
(
extraFieldsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
extraFields
=
null
;
}
this
.
type
=
source
.
readString
();
this
.
expired
=
source
.
readInt
()
>
0
;
this
.
show
=
source
.
readInt
()
>
0
;
...
...
@@ -227,6 +281,26 @@ public class Campaign implements Parcelable, Serializable {
this
.
campaignTypeSettings
=
source
.
readString
();
this
.
categoryId
=
source
.
readString
();
this
.
couponAvailability
=
source
.
readInt
();
this
.
communicationUuid
=
source
.
readString
();
this
.
communicationName
=
source
.
readString
();
this
.
communicationCategory
=
source
.
readString
();
this
.
category
=
source
.
readString
();
this
.
description
=
source
.
readString
();
try
{
String
workflowSettingsStr
=
source
.
readString
();
this
.
workflowSettings
=
workflowSettingsStr
!=
null
?
new
JSONObject
(
workflowSettingsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
workflowSettings
=
null
;
}
try
{
String
settingsStr
=
source
.
readString
();
this
.
settings
=
settingsStr
!=
null
?
new
JSONObject
(
settingsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
settings
=
null
;
}
this
.
audience
=
source
.
readString
();
this
.
startDate
=
source
.
readString
();
this
.
endDate
=
source
.
readString
();
}
@Override
...
...
@@ -246,7 +320,7 @@ public class Campaign implements Parcelable, Serializable {
dest
.
writeInt
(
this
.
opened
);
dest
.
writeInt
(
this
.
isNew
?
1
:
0
);
dest
.
writeString
(
this
.
logoUrl
);
dest
.
writeString
(
this
.
extraFields
);
dest
.
writeString
(
this
.
extraFields
!=
null
?
this
.
extraFields
.
toString
()
:
null
);
dest
.
writeString
(
this
.
type
);
dest
.
writeInt
(
this
.
expired
?
1
:
0
);
dest
.
writeInt
(
this
.
show
?
1
:
0
);
...
...
@@ -257,6 +331,16 @@ public class Campaign implements Parcelable, Serializable {
dest
.
writeString
(
this
.
campaignTypeSettings
);
dest
.
writeInt
(
this
.
couponAvailability
);
dest
.
writeString
(
this
.
categoryId
);
dest
.
writeString
(
this
.
communicationUuid
);
dest
.
writeString
(
this
.
communicationName
);
dest
.
writeString
(
this
.
communicationCategory
);
dest
.
writeString
(
this
.
category
);
dest
.
writeString
(
this
.
description
);
dest
.
writeString
(
this
.
workflowSettings
!=
null
?
this
.
workflowSettings
.
toString
()
:
null
);
dest
.
writeString
(
this
.
settings
!=
null
?
this
.
settings
.
toString
()
:
null
);
dest
.
writeString
(
this
.
audience
);
dest
.
writeString
(
this
.
startDate
);
dest
.
writeString
(
this
.
endDate
);
}
/**
...
...
@@ -267,32 +351,41 @@ public class Campaign implements Parcelable, Serializable {
public
JSONObject
toJSONObject
()
{
JSONObject
jObj
=
new
JSONObject
();
try
{
jObj
.
put
Opt
(
INDEX_URL
,
this
.
indexUrl
);
jObj
.
put
Opt
(
LOGO_URL
,
this
.
logoUrl
);
jObj
.
put
(
INDEX_URL
,
this
.
indexUrl
!=
null
?
this
.
indexUrl
:
JSONObject
.
NULL
);
jObj
.
put
(
LOGO_URL
,
this
.
logoUrl
!=
null
?
this
.
logoUrl
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
ACTION
,
this
.
action
);
jObj
.
putOpt
(
DELIVERED
,
this
.
delivered
);
jObj
.
putOpt
(
EXPIRES
,
this
.
expires
);
jObj
.
put
Opt
(
MESSAGE
,
this
.
message
);
jObj
.
put
Opt
(
OFFER_CATEGORY
,
this
.
offerCategory
);
jObj
.
put
Opt
(
OFFER_MESSAGE
,
this
.
offerMessage
);
jObj
.
put
Opt
(
SESSION_UUID
,
this
.
sessionUUID
);
jObj
.
put
(
MESSAGE
,
this
.
message
!=
null
?
this
.
message
:
JSONObject
.
NULL
);
jObj
.
put
(
OFFER_CATEGORY
,
this
.
offerCategory
!=
null
?
this
.
offerCategory
:
JSONObject
.
NULL
);
jObj
.
put
(
OFFER_MESSAGE
,
this
.
offerMessage
!=
null
?
this
.
offerMessage
:
JSONObject
.
NULL
);
jObj
.
put
(
SESSION_UUID
,
this
.
sessionUUID
!=
null
?
this
.
sessionUUID
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
STARTS
,
this
.
starts
);
jObj
.
put
Opt
(
SUBTITLE
,
this
.
subtitle
);
jObj
.
put
Opt
(
TITLE
,
this
.
title
);
jObj
.
put
(
SUBTITLE
,
this
.
subtitle
!=
null
?
this
.
subtitle
:
JSONObject
.
NULL
);
jObj
.
put
(
TITLE
,
this
.
title
!=
null
?
this
.
title
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
SORTING
,
this
.
sorting
);
jObj
.
putOpt
(
OPENED
,
this
.
opened
);
jObj
.
putOpt
(
IS_NEW
,
this
.
isNew
);
jObj
.
putOpt
(
SORTING
,
this
.
sorting
);
jObj
.
putOpt
(
EXTRA_FIELDS
,
this
.
extraFields
);
jObj
.
putOpt
(
TYPE
,
this
.
type
);
jObj
.
put
(
EXTRA_FIELDS
,
this
.
extraFields
!=
null
?
this
.
extraFields
:
JSONObject
.
NULL
);
jObj
.
put
(
TYPE
,
this
.
type
!=
null
?
this
.
type
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
EXPIRED
,
this
.
expired
);
jObj
.
putOpt
(
SHOW
,
this
.
show
);
jObj
.
put
Opt
(
DELIVERY_METHOD
,
this
.
deliveryMethod
);
jObj
.
put
Opt
(
DISPLAY_TYPE
,
this
.
displayType
);
jObj
.
put
(
BUS_ID
,
this
.
busId
);
jObj
.
put
(
CAMPAIGN_TYPE_SETTINGS
,
this
.
campaignTypeSettings
);
jObj
.
put
(
DELIVERY_METHOD
,
this
.
deliveryMethod
!=
null
?
this
.
deliveryMethod
:
JSONObject
.
NULL
);
jObj
.
put
(
DISPLAY_TYPE
,
this
.
displayType
!=
null
?
this
.
displayType
:
JSONObject
.
NULL
);
jObj
.
put
(
BUS_ID
,
this
.
busId
!=
null
?
this
.
busId
:
JSONObject
.
NULL
);
jObj
.
put
(
CAMPAIGN_TYPE_SETTINGS
,
this
.
campaignTypeSettings
!=
null
?
this
.
campaignTypeSettings
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
COUPON_AVAILABILITY
,
this
.
couponAvailability
);
jObj
.
putOpt
(
CATEGORY_ID
,
this
.
categoryId
);
jObj
.
put
(
CATEGORY_ID
,
this
.
categoryId
!=
null
?
this
.
categoryId
:
JSONObject
.
NULL
);
jObj
.
put
(
COMMUNICATION_UUID
,
this
.
communicationUuid
!=
null
?
this
.
communicationUuid
:
JSONObject
.
NULL
);
jObj
.
put
(
COMMUNICATION_NAME
,
this
.
communicationName
!=
null
?
this
.
communicationName
:
JSONObject
.
NULL
);
jObj
.
put
(
COMMUNICATION_CATEGORY
,
this
.
communicationCategory
!=
null
?
this
.
communicationCategory
:
JSONObject
.
NULL
);
jObj
.
put
(
CATEGORY
,
this
.
category
!=
null
?
this
.
category
:
JSONObject
.
NULL
);
jObj
.
put
(
DESCRIPTION
,
this
.
description
!=
null
?
this
.
description
:
JSONObject
.
NULL
);
jObj
.
put
(
WORKFLOW_SETTINGS
,
this
.
workflowSettings
!=
null
?
this
.
workflowSettings
:
JSONObject
.
NULL
);
jObj
.
put
(
SETTINGS
,
this
.
settings
!=
null
?
this
.
settings
:
JSONObject
.
NULL
);
jObj
.
put
(
AUDIENCE
,
this
.
audience
!=
null
?
this
.
audience
:
JSONObject
.
NULL
);
jObj
.
put
(
START_DATE
,
this
.
startDate
!=
null
?
this
.
startDate
:
JSONObject
.
NULL
);
jObj
.
put
(
END_DATE
,
this
.
endDate
!=
null
?
this
.
endDate
:
JSONObject
.
NULL
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
...
...
@@ -366,7 +459,6 @@ public class Campaign implements Parcelable, Serializable {
// Getters
// ================================================================================
public
String
getCategoryId
()
{
return
categoryId
;
}
...
...
@@ -499,7 +591,7 @@ public class Campaign implements Parcelable, Serializable {
return
indexUrl
;
}
public
String
getExtraFields
()
{
public
JSONObject
getExtraFields
()
{
return
extraFields
;
}
...
...
@@ -615,7 +707,7 @@ public class Campaign implements Parcelable, Serializable {
this
.
logoUrl
=
logoUrl
;
}
public
void
setExtraFields
(
String
extraFields
)
{
public
void
setExtraFields
(
JSONObject
extraFields
)
{
this
.
extraFields
=
extraFields
;
}
...
...
@@ -671,6 +763,70 @@ public class Campaign implements Parcelable, Serializable {
this
.
filter
=
filter
;
}
public
String
getCommunicationUuid
()
{
return
communicationUuid
;
}
public
void
setCommunicationUuid
(
String
communicationUuid
)
{
this
.
communicationUuid
=
communicationUuid
;
}
public
String
getCommunicationName
()
{
return
communicationName
;
}
public
void
setCommunicationName
(
String
communicationName
)
{
this
.
communicationName
=
communicationName
;
}
public
String
getCommunicationCategory
()
{
return
communicationCategory
;
}
public
void
setCommunicationCategory
(
String
communicationCategory
)
{
this
.
communicationCategory
=
communicationCategory
;
}
public
String
getCategory
()
{
return
category
;
}
public
void
setCategory
(
String
category
)
{
this
.
category
=
category
;
}
public
String
getDescription
()
{
return
description
;
}
public
void
setDescription
(
String
description
)
{
this
.
description
=
description
;
}
public
JSONObject
getWorkflowSettings
()
{
return
workflowSettings
;
}
public
void
setWorkflowSettings
(
JSONObject
workflowSettings
)
{
this
.
workflowSettings
=
workflowSettings
;
}
public
JSONObject
getSettings
()
{
return
settings
;
}
public
void
setSettings
(
JSONObject
settings
)
{
this
.
settings
=
settings
;
}
public
String
getAudience
()
{
return
audience
;
}
public
void
setAudience
(
String
audience
)
{
this
.
audience
=
audience
;
}
@Override
public
int
describeContents
()
{
return
0
;
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Content.java
View file @
2b9f74f
...
...
@@ -77,61 +77,68 @@ public class Content implements Parcelable, Serializable {
/* Member variables of the Content object */
private
String
id
=
""
;
private
int
idid
=
0
;
private
String
customId
=
""
;
private
String
name
=
""
;
private
String
description
=
""
;
private
String
shortDescription
=
""
;
private
String
couponDescription
=
""
;
private
boolean
active
=
false
;
private
String
created
=
""
;
private
int
categoryId
=
0
;
private
String
categoryName
=
""
;
private
String
categoryUuid
=
""
;
private
String
merchantUuid
=
""
;
private
ArrayList
<
Tags
>
tags
=
new
ArrayList
<
Tags
>()
;
private
String
startDate
=
""
;
private
String
endDate
=
""
;
private
String
imgPreview
=
""
;
private
ArrayList
<
String
>
img
=
new
ArrayList
<
String
>()
;
private
boolean
favourite
=
false
;
private
JSONObject
extraFields
=
new
JSONObject
()
;
private
String
participated
=
""
;
private
JSONObject
participatedFields
=
new
JSONObject
()
;
private
String
parent
=
""
;
private
int
sorting
=
0
;
private
String
consumerFullName
=
""
;
private
String
consumerPhoto
=
""
;
private
String
id
;
private
int
idid
;
private
String
customId
;
private
String
name
;
private
String
description
;
private
String
shortDescription
;
private
String
couponDescription
;
private
boolean
active
;
private
String
created
;
private
int
categoryId
;
private
String
categoryName
;
private
String
categoryUuid
;
private
String
merchantUuid
;
private
ArrayList
<
Tags
>
tags
;
private
String
startDate
;
private
String
endDate
;
private
String
imgPreview
;
private
ArrayList
<
String
>
img
;
private
boolean
favourite
;
private
JSONObject
extraFields
;
private
String
participated
;
private
JSONObject
participatedFields
;
private
String
parent
;
private
int
sorting
;
private
String
consumerFullName
;
private
String
consumerPhoto
;
/**
* Helper method to get a nullable String from a JSONObject.
* Returns null if the JSON value is null, otherwise returns the String value.
*/
private
static
String
optNullableString
(
JSONObject
json
,
String
key
)
{
return
json
.
isNull
(
key
)
?
null
:
json
.
optString
(
key
);
}
public
Content
()
{
this
.
id
=
""
;
this
.
id
=
null
;
this
.
idid
=
0
;
this
.
customId
=
""
;
this
.
name
=
""
;
this
.
description
=
""
;
this
.
shortDescription
=
""
;
this
.
couponDescription
=
""
;
this
.
customId
=
null
;
this
.
name
=
null
;
this
.
description
=
null
;
this
.
shortDescription
=
null
;
this
.
couponDescription
=
null
;
this
.
active
=
false
;
this
.
created
=
""
;
this
.
created
=
null
;
this
.
categoryId
=
0
;
this
.
categoryName
=
""
;
this
.
categoryUuid
=
""
;
this
.
merchantUuid
=
""
;
this
.
categoryName
=
null
;
this
.
categoryUuid
=
null
;
this
.
merchantUuid
=
null
;
this
.
tags
=
new
ArrayList
<
Tags
>();
this
.
startDate
=
""
;
this
.
endDate
=
""
;
this
.
imgPreview
=
""
;
this
.
startDate
=
null
;
this
.
endDate
=
null
;
this
.
imgPreview
=
null
;
this
.
img
=
new
ArrayList
<
String
>();
this
.
favourite
=
false
;
this
.
extraFields
=
n
ew
JSONObject
()
;
this
.
participated
=
""
;
this
.
participatedFields
=
n
ew
JSONObject
()
;
this
.
parent
=
""
;
this
.
extraFields
=
n
ull
;
this
.
participated
=
null
;
this
.
participatedFields
=
n
ull
;
this
.
parent
=
null
;
this
.
sorting
=
0
;
this
.
consumerFullName
=
""
;
this
.
consumerPhoto
=
""
;
this
.
consumerFullName
=
null
;
this
.
consumerPhoto
=
null
;
}
/**
...
...
@@ -149,19 +156,18 @@ public class Content implements Parcelable, Serializable {
private
static
final
String
NAME
=
"name"
;
private
static
final
String
ID
=
"id"
;
private
String
name
=
""
;
private
String
id
=
""
;
private
String
name
;
private
String
id
;
public
Tags
()
{
this
.
name
=
""
;
this
.
id
=
""
;
this
.
name
=
null
;
this
.
id
=
null
;
}
public
Tags
(
JSONObject
json
)
{
if
(
json
!=
null
)
{
this
.
name
=
json
.
isNull
(
NAME
)
?
""
:
json
.
optString
(
NAME
);
this
.
id
=
json
.
isNull
(
ID
)
?
""
:
json
.
optString
(
ID
);
this
.
name
=
json
.
isNull
(
NAME
)
?
null
:
json
.
optString
(
NAME
);
this
.
id
=
json
.
isNull
(
ID
)
?
null
:
json
.
optString
(
ID
);
}
}
...
...
@@ -189,48 +195,50 @@ public class Content implements Parcelable, Serializable {
*/
public
Content
(
JSONObject
json
)
{
if
(
json
!=
null
)
{
this
.
id
=
json
.
optString
(
ID
);
this
.
id
=
optNullableString
(
json
,
ID
);
this
.
idid
=
json
.
optInt
(
ID_ID
);
this
.
customId
=
json
.
isNull
(
CUSTOM_ID
)
?
""
:
json
.
optString
(
CUSTOM_ID
);
this
.
name
=
json
.
optString
(
NAME
);
this
.
description
=
json
.
optString
(
DESCRIPTION
);
this
.
shortDescription
=
json
.
optString
(
SHORT_DESCRIPTION
);
this
.
couponDescription
=
json
.
optString
(
COUPON_DESCRIPTION
);
this
.
customId
=
optNullableString
(
json
,
CUSTOM_ID
);
this
.
name
=
optNullableString
(
json
,
NAME
);
this
.
description
=
optNullableString
(
json
,
DESCRIPTION
);
this
.
shortDescription
=
optNullableString
(
json
,
SHORT_DESCRIPTION
);
this
.
couponDescription
=
optNullableString
(
json
,
COUPON_DESCRIPTION
);
this
.
active
=
json
.
optBoolean
(
ACTIVE
);
this
.
created
=
json
.
optString
(
CREATED
);
this
.
created
=
optNullableString
(
json
,
CREATED
);
this
.
categoryId
=
json
.
optInt
(
CATEGORY_ID
);
this
.
categoryName
=
json
.
optString
(
CATEGORY_NAME
);
this
.
categoryUuid
=
json
.
optString
(
CATEGORY_UUID
);
this
.
merchantUuid
=
json
.
isNull
(
MERCHANT_UUID
)
?
""
:
json
.
optString
(
MERCHANT_UUID
);
this
.
categoryName
=
optNullableString
(
json
,
CATEGORY_NAME
);
this
.
categoryUuid
=
optNullableString
(
json
,
CATEGORY_UUID
);
this
.
merchantUuid
=
optNullableString
(
json
,
MERCHANT_UUID
);
JSONArray
tempTags
=
json
.
optJSONArray
(
TAGS
);
if
(
tempTags
!=
null
)
{
this
.
tags
=
new
ArrayList
<
Tags
>();
for
(
int
i
=
0
;
i
<
tempTags
.
length
();
i
++)
{
this
.
tags
.
add
(
new
Tags
(
tempTags
.
optJSONObject
(
i
)));
}
}
else
{
this
.
tags
=
n
ew
ArrayList
<
Tags
>()
;
this
.
tags
=
n
ull
;
}
this
.
startDate
=
json
.
isNull
(
START_DATE
)
?
""
:
json
.
optString
(
START_DATE
);
this
.
endDate
=
json
.
isNull
(
END_DATE
)
?
""
:
json
.
optString
(
END_DATE
);
this
.
imgPreview
=
json
.
optString
(
IMG_PREVIEW
);
this
.
startDate
=
optNullableString
(
json
,
START_DATE
);
this
.
endDate
=
optNullableString
(
json
,
END_DATE
);
this
.
imgPreview
=
optNullableString
(
json
,
IMG_PREVIEW
);
try
{
JSONArray
tempImg
=
new
JSONArray
(
json
.
optString
(
IMG
));
if
(
tempImg
!=
null
)
{
this
.
img
=
new
ArrayList
<
String
>();
for
(
int
i
=
0
;
i
<
tempImg
.
length
();
i
++)
{
this
.
img
.
add
(
tempImg
.
optString
(
i
));
}
}
}
catch
(
JSONException
e
)
{
this
.
img
=
n
ew
ArrayList
<
String
>()
;
this
.
img
=
n
ull
;
}
this
.
favourite
=
json
.
optBoolean
(
FAVOURITE
);
this
.
extraFields
=
json
.
optJSONObject
(
EXTRA_FIELDS
);
this
.
participated
=
json
.
isNull
(
PARTICIPATED
)
?
""
:
json
.
optString
(
PARTICIPATED
);
this
.
participated
=
optNullableString
(
json
,
PARTICIPATED
);
this
.
participatedFields
=
json
.
optJSONObject
(
PARTICIPATED_FIELDS
);
this
.
parent
=
json
.
isNull
(
PARENT
)
?
""
:
json
.
optString
(
PARENT
);
this
.
parent
=
optNullableString
(
json
,
PARENT
);
this
.
sorting
=
json
.
optInt
(
SORTING
);
this
.
consumerFullName
=
json
.
isNull
(
CONSUMER_FULL_NAME
)
?
""
:
json
.
optString
(
CONSUMER_FULL_NAME
);
this
.
consumerPhoto
=
json
.
isNull
(
CONSUMER_PHOTO
)
?
""
:
json
.
optString
(
CONSUMER_PHOTO
);
this
.
consumerFullName
=
optNullableString
(
json
,
CONSUMER_FULL_NAME
);
this
.
consumerPhoto
=
optNullableString
(
json
,
CONSUMER_PHOTO
);
}
}
...
...
@@ -248,15 +256,25 @@ public class Content implements Parcelable, Serializable {
this
.
categoryName
=
source
.
readString
();
this
.
categoryUuid
=
source
.
readString
();
this
.
merchantUuid
=
source
.
readString
();
this
.
tags
=
source
.
readArrayList
(
null
);
this
.
tags
=
source
.
readArrayList
(
Tags
.
class
.
getClassLoader
()
);
this
.
startDate
=
source
.
readString
();
this
.
endDate
=
source
.
readString
();
this
.
imgPreview
=
source
.
readString
();
this
.
img
=
source
.
createStringArrayList
();
this
.
favourite
=
source
.
readByte
()
!=
0
;
this
.
extraFields
=
(
JSONObject
)
source
.
readSerializable
();
try
{
String
extraFieldsStr
=
source
.
readString
();
this
.
extraFields
=
extraFieldsStr
!=
null
?
new
JSONObject
(
extraFieldsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
extraFields
=
null
;
}
this
.
participated
=
source
.
readString
();
this
.
participatedFields
=
(
JSONObject
)
source
.
readSerializable
();
try
{
String
participatedFieldsStr
=
source
.
readString
();
this
.
participatedFields
=
participatedFieldsStr
!=
null
?
new
JSONObject
(
participatedFieldsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
participatedFields
=
null
;
}
this
.
parent
=
source
.
readString
();
this
.
sorting
=
source
.
readInt
();
this
.
consumerFullName
=
source
.
readString
();
...
...
@@ -284,9 +302,9 @@ public class Content implements Parcelable, Serializable {
dest
.
writeString
(
this
.
imgPreview
);
dest
.
writeStringList
(
this
.
img
);
dest
.
writeByte
(
this
.
favourite
?
(
byte
)
1
:
(
byte
)
0
);
dest
.
writeS
erializable
((
Serializable
)
this
.
extraFields
);
dest
.
writeS
tring
(
this
.
extraFields
!=
null
?
this
.
extraFields
.
toString
()
:
null
);
dest
.
writeString
(
this
.
participated
);
dest
.
writeS
erializable
((
Serializable
)
this
.
participatedFields
);
dest
.
writeS
tring
(
this
.
participatedFields
!=
null
?
this
.
participatedFields
.
toString
()
:
null
);
dest
.
writeString
(
this
.
parent
);
dest
.
writeInt
(
this
.
sorting
);
dest
.
writeString
(
this
.
consumerFullName
);
...
...
@@ -301,8 +319,48 @@ public class Content implements Parcelable, Serializable {
public
JSONObject
toJSONObject
()
{
JSONObject
jObj
=
new
JSONObject
();
try
{
jObj
.
put
Opt
(
ID
,
this
.
id
);
jObj
.
put
(
ID
,
this
.
id
!=
null
?
this
.
id
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
ID_ID
,
this
.
idid
);
jObj
.
put
(
CUSTOM_ID
,
this
.
customId
!=
null
?
this
.
customId
:
JSONObject
.
NULL
);
jObj
.
put
(
NAME
,
this
.
name
!=
null
?
this
.
name
:
JSONObject
.
NULL
);
jObj
.
put
(
DESCRIPTION
,
this
.
description
!=
null
?
this
.
description
:
JSONObject
.
NULL
);
jObj
.
put
(
SHORT_DESCRIPTION
,
this
.
shortDescription
!=
null
?
this
.
shortDescription
:
JSONObject
.
NULL
);
jObj
.
put
(
COUPON_DESCRIPTION
,
this
.
couponDescription
!=
null
?
this
.
couponDescription
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
ACTIVE
,
this
.
active
);
jObj
.
put
(
CREATED
,
this
.
created
!=
null
?
this
.
created
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
CATEGORY_ID
,
this
.
categoryId
);
jObj
.
put
(
CATEGORY_NAME
,
this
.
categoryName
!=
null
?
this
.
categoryName
:
JSONObject
.
NULL
);
jObj
.
put
(
CATEGORY_UUID
,
this
.
categoryUuid
!=
null
?
this
.
categoryUuid
:
JSONObject
.
NULL
);
jObj
.
put
(
MERCHANT_UUID
,
this
.
merchantUuid
!=
null
?
this
.
merchantUuid
:
JSONObject
.
NULL
);
if
(
this
.
tags
!=
null
)
{
JSONArray
tagsArray
=
new
JSONArray
();
for
(
Tags
tag
:
this
.
tags
)
{
JSONObject
tagObj
=
new
JSONObject
();
tagObj
.
put
(
Tags
.
ID
,
tag
.
getId
()
!=
null
?
tag
.
getId
()
:
JSONObject
.
NULL
);
tagObj
.
put
(
Tags
.
NAME
,
tag
.
getName
()
!=
null
?
tag
.
getName
()
:
JSONObject
.
NULL
);
tagsArray
.
put
(
tagObj
);
}
jObj
.
put
(
TAGS
,
tagsArray
);
}
else
{
jObj
.
put
(
TAGS
,
JSONObject
.
NULL
);
}
jObj
.
put
(
START_DATE
,
this
.
startDate
!=
null
?
this
.
startDate
:
JSONObject
.
NULL
);
jObj
.
put
(
END_DATE
,
this
.
endDate
!=
null
?
this
.
endDate
:
JSONObject
.
NULL
);
jObj
.
put
(
IMG_PREVIEW
,
this
.
imgPreview
!=
null
?
this
.
imgPreview
:
JSONObject
.
NULL
);
if
(
this
.
img
!=
null
)
{
JSONArray
imgArray
=
new
JSONArray
(
this
.
img
);
jObj
.
put
(
IMG
,
imgArray
.
toString
());
}
else
{
jObj
.
put
(
IMG
,
JSONObject
.
NULL
);
}
jObj
.
putOpt
(
FAVOURITE
,
this
.
favourite
);
jObj
.
put
(
EXTRA_FIELDS
,
this
.
extraFields
!=
null
?
this
.
extraFields
:
JSONObject
.
NULL
);
jObj
.
put
(
PARTICIPATED
,
this
.
participated
!=
null
?
this
.
participated
:
JSONObject
.
NULL
);
jObj
.
put
(
PARTICIPATED_FIELDS
,
this
.
participatedFields
!=
null
?
this
.
participatedFields
:
JSONObject
.
NULL
);
jObj
.
put
(
PARENT
,
this
.
parent
!=
null
?
this
.
parent
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
SORTING
,
this
.
sorting
);
jObj
.
put
(
CONSUMER_FULL_NAME
,
this
.
consumerFullName
!=
null
?
this
.
consumerFullName
:
JSONObject
.
NULL
);
jObj
.
put
(
CONSUMER_PHOTO
,
this
.
consumerPhoto
!=
null
?
this
.
consumerPhoto
:
JSONObject
.
NULL
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
...
...
@@ -341,7 +399,6 @@ public class Content implements Parcelable, Serializable {
// Getters
// ================================================================================
public
String
getId
()
{
return
id
;
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Couponset.java
View file @
2b9f74f
...
...
@@ -33,9 +33,7 @@ import org.json.JSONException;
import
org.json.JSONObject
;
import
java.io.Serializable
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.ArrayList
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.utils.constants.WarpConstants
;
...
...
@@ -48,7 +46,7 @@ public class Couponset implements Parcelable, Serializable {
private
static
final
long
serialVersionUID
=
-
4754964462459705285L
;
/* Constants used to export the
campaign
in JSON formal and vice versa */
/* Constants used to export the
Couponset
in JSON formal and vice versa */
private
static
final
String
UUID
=
"uuid"
;
private
static
final
String
ADMIN_NAME
=
"admin_name"
;
...
...
@@ -66,7 +64,6 @@ public class Couponset implements Parcelable, Serializable {
private
static
final
String
POINTS
=
"points"
;
private
static
final
String
POINTS_CAUSE
=
"points_cause"
;
private
static
final
String
EXPIRATION
=
"expiration"
;
private
static
final
String
VALUE
=
"value"
;
private
static
final
String
THIRD_PARTY_SERVICE
=
"third_party_service"
;
private
static
final
String
NAME
=
"name"
;
private
static
final
String
DESCRIPTION
=
"description"
;
...
...
@@ -86,112 +83,156 @@ public class Couponset implements Parcelable, Serializable {
private
static
final
String
LOCKED
=
"locked"
;
private
static
final
String
UNLOCK_ACTION
=
"unlock_action"
;
private
static
final
String
UNLOCK_MESSAGE
=
"unlock_message"
;
private
static
final
String
ELIGIBILITIES
=
"eligibilities"
;
private
static
final
String
START_DATE
=
"start_date"
;
private
static
final
String
END_DATE
=
"end_date"
;
private
static
final
String
HIDE_CONDITION
=
"hide_condition"
;
private
static
final
String
SHOW_AS_BANNER
=
"show_as_banner"
;
private
static
final
String
SEGMENT
=
"segment"
;
private
static
final
String
OFFER_CATEGORY
=
"offer_category"
;
private
static
final
String
TAGGING
=
"tagging"
;
private
static
final
String
REGIONS
=
"regions"
;
/* Member variables of the Couponset object */
private
String
uuid
;
private
String
admin_name
;
private
String
created
;
private
String
updated
;
private
String
app_uuid
;
private
JSONArray
img
;
private
String
img_preview
;
private
Integer
sorting
;
private
boolean
active
;
private
boolean
visible
;
private
boolean
buyable
;
private
boolean
user_generated
;
private
JSONObject
limits
;
private
int
points
;
private
String
points_cause
;
private
JSONObject
expiration
;
private
boolean
third_party_service
;
private
String
name
;
private
String
description
;
private
String
short_description
;
private
String
discount
;
private
String
category
;
private
String
terms
;
private
int
availability
;
private
String
merchantUuid
;
private
String
innerText
;
private
String
discount_type
;
private
double
final_price
;
private
String
couponsetType
;
private
JSONObject
extraFields
;
private
boolean
isNew
;
private
boolean
promoted
;
private
boolean
personalized
;
private
boolean
locked
;
private
String
unlockAction
;
private
String
unlockMessage
;
private
JSONObject
eligibilities
;
private
String
startDate
;
private
String
endDate
;
private
JSONObject
hideCondition
;
private
JSONObject
showAsBanner
;
private
String
segment
;
private
String
offerCategory
;
private
JSONObject
tagging
;
private
JSONArray
regions
;
private
Merchant
merchant
;
/* Member variables of the Campaign object */
private
String
uuid
=
""
;
private
String
admin_name
=
""
;
private
String
created
=
""
;
private
String
updated
=
""
;
private
String
app_uuid
=
""
;
private
JSONArray
img
=
new
JSONArray
();
private
String
img_preview
=
""
;
private
int
sorting
=
0
;
private
boolean
active
=
false
;
private
boolean
visible
=
false
;
private
boolean
buyable
=
false
;
private
boolean
user_generated
=
false
;
private
JSONObject
limits
=
new
JSONObject
();
private
int
points
=
0
;
private
String
points_cause
=
""
;
private
String
expiration
=
""
;
private
boolean
third_party_service
=
false
;
private
String
name
=
""
;
private
String
description
=
""
;
private
String
short_description
=
""
;
private
String
discount
=
""
;
private
String
category
=
""
;
private
String
terms
=
""
;
private
int
availability
=
0
;
private
String
merchantUuid
=
""
;
private
String
innerText
=
""
;
private
String
discount_type
=
""
;
private
double
final_price
=
0.0d
;
private
Date
endDate
=
new
Date
();
private
String
couponsetType
=
""
;
private
JSONObject
extraFields
=
new
JSONObject
();
private
boolean
isNew
=
false
;
private
boolean
promoted
=
false
;
private
boolean
personalized
=
false
;
private
boolean
locked
=
false
;
private
String
unlockAction
=
""
;
private
String
unlockMessage
=
""
;
/**
* Helper method to get a nullable String from a JSONObject.
* Returns null if the JSON value is null, otherwise returns the String value.
*/
private
static
String
optNullableString
(
JSONObject
json
,
String
key
)
{
return
json
.
isNull
(
key
)
?
null
:
json
.
optString
(
key
);
}
public
Couponset
()
{
this
.
uuid
=
""
;
this
.
admin_name
=
""
;
this
.
created
=
""
;
this
.
updated
=
""
;
this
.
app_uuid
=
""
;
this
.
img
=
n
ew
JSONArray
()
;
this
.
img_preview
=
""
;
this
.
sorting
=
0
;
this
.
uuid
=
null
;
this
.
admin_name
=
null
;
this
.
created
=
null
;
this
.
updated
=
null
;
this
.
app_uuid
=
null
;
this
.
img
=
n
ull
;
this
.
img_preview
=
null
;
this
.
sorting
=
null
;
this
.
active
=
false
;
this
.
visible
=
false
;
this
.
buyable
=
false
;
this
.
user_generated
=
false
;
this
.
limits
=
n
ew
JSONObject
()
;
this
.
limits
=
n
ull
;
this
.
points
=
0
;
this
.
points_cause
=
""
;
this
.
expiration
=
""
;
this
.
points_cause
=
null
;
this
.
expiration
=
null
;
this
.
third_party_service
=
false
;
this
.
name
=
""
;
this
.
description
=
""
;
this
.
short_description
=
""
;
this
.
discount
=
""
;
this
.
category
=
""
;
this
.
terms
=
""
;
this
.
name
=
null
;
this
.
description
=
null
;
this
.
short_description
=
null
;
this
.
discount
=
null
;
this
.
category
=
null
;
this
.
terms
=
null
;
this
.
availability
=
0
;
this
.
merchantUuid
=
""
;
this
.
innerText
=
""
;
this
.
discount_type
=
""
;
this
.
merchantUuid
=
null
;
this
.
innerText
=
null
;
this
.
discount_type
=
null
;
this
.
final_price
=
0.0d
;
this
.
extraFields
=
new
JSONObject
();
this
.
couponsetType
=
null
;
this
.
extraFields
=
null
;
this
.
isNew
=
false
;
this
.
promoted
=
false
;
this
.
personalized
=
false
;
this
.
locked
=
false
;
this
.
unlockAction
=
""
;
this
.
unlockMessage
=
""
;
this
.
unlockAction
=
null
;
this
.
unlockMessage
=
null
;
this
.
eligibilities
=
null
;
this
.
startDate
=
null
;
this
.
endDate
=
null
;
this
.
hideCondition
=
null
;
this
.
showAsBanner
=
null
;
this
.
segment
=
null
;
this
.
offerCategory
=
null
;
this
.
tagging
=
null
;
this
.
regions
=
null
;
this
.
merchant
=
null
;
}
public
Couponset
(
boolean
isUniversal
)
{
this
.
admin_name
=
""
;
this
.
uuid
=
null
;
this
.
admin_name
=
null
;
this
.
active
=
false
;
this
.
buyable
=
false
;
this
.
category
=
""
;
this
.
created
=
""
;
this
.
discount
=
""
;
this
.
discount_type
=
""
;
this
.
name
=
""
;
this
.
img
=
new
JSONArray
();
this
.
short_description
=
""
;
this
.
terms
=
""
;
this
.
updated
=
""
;
this
.
uuid
=
""
;
// this.endDate = new Date();
this
.
couponsetType
=
""
;
this
.
img_preview
=
""
;
this
.
innerText
=
""
;
this
.
category
=
null
;
this
.
created
=
null
;
this
.
discount
=
null
;
this
.
discount_type
=
null
;
this
.
name
=
null
;
this
.
img
=
null
;
this
.
img_preview
=
null
;
this
.
short_description
=
null
;
this
.
terms
=
null
;
this
.
updated
=
null
;
this
.
couponsetType
=
null
;
this
.
innerText
=
null
;
this
.
final_price
=
0.0d
;
this
.
extraFields
=
n
ew
JSONObject
()
;
this
.
extraFields
=
n
ull
;
this
.
isNew
=
false
;
this
.
promoted
=
false
;
this
.
personalized
=
false
;
this
.
locked
=
false
;
this
.
unlockAction
=
""
;
this
.
unlockMessage
=
""
;
this
.
unlockAction
=
null
;
this
.
unlockMessage
=
null
;
this
.
eligibilities
=
null
;
this
.
startDate
=
null
;
this
.
endDate
=
null
;
this
.
hideCondition
=
null
;
this
.
showAsBanner
=
null
;
this
.
segment
=
null
;
this
.
offerCategory
=
null
;
this
.
tagging
=
null
;
this
.
regions
=
null
;
}
/**
...
...
@@ -208,23 +249,22 @@ public class Couponset implements Parcelable, Serializable {
/**
* Constructor used to create an Object from a given JSON Object
*
* @param json JSON Object used to create the
Address
* @param json JSON Object used to create the
Couponset
*/
public
Couponset
(
JSONObject
json
)
{
if
(
json
!=
null
)
{
this
.
uuid
=
json
.
optString
(
UUID
);
this
.
admin_name
=
json
.
optString
(
ADMIN_NAME
);
this
.
created
=
json
.
optString
(
CREATED
);
this
.
updated
=
json
.
optString
(
UPDATED
);
this
.
app_uuid
=
json
.
optString
(
APP_UUID
);
// this.img = json.optJSONArray(IMG);
this
.
uuid
=
optNullableString
(
json
,
UUID
);
this
.
admin_name
=
optNullableString
(
json
,
ADMIN_NAME
);
this
.
created
=
optNullableString
(
json
,
CREATED
);
this
.
updated
=
optNullableString
(
json
,
UPDATED
);
this
.
app_uuid
=
optNullableString
(
json
,
APP_UUID
);
try
{
this
.
img
=
new
JSONArray
(
json
.
optString
(
IMG
));
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
()
;
this
.
img
=
null
;
}
this
.
img_preview
=
json
.
optString
(
IMG_PREVIEW
);
this
.
sorting
=
json
.
optInt
(
SORTING
);
this
.
img_preview
=
optNullableString
(
json
,
IMG_PREVIEW
);
this
.
sorting
=
json
.
isNull
(
SORTING
)
?
null
:
json
.
optInt
(
SORTING
);
this
.
active
=
json
.
optBoolean
(
ACTIVE
);
this
.
visible
=
json
.
optBoolean
(
VISIBLE
);
this
.
buyable
=
json
.
optBoolean
(
BUYABLE
);
...
...
@@ -232,102 +272,77 @@ public class Couponset implements Parcelable, Serializable {
this
.
promoted
=
json
.
optBoolean
(
PROMOTED
);
this
.
personalized
=
json
.
optBoolean
(
PERSONALIZED
);
this
.
locked
=
json
.
optBoolean
(
LOCKED
);
this
.
unlockAction
=
json
.
optString
(
UNLOCK_ACTION
);
this
.
unlockMessage
=
json
.
optString
(
UNLOCK_MESSAGE
);
this
.
unlockAction
=
optNullableString
(
json
,
UNLOCK_ACTION
);
this
.
unlockMessage
=
optNullableString
(
json
,
UNLOCK_MESSAGE
);
this
.
user_generated
=
json
.
optBoolean
(
USER_GENERATED
);
this
.
limits
=
json
.
optJSONObject
(
LIMITS
);
this
.
points
=
json
.
optInt
(
POINTS
);
this
.
points_cause
=
json
.
optString
(
POINTS_CAUSE
);
JSONObject
exp
=
null
;
try
{
exp
=
new
JSONObject
(
json
.
optString
(
EXPIRATION
));
this
.
expiration
=
exp
.
optString
(
VALUE
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
this
.
expiration
=
""
;
}
this
.
points_cause
=
optNullableString
(
json
,
POINTS_CAUSE
);
this
.
expiration
=
json
.
optJSONObject
(
EXPIRATION
);
this
.
third_party_service
=
json
.
optBoolean
(
THIRD_PARTY_SERVICE
);
this
.
name
=
json
.
optString
(
NAME
);
this
.
description
=
json
.
optString
(
DESCRIPTION
);
this
.
short_description
=
json
.
optString
(
SHORT_DESCRIPTION
);
this
.
discount
=
json
.
optString
(
DISCOUNT
);
this
.
category
=
json
.
optString
(
CATEGORY
);
this
.
terms
=
json
.
optString
(
TERMS
);
this
.
name
=
optNullableString
(
json
,
NAME
);
this
.
description
=
optNullableString
(
json
,
DESCRIPTION
);
this
.
short_description
=
optNullableString
(
json
,
SHORT_DESCRIPTION
);
this
.
discount
=
optNullableString
(
json
,
DISCOUNT
);
this
.
category
=
optNullableString
(
json
,
CATEGORY
);
this
.
terms
=
optNullableString
(
json
,
TERMS
);
this
.
availability
=
json
.
optInt
(
AVAILABILITY
);
this
.
merchantUuid
=
json
.
optString
(
MERCHANT_UUID
);
this
.
innerText
=
json
.
optString
(
INNER_TEXT
);
this
.
discount_type
=
json
.
isNull
(
DISCOUNT_TYPE
)
?
""
:
json
.
optString
(
DISCOUNT_TYPE
);
this
.
merchantUuid
=
optNullableString
(
json
,
MERCHANT_UUID
);
this
.
innerText
=
optNullableString
(
json
,
INNER_TEXT
);
this
.
discount_type
=
optNullableString
(
json
,
DISCOUNT_TYPE
);
this
.
final_price
=
json
.
isNull
(
FINAL_PRICE
)
?
0.0d
:
json
.
optDouble
(
FINAL_PRICE
);
// this.extraFields = json.optJSONObject(EXTRA_FIELDS);
JSONObject
ef
=
null
;
ef
=
json
.
optJSONObject
(
EXTRA_FIELDS
);
this
.
extraFields
=
ef
;
this
.
extraFields
=
json
.
optJSONObject
(
EXTRA_FIELDS
);
this
.
eligibilities
=
json
.
optJSONObject
(
ELIGIBILITIES
);
this
.
startDate
=
optNullableString
(
json
,
START_DATE
);
this
.
endDate
=
optNullableString
(
json
,
END_DATE
);
this
.
hideCondition
=
json
.
optJSONObject
(
HIDE_CONDITION
);
this
.
showAsBanner
=
json
.
optJSONObject
(
SHOW_AS_BANNER
);
this
.
segment
=
optNullableString
(
json
,
SEGMENT
);
this
.
offerCategory
=
optNullableString
(
json
,
OFFER_CATEGORY
);
this
.
tagging
=
json
.
optJSONObject
(
TAGGING
);
this
.
regions
=
json
.
optJSONArray
(
REGIONS
);
}
}
public
Couponset
(
JSONObject
json
,
boolean
isUniversal
)
{
if
(
json
!=
null
)
{
this
.
uuid
=
json
.
optString
(
UUID
);
this
.
admin_name
=
json
.
optString
(
ADMIN_NAME
);
this
.
created
=
json
.
optString
(
CREATED
);
this
.
updated
=
json
.
optString
(
UPDATED
);
// this.img = json.optJSONArray(IMG);
this
.
uuid
=
optNullableString
(
json
,
UUID
);
this
.
admin_name
=
optNullableString
(
json
,
ADMIN_NAME
);
this
.
created
=
optNullableString
(
json
,
CREATED
);
this
.
updated
=
optNullableString
(
json
,
UPDATED
);
try
{
this
.
img
=
new
JSONArray
(
json
.
optString
(
IMG
));
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
()
;
this
.
img
=
null
;
}
this
.
isNew
=
json
.
optBoolean
(
IS_NEW
);
this
.
promoted
=
json
.
optBoolean
(
PROMOTED
);
this
.
personalized
=
json
.
optBoolean
(
PERSONALIZED
);
this
.
locked
=
json
.
optBoolean
(
LOCKED
);
this
.
unlockAction
=
json
.
optString
(
UNLOCK_ACTION
);
this
.
unlockMessage
=
json
.
optString
(
UNLOCK_MESSAGE
);
this
.
unlockAction
=
optNullableString
(
json
,
UNLOCK_ACTION
);
this
.
unlockMessage
=
optNullableString
(
json
,
UNLOCK_MESSAGE
);
this
.
active
=
json
.
optBoolean
(
ACTIVE
);
this
.
buyable
=
json
.
optBoolean
(
BUYABLE
);
this
.
name
=
json
.
optString
(
NAME
);
this
.
short_description
=
json
.
optString
(
SHORT_DESCRIPTION
);
this
.
discount
=
json
.
optString
(
DISCOUNT
);
this
.
category
=
json
.
optString
(
CATEGORY
);
this
.
terms
=
json
.
optString
(
TERMS
);
this
.
discount_type
=
json
.
isNull
(
DISCOUNT_TYPE
)
?
""
:
json
.
optString
(
DISCOUNT_TYPE
);
this
.
couponsetType
=
json
.
optString
(
"couponset_type"
);
this
.
img_preview
=
json
.
optString
(
IMG_PREVIEW
);
this
.
innerText
=
json
.
optString
(
INNER_TEXT
);
this
.
name
=
optNullableString
(
json
,
NAME
);
this
.
short_description
=
optNullableString
(
json
,
SHORT_DESCRIPTION
);
this
.
discount
=
optNullableString
(
json
,
DISCOUNT
);
this
.
category
=
optNullableString
(
json
,
CATEGORY
);
this
.
terms
=
optNullableString
(
json
,
TERMS
);
this
.
discount_type
=
optNullableString
(
json
,
DISCOUNT_TYPE
);
this
.
couponsetType
=
optNullableString
(
json
,
"couponset_type"
);
this
.
img_preview
=
optNullableString
(
json
,
IMG_PREVIEW
);
this
.
innerText
=
optNullableString
(
json
,
INNER_TEXT
);
this
.
final_price
=
json
.
isNull
(
FINAL_PRICE
)
?
0.0d
:
json
.
optDouble
(
FINAL_PRICE
);
this
.
extraFields
=
json
.
optJSONObject
(
EXTRA_FIELDS
);
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
// Date newDate = new Date();
// String tempRedeemDate = json.optString("end_date");
// try {
// newDate = simpleDateFormat.parse(tempRedeemDate);
// this.endDate = newDate;
// } catch (ParseException e) {
// e.printStackTrace();
// }
// this.app_uuid = json.optString(APP_UUID);
// this.img_preview = json.optString(IMG_PREVIEW);
// this.sorting = json.optInt(SORTING);
// this.visible = json.optBoolean(VISIBLE);
// this.user_generated = json.optBoolean(USER_GENERATED);
// this.limits = json.optJSONObject(LIMITS);
// this.points = json.optInt(POINTS);
// this.points_cause = json.optString(POINTS_CAUSE);
// JSONObject exp = null;
// try {
// exp = new JSONObject(json.optString(EXPIRATION));
// this.expiration = exp.optString(VALUE);
// } catch (JSONException e) {
// e.printStackTrace();
// this.expiration = "";
// }
// this.third_party_service = json.optBoolean(THIRD_PARTY_SERVICE);
// this.description = json.optString(DESCRIPTION);
// this.availability = json.optInt(AVAILABILITY);
// this.merchantUuid = json.optString(MERCHANT_UUID);
// this.innerText = json.optString(INNER_TEXT);
// this.final_price = json.isNull(FINAL_PRICE) ? 0.0d : json.optDouble(FINAL_PRICE);
this
.
eligibilities
=
json
.
optJSONObject
(
ELIGIBILITIES
);
this
.
startDate
=
optNullableString
(
json
,
START_DATE
);
this
.
endDate
=
optNullableString
(
json
,
END_DATE
);
this
.
hideCondition
=
json
.
optJSONObject
(
HIDE_CONDITION
);
this
.
showAsBanner
=
json
.
optJSONObject
(
SHOW_AS_BANNER
);
this
.
segment
=
optNullableString
(
json
,
SEGMENT
);
this
.
offerCategory
=
optNullableString
(
json
,
OFFER_CATEGORY
);
this
.
tagging
=
json
.
optJSONObject
(
TAGGING
);
this
.
regions
=
json
.
optJSONArray
(
REGIONS
);
}
}
...
...
@@ -337,15 +352,33 @@ public class Couponset implements Parcelable, Serializable {
this
.
created
=
source
.
readString
();
this
.
updated
=
source
.
readString
();
this
.
app_uuid
=
source
.
readString
();
try
{
String
imgStr
=
source
.
readString
();
this
.
img
=
imgStr
!=
null
?
new
JSONArray
(
imgStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
img
=
null
;
}
this
.
img_preview
=
source
.
readString
();
this
.
sorting
=
source
.
readInt
();
int
sortingVal
=
source
.
readInt
();
this
.
sorting
=
sortingVal
==
Integer
.
MIN_VALUE
?
null
:
sortingVal
;
this
.
active
=
source
.
readByte
()
!=
0
;
this
.
visible
=
source
.
readByte
()
!=
0
;
this
.
buyable
=
source
.
readByte
()
!=
0
;
this
.
user_generated
=
source
.
readByte
()
!=
0
;
try
{
String
limitsStr
=
source
.
readString
();
this
.
limits
=
limitsStr
!=
null
?
new
JSONObject
(
limitsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
limits
=
null
;
}
this
.
points
=
source
.
readInt
();
this
.
points_cause
=
source
.
readString
();
this
.
expiration
=
source
.
readString
();
try
{
String
expirationStr
=
source
.
readString
();
this
.
expiration
=
expirationStr
!=
null
?
new
JSONObject
(
expirationStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
expiration
=
null
;
}
this
.
third_party_service
=
source
.
readByte
()
!=
0
;
this
.
name
=
source
.
readString
();
this
.
description
=
source
.
readString
();
...
...
@@ -358,12 +391,53 @@ public class Couponset implements Parcelable, Serializable {
this
.
innerText
=
source
.
readString
();
this
.
discount_type
=
source
.
readString
();
this
.
final_price
=
source
.
readDouble
();
this
.
couponsetType
=
source
.
readString
();
try
{
String
extraFieldsStr
=
source
.
readString
();
this
.
extraFields
=
extraFieldsStr
!=
null
?
new
JSONObject
(
extraFieldsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
extraFields
=
null
;
}
this
.
isNew
=
source
.
readByte
()
!=
0
;
this
.
promoted
=
source
.
readByte
()
!=
0
;
this
.
personalized
=
source
.
readByte
()
!=
0
;
this
.
locked
=
source
.
readByte
()
!=
0
;
this
.
unlockAction
=
source
.
readString
();
this
.
unlockMessage
=
source
.
readString
();
try
{
String
eligibilitiesStr
=
source
.
readString
();
this
.
eligibilities
=
eligibilitiesStr
!=
null
?
new
JSONObject
(
eligibilitiesStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
eligibilities
=
null
;
}
this
.
startDate
=
source
.
readString
();
this
.
endDate
=
source
.
readString
();
try
{
String
hideConditionStr
=
source
.
readString
();
this
.
hideCondition
=
hideConditionStr
!=
null
?
new
JSONObject
(
hideConditionStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
hideCondition
=
null
;
}
try
{
String
showAsBannerStr
=
source
.
readString
();
this
.
showAsBanner
=
showAsBannerStr
!=
null
?
new
JSONObject
(
showAsBannerStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
showAsBanner
=
null
;
}
this
.
segment
=
source
.
readString
();
this
.
offerCategory
=
source
.
readString
();
try
{
String
taggingStr
=
source
.
readString
();
this
.
tagging
=
taggingStr
!=
null
?
new
JSONObject
(
taggingStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
tagging
=
null
;
}
try
{
String
regionsStr
=
source
.
readString
();
this
.
regions
=
regionsStr
!=
null
?
new
JSONArray
(
regionsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
regions
=
null
;
}
}
@Override
...
...
@@ -373,15 +447,17 @@ public class Couponset implements Parcelable, Serializable {
dest
.
writeString
(
this
.
created
);
dest
.
writeString
(
this
.
updated
);
dest
.
writeString
(
this
.
app_uuid
);
dest
.
writeString
(
this
.
img
!=
null
?
this
.
img
.
toString
()
:
null
);
dest
.
writeString
(
this
.
img_preview
);
dest
.
writeInt
(
this
.
sorting
);
dest
.
writeInt
(
this
.
sorting
!=
null
?
this
.
sorting
:
Integer
.
MIN_VALUE
);
dest
.
writeByte
((
byte
)
(
this
.
active
?
1
:
0
));
dest
.
writeByte
((
byte
)
(
this
.
visible
?
1
:
0
));
dest
.
writeByte
((
byte
)
(
this
.
buyable
?
1
:
0
));
dest
.
writeByte
((
byte
)
(
this
.
user_generated
?
1
:
0
));
dest
.
writeString
(
this
.
limits
!=
null
?
this
.
limits
.
toString
()
:
null
);
dest
.
writeInt
(
this
.
points
);
dest
.
writeString
(
this
.
points_cause
);
dest
.
writeString
(
this
.
expiration
);
dest
.
writeString
(
this
.
expiration
!=
null
?
this
.
expiration
.
toString
()
:
null
);
dest
.
writeByte
((
byte
)
(
this
.
third_party_service
?
1
:
0
));
dest
.
writeString
(
this
.
name
);
dest
.
writeString
(
this
.
description
);
...
...
@@ -394,12 +470,23 @@ public class Couponset implements Parcelable, Serializable {
dest
.
writeString
(
this
.
innerText
);
dest
.
writeString
(
this
.
discount_type
);
dest
.
writeDouble
(
this
.
final_price
);
dest
.
writeString
(
this
.
couponsetType
);
dest
.
writeString
(
this
.
extraFields
!=
null
?
this
.
extraFields
.
toString
()
:
null
);
dest
.
writeByte
((
byte
)
(
this
.
isNew
?
1
:
0
));
dest
.
writeByte
((
byte
)
(
this
.
promoted
?
1
:
0
));
dest
.
writeByte
((
byte
)
(
this
.
personalized
?
1
:
0
));
dest
.
writeByte
((
byte
)
(
this
.
locked
?
1
:
0
));
dest
.
writeString
(
this
.
unlockAction
);
dest
.
writeString
(
this
.
unlockMessage
);
dest
.
writeString
(
this
.
eligibilities
!=
null
?
this
.
eligibilities
.
toString
()
:
null
);
dest
.
writeString
(
this
.
startDate
);
dest
.
writeString
(
this
.
endDate
);
dest
.
writeString
(
this
.
hideCondition
!=
null
?
this
.
hideCondition
.
toString
()
:
null
);
dest
.
writeString
(
this
.
showAsBanner
!=
null
?
this
.
showAsBanner
.
toString
()
:
null
);
dest
.
writeString
(
this
.
segment
);
dest
.
writeString
(
this
.
offerCategory
);
dest
.
writeString
(
this
.
tagging
!=
null
?
this
.
tagging
.
toString
()
:
null
);
dest
.
writeString
(
this
.
regions
!=
null
?
this
.
regions
.
toString
()
:
null
);
}
/**
...
...
@@ -410,41 +497,50 @@ public class Couponset implements Parcelable, Serializable {
public
JSONObject
toJSONObject
()
{
JSONObject
jObj
=
new
JSONObject
();
try
{
jObj
.
put
Opt
(
UUID
,
this
.
uuid
);
jObj
.
put
Opt
(
ADMIN_NAME
,
this
.
admin_name
);
jObj
.
put
Opt
(
CREATED
,
this
.
created
);
jObj
.
put
Opt
(
UPDATED
,
this
.
updated
);
jObj
.
put
Opt
(
APP_UUID
,
this
.
app_uuid
);
jObj
.
put
Opt
(
IMG
,
this
.
img
);
jObj
.
put
Opt
(
IMG_PREVIEW
,
this
.
img_preview
);
jObj
.
put
Opt
(
SORTING
,
this
.
sorting
);
jObj
.
put
(
UUID
,
this
.
uuid
!=
null
?
this
.
uuid
:
JSONObject
.
NULL
);
jObj
.
put
(
ADMIN_NAME
,
this
.
admin_name
!=
null
?
this
.
admin_name
:
JSONObject
.
NULL
);
jObj
.
put
(
CREATED
,
this
.
created
!=
null
?
this
.
created
:
JSONObject
.
NULL
);
jObj
.
put
(
UPDATED
,
this
.
updated
!=
null
?
this
.
updated
:
JSONObject
.
NULL
);
jObj
.
put
(
APP_UUID
,
this
.
app_uuid
!=
null
?
this
.
app_uuid
:
JSONObject
.
NULL
);
jObj
.
put
(
IMG
,
this
.
img
!=
null
?
this
.
img
:
JSONObject
.
NULL
);
jObj
.
put
(
IMG_PREVIEW
,
this
.
img_preview
!=
null
?
this
.
img_preview
:
JSONObject
.
NULL
);
jObj
.
put
(
SORTING
,
this
.
sorting
!=
null
?
this
.
sorting
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
ACTIVE
,
this
.
active
);
jObj
.
putOpt
(
VISIBLE
,
this
.
visible
);
jObj
.
putOpt
(
BUYABLE
,
this
.
buyable
);
jObj
.
putOpt
(
USER_GENERATED
,
this
.
user_generated
);
jObj
.
put
Opt
(
LIMITS
,
this
.
limits
);
jObj
.
put
(
LIMITS
,
this
.
limits
!=
null
?
this
.
limits
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
POINTS
,
this
.
points
);
jObj
.
put
Opt
(
POINTS_CAUSE
,
this
.
points_cause
);
jObj
.
put
Opt
(
EXPIRATION
,
this
.
expiration
);
jObj
.
put
(
POINTS_CAUSE
,
this
.
points_cause
!=
null
?
this
.
points_cause
:
JSONObject
.
NULL
);
jObj
.
put
(
EXPIRATION
,
this
.
expiration
!=
null
?
this
.
expiration
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
THIRD_PARTY_SERVICE
,
this
.
third_party_service
);
jObj
.
put
Opt
(
NAME
,
this
.
name
);
jObj
.
put
Opt
(
DESCRIPTION
,
this
.
description
);
jObj
.
put
Opt
(
SHORT_DESCRIPTION
,
this
.
short_description
);
jObj
.
put
Opt
(
DISCOUNT
,
this
.
discount
);
jObj
.
put
Opt
(
CATEGORY
,
this
.
category
);
jObj
.
put
Opt
(
TERMS
,
this
.
terms
);
jObj
.
put
(
NAME
,
this
.
name
!=
null
?
this
.
name
:
JSONObject
.
NULL
);
jObj
.
put
(
DESCRIPTION
,
this
.
description
!=
null
?
this
.
description
:
JSONObject
.
NULL
);
jObj
.
put
(
SHORT_DESCRIPTION
,
this
.
short_description
!=
null
?
this
.
short_description
:
JSONObject
.
NULL
);
jObj
.
put
(
DISCOUNT
,
this
.
discount
!=
null
?
this
.
discount
:
JSONObject
.
NULL
);
jObj
.
put
(
CATEGORY
,
this
.
category
!=
null
?
this
.
category
:
JSONObject
.
NULL
);
jObj
.
put
(
TERMS
,
this
.
terms
!=
null
?
this
.
terms
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
AVAILABILITY
,
this
.
availability
);
jObj
.
put
Opt
(
MERCHANT_UUID
,
this
.
merchantUuid
);
jObj
.
put
Opt
(
INNER_TEXT
,
this
.
innerText
);
jObj
.
put
Opt
(
DISCOUNT_TYPE
,
this
.
discount_type
);
jObj
.
put
(
MERCHANT_UUID
,
this
.
merchantUuid
!=
null
?
this
.
merchantUuid
:
JSONObject
.
NULL
);
jObj
.
put
(
INNER_TEXT
,
this
.
innerText
!=
null
?
this
.
innerText
:
JSONObject
.
NULL
);
jObj
.
put
(
DISCOUNT_TYPE
,
this
.
discount_type
!=
null
?
this
.
discount_type
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
FINAL_PRICE
,
this
.
final_price
);
jObj
.
put
Opt
(
EXTRA_FIELDS
,
this
.
extraFields
);
jObj
.
put
(
EXTRA_FIELDS
,
this
.
extraFields
!=
null
?
this
.
extraFields
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
IS_NEW
,
this
.
isNew
);
jObj
.
putOpt
(
PROMOTED
,
this
.
promoted
);
jObj
.
putOpt
(
PERSONALIZED
,
this
.
personalized
);
jObj
.
putOpt
(
LOCKED
,
this
.
locked
);
jObj
.
putOpt
(
UNLOCK_ACTION
,
this
.
unlockAction
);
jObj
.
putOpt
(
UNLOCK_MESSAGE
,
this
.
unlockMessage
);
jObj
.
put
(
UNLOCK_ACTION
,
this
.
unlockAction
!=
null
?
this
.
unlockAction
:
JSONObject
.
NULL
);
jObj
.
put
(
UNLOCK_MESSAGE
,
this
.
unlockMessage
!=
null
?
this
.
unlockMessage
:
JSONObject
.
NULL
);
jObj
.
put
(
ELIGIBILITIES
,
this
.
eligibilities
!=
null
?
this
.
eligibilities
:
JSONObject
.
NULL
);
jObj
.
put
(
START_DATE
,
this
.
startDate
!=
null
?
this
.
startDate
:
JSONObject
.
NULL
);
jObj
.
put
(
END_DATE
,
this
.
endDate
!=
null
?
this
.
endDate
:
JSONObject
.
NULL
);
jObj
.
put
(
HIDE_CONDITION
,
this
.
hideCondition
!=
null
?
this
.
hideCondition
:
JSONObject
.
NULL
);
jObj
.
put
(
SHOW_AS_BANNER
,
this
.
showAsBanner
!=
null
?
this
.
showAsBanner
:
JSONObject
.
NULL
);
jObj
.
put
(
SEGMENT
,
this
.
segment
!=
null
?
this
.
segment
:
JSONObject
.
NULL
);
jObj
.
put
(
OFFER_CATEGORY
,
this
.
offerCategory
!=
null
?
this
.
offerCategory
:
JSONObject
.
NULL
);
jObj
.
put
(
TAGGING
,
this
.
tagging
!=
null
?
this
.
tagging
:
JSONObject
.
NULL
);
jObj
.
put
(
REGIONS
,
this
.
regions
!=
null
?
this
.
regions
:
JSONObject
.
NULL
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
...
...
@@ -454,6 +550,30 @@ public class Couponset implements Parcelable, Serializable {
}
/**
* Helper to get the expiration value string from the expiration JSONObject
*
* @return The expiration value string, or null
*/
public
String
getExpirationValue
()
{
if
(
expiration
!=
null
)
{
return
expiration
.
optString
(
"value"
,
null
);
}
return
null
;
}
/**
* Helper to get the expiration type from the expiration JSONObject
*
* @return The expiration type string, or null
*/
public
String
getExpirationType
()
{
if
(
expiration
!=
null
)
{
return
expiration
.
optString
(
"type"
,
null
);
}
return
null
;
}
/**
* String representation of the Couponset, as a JSON object
*
* @return A String representation of JSON object
...
...
@@ -465,7 +585,7 @@ public class Couponset implements Parcelable, Serializable {
}
/**
* String representation of the
Address
, as a human readable JSON object
* String representation of the
Couponset
, as a human readable JSON object
*
* @return A human readable String representation of JSON object
*/
...
...
@@ -483,7 +603,6 @@ public class Couponset implements Parcelable, Serializable {
// Getters
// ================================================================================
public
String
getUuid
()
{
return
uuid
;
}
...
...
@@ -492,6 +611,10 @@ public class Couponset implements Parcelable, Serializable {
return
admin_name
;
}
public
String
getAdmin_name
()
{
return
admin_name
;
}
public
String
getCreated
()
{
return
created
;
}
...
...
@@ -512,7 +635,11 @@ public class Couponset implements Parcelable, Serializable {
return
img_preview
;
}
public
int
getSorting
()
{
public
String
getImg_preview
()
{
return
img_preview
;
}
public
Integer
getSorting
()
{
return
sorting
;
}
...
...
@@ -544,7 +671,7 @@ public class Couponset implements Parcelable, Serializable {
return
points_cause
;
}
public
String
getExpiration
()
{
public
JSONObject
getExpiration
()
{
return
expiration
;
}
...
...
@@ -564,6 +691,10 @@ public class Couponset implements Parcelable, Serializable {
return
short_description
;
}
public
String
getShort_description
()
{
return
short_description
;
}
public
String
getDiscount
()
{
return
discount
;
}
...
...
@@ -596,6 +727,82 @@ public class Couponset implements Parcelable, Serializable {
return
final_price
;
}
public
String
getCouponsetType
()
{
return
couponsetType
;
}
public
JSONObject
getExtraFields
()
{
return
extraFields
;
}
public
boolean
isNew
()
{
return
isNew
;
}
public
boolean
isPromoted
()
{
return
promoted
;
}
public
boolean
isPersonalized
()
{
return
personalized
;
}
public
boolean
isLocked
()
{
return
locked
;
}
public
String
getUnlockAction
()
{
return
unlockAction
;
}
public
String
getUnlockMessage
()
{
return
unlockMessage
;
}
public
JSONObject
getEligibilities
()
{
return
eligibilities
;
}
public
String
getStartDate
()
{
return
startDate
;
}
public
String
getEndDate
()
{
return
endDate
;
}
public
JSONObject
getHideCondition
()
{
return
hideCondition
;
}
public
JSONObject
getShowAsBanner
()
{
return
showAsBanner
;
}
public
String
getSegment
()
{
return
segment
;
}
public
String
getOfferCategory
()
{
return
offerCategory
;
}
public
JSONObject
getTagging
()
{
return
tagging
;
}
public
JSONArray
getRegions
()
{
return
regions
;
}
public
Merchant
getMerchant
()
{
return
merchant
;
}
// ================================================================================
// Setters
// ================================================================================
public
void
setUuid
(
String
uuid
)
{
this
.
uuid
=
uuid
;
}
...
...
@@ -624,7 +831,7 @@ public class Couponset implements Parcelable, Serializable {
this
.
img_preview
=
img_preview
;
}
public
void
setSorting
(
int
sorting
)
{
public
void
setSorting
(
Integer
sorting
)
{
this
.
sorting
=
sorting
;
}
...
...
@@ -656,7 +863,7 @@ public class Couponset implements Parcelable, Serializable {
this
.
points_cause
=
points_cause
;
}
public
void
setExpiration
(
String
expiration
)
{
public
void
setExpiration
(
JSONObject
expiration
)
{
this
.
expiration
=
expiration
;
}
...
...
@@ -708,81 +915,76 @@ public class Couponset implements Parcelable, Serializable {
this
.
final_price
=
final_price
;
}
public
String
getCouponsetType
()
{
return
couponsetType
;
}
public
void
setCouponsetType
(
String
couponsetType
)
{
this
.
couponsetType
=
couponsetType
;
}
public
String
getAdmin_name
(
)
{
return
admin_name
;
public
void
setExtraFields
(
JSONObject
extraFields
)
{
this
.
extraFields
=
extraFields
;
}
public
JSONObject
getExtraFields
(
)
{
return
extraFields
;
public
void
setNew
(
boolean
aNew
)
{
isNew
=
aNew
;
}
public
void
set
ExtraFields
(
JSONObject
extraFields
)
{
this
.
extraFields
=
extraFields
;
public
void
set
Promoted
(
boolean
promoted
)
{
this
.
promoted
=
promoted
;
}
public
String
getShort_description
(
)
{
return
short_description
;
public
void
setPersonalized
(
boolean
personalized
)
{
this
.
personalized
=
personalized
;
}
public
String
getImg_preview
(
)
{
return
img_preview
;
public
void
setLocked
(
boolean
locked
)
{
this
.
locked
=
locked
;
}
public
boolean
isNew
()
{
return
isNew
;
public
void
setUnlockAction
(
String
unlockAction
)
{
this
.
unlockAction
=
unlockAction
;
}
public
void
set
New
(
boolean
aNew
)
{
isNew
=
aNew
;
public
void
set
UnlockMessage
(
String
unlockMessage
)
{
this
.
unlockMessage
=
unlockMessage
;
}
public
boolean
isPromoted
(
)
{
return
promoted
;
public
void
setEligibilities
(
JSONObject
eligibilities
)
{
this
.
eligibilities
=
eligibilities
;
}
public
void
set
Promoted
(
boolean
promoted
)
{
this
.
promoted
=
promoted
;
public
void
set
StartDate
(
String
startDate
)
{
this
.
startDate
=
startDate
;
}
public
boolean
isPersonalized
(
)
{
return
personalized
;
public
void
setEndDate
(
String
endDate
)
{
this
.
endDate
=
endDate
;
}
public
void
set
Personalized
(
boolean
personalized
)
{
this
.
personalized
=
personalized
;
public
void
set
HideCondition
(
JSONObject
hideCondition
)
{
this
.
hideCondition
=
hideCondition
;
}
public
boolean
isLocked
(
)
{
return
locked
;
public
void
setShowAsBanner
(
JSONObject
showAsBanner
)
{
this
.
showAsBanner
=
showAsBanner
;
}
public
void
set
Locked
(
boolean
locked
)
{
this
.
locked
=
locked
;
public
void
set
Segment
(
String
segment
)
{
this
.
segment
=
segment
;
}
public
String
getUnlockAction
(
)
{
return
unlockAction
;
public
void
setOfferCategory
(
String
offerCategory
)
{
this
.
offerCategory
=
offerCategory
;
}
public
void
set
UnlockAction
(
String
unlockAction
)
{
this
.
unlockAction
=
unlockAction
;
public
void
set
Tagging
(
JSONObject
tagging
)
{
this
.
tagging
=
tagging
;
}
public
String
getUnlockMessage
(
)
{
return
unlockMessage
;
public
void
setRegions
(
JSONArray
regions
)
{
this
.
regions
=
regions
;
}
public
void
set
UnlockMessage
(
String
unlockMessage
)
{
this
.
unlockMessage
=
unlockMessage
;
public
void
set
Merchant
(
Merchant
merchant
)
{
this
.
merchant
=
merchant
;
}
@Override
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Merchant.java
View file @
2b9f74f
...
...
@@ -46,7 +46,7 @@ public class Merchant implements Parcelable, Serializable {
private
static
final
long
serialVersionUID
=
-
4754964462459705285L
;
/* Constants used to export the
campaign
in JSON formal and vice versa */
/* Constants used to export the
Merchant
in JSON formal and vice versa */
private
static
final
String
ADDRESS
=
"address"
;
private
static
final
String
ID
=
"id"
;
...
...
@@ -73,122 +73,157 @@ public class Merchant implements Parcelable, Serializable {
private
static
final
String
CATEGORY_UUID
=
"category_uuid"
;
private
static
final
String
CREATED
=
"created"
;
private
static
final
String
PARENT
=
"parent"
;
private
static
final
String
IMG
=
"img"
;
// JSONArray
private
static
final
String
IMG
=
"img"
;
private
static
final
String
IMG_PREVIEW
=
"img_preview"
;
private
static
final
String
ADMIN_NAME
=
"admin_name"
;
private
static
final
String
SORTING
=
"sorting"
;
// int
private
static
final
String
SORTING
=
"sorting"
;
private
static
final
String
BODY
=
"body"
;
private
static
final
String
OWNER_NAME
=
"owner_name"
;
private
static
final
String
PREVIEW
=
"preview"
;
private
static
final
String
MERCHANT_METADATA
=
"merchant_metadata"
;
// JSONObject
private
static
final
String
PROMOTED
=
"promoted"
;
// boolean
private
static
final
String
DISTANCE
=
"distance"
;
// int
private
static
final
String
DEFAULT_SHOWN
=
"default_shown"
;
// boolean
private
static
final
String
HIDDEN
=
"hidden"
;
// boolean
private
static
final
String
WORKING_HOURS
=
"working_hours"
;
// JSONObject
private
static
final
String
TAGS
=
"tags"
;
// JSONArray
private
static
final
String
PRODUCT
=
"product"
;
// JSONObject
/* Member variables of the Campaign object */
private
String
address
=
""
;
private
String
id
=
""
;
private
String
store_id
=
""
;
private
String
name
=
""
;
private
String
logo
=
""
;
private
String
website
=
""
;
private
String
email
=
""
;
private
String
telephone
=
""
;
private
String
category
=
""
;
private
String
description
=
""
;
private
String
short_description
=
""
;
private
String
region
=
""
;
private
double
latitude
=
0.0
;
private
double
longitude
=
0.0
;
private
String
image
=
""
;
private
JSONObject
extra_fields
=
new
JSONObject
();
private
static
final
String
MERCHANT_METADATA
=
"merchant_metadata"
;
private
static
final
String
PROMOTED
=
"promoted"
;
private
static
final
String
DISTANCE
=
"distance"
;
private
static
final
String
DEFAULT_SHOWN
=
"default_shown"
;
private
static
final
String
HIDDEN
=
"hidden"
;
private
static
final
String
WORKING_HOURS
=
"working_hours"
;
private
static
final
String
TAGS
=
"tags"
;
private
static
final
String
PRODUCT
=
"product"
;
private
static
final
String
TELEPHONES_RAW
=
"telephones_raw"
;
private
static
final
String
YEAR_ESTABLISHED
=
"year_established"
;
private
static
final
String
CURRENCY
=
"currency"
;
private
static
final
String
BANK
=
"bank"
;
private
static
final
String
MIN_ORDER_PRICE
=
"min_order_price"
;
private
static
final
String
MIN_ORDER_PRICE_TAKEAWAY
=
"min_order_price_takeaway"
;
private
static
final
String
MIN_PRICE
=
"min_price"
;
private
static
final
String
MAX_PRICE
=
"max_price"
;
private
static
final
String
URL_NAME
=
"url_name"
;
/* Member variables of the Merchant object */
private
String
address
;
private
String
id
;
private
String
store_id
;
private
String
name
;
private
String
logo
;
private
String
website
;
private
String
email
;
private
String
telephone
;
private
String
category
;
private
String
description
;
private
String
short_description
;
private
String
region
;
private
Double
latitude
;
private
Double
longitude
;
private
String
image
;
private
JSONObject
extra_fields
;
private
boolean
active
;
private
String
city
=
""
;
private
String
country
=
""
;
private
String
postal_code
=
""
;
private
String
vat
=
""
;
private
String
uuid
=
""
;
private
String
category_uuid
=
""
;
private
String
created
=
""
;
private
String
parent
=
""
;
private
JSONArray
img
=
new
JSONArray
();
private
String
img_preview
=
""
;
private
String
admin_name
=
""
;
private
int
sorting
=
0
;
private
String
body
=
""
;
private
String
owner_name
=
""
;
private
String
preview
=
""
;
private
JSONObject
merchant_metadata
=
new
JSONObject
();
private
boolean
promoted
=
false
;
private
int
distance
=
0
;
private
boolean
default_shown
=
false
;
private
boolean
hidden
=
false
;
private
JSONObject
working_hours
=
new
JSONObject
();
private
JSONArray
tags
=
new
JSONArray
();
private
JSONObject
product
=
new
JSONObject
();
private
String
city
;
private
String
country
;
private
String
postal_code
;
private
String
vat
;
private
String
uuid
;
private
String
category_uuid
;
private
String
created
;
private
String
parent
;
private
JSONArray
img
;
private
String
img_preview
;
private
String
admin_name
;
private
Integer
sorting
;
private
String
body
;
private
String
owner_name
;
private
String
preview
;
private
JSONObject
merchant_metadata
;
private
boolean
promoted
;
private
Integer
distance
;
private
boolean
default_shown
;
private
boolean
hidden
;
private
String
working_hours
;
private
JSONArray
tags
;
private
JSONObject
product
;
private
String
telephonesRaw
;
private
String
yearEstablished
;
private
String
currency
;
private
String
bank
;
private
String
minOrderPrice
;
private
String
minOrderPriceTakeaway
;
private
String
minPrice
;
private
String
maxPrice
;
private
String
urlName
;
/**
* Helper method to get a nullable String from a JSONObject.
* Returns null if the JSON value is null, otherwise returns the String value.
*/
private
static
String
optNullableString
(
JSONObject
json
,
String
key
)
{
return
json
.
isNull
(
key
)
?
null
:
json
.
optString
(
key
);
}
public
Merchant
()
{
this
.
address
=
""
;
this
.
id
=
""
;
this
.
store_id
=
""
;
this
.
name
=
""
;
this
.
logo
=
""
;
this
.
website
=
""
;
this
.
email
=
""
;
this
.
telephone
=
""
;
this
.
category
=
""
;
this
.
description
=
""
;
this
.
short_description
=
""
;
this
.
region
=
""
;
this
.
latitude
=
0.0
;
this
.
longitude
=
0.0
;
this
.
image
=
""
;
this
.
extra_fields
=
n
ew
JSONObject
()
;
this
.
address
=
null
;
this
.
id
=
null
;
this
.
store_id
=
null
;
this
.
name
=
null
;
this
.
logo
=
null
;
this
.
website
=
null
;
this
.
email
=
null
;
this
.
telephone
=
null
;
this
.
category
=
null
;
this
.
description
=
null
;
this
.
short_description
=
null
;
this
.
region
=
null
;
this
.
latitude
=
null
;
this
.
longitude
=
null
;
this
.
image
=
null
;
this
.
extra_fields
=
n
ull
;
this
.
active
=
true
;
this
.
city
=
""
;
this
.
country
=
""
;
this
.
postal_code
=
""
;
this
.
vat
=
""
;
this
.
uuid
=
""
;
this
.
category_uuid
=
""
;
this
.
created
=
""
;
this
.
parent
=
""
;
this
.
img
=
n
ew
JSONArray
()
;
this
.
img_preview
=
""
;
this
.
admin_name
=
""
;
this
.
sorting
=
0
;
this
.
body
=
""
;
this
.
owner_name
=
""
;
this
.
preview
=
""
;
this
.
merchant_metadata
=
n
ew
JSONObject
()
;
this
.
city
=
null
;
this
.
country
=
null
;
this
.
postal_code
=
null
;
this
.
vat
=
null
;
this
.
uuid
=
null
;
this
.
category_uuid
=
null
;
this
.
created
=
null
;
this
.
parent
=
null
;
this
.
img
=
n
ull
;
this
.
img_preview
=
null
;
this
.
admin_name
=
null
;
this
.
sorting
=
null
;
this
.
body
=
null
;
this
.
owner_name
=
null
;
this
.
preview
=
null
;
this
.
merchant_metadata
=
n
ull
;
this
.
promoted
=
false
;
this
.
distance
=
0
;
this
.
distance
=
null
;
this
.
default_shown
=
true
;
this
.
hidden
=
false
;
this
.
working_hours
=
new
JSONObject
();
this
.
tags
=
new
JSONArray
();
this
.
product
=
new
JSONObject
();
this
.
working_hours
=
null
;
this
.
tags
=
null
;
this
.
product
=
null
;
this
.
telephonesRaw
=
null
;
this
.
yearEstablished
=
null
;
this
.
currency
=
null
;
this
.
bank
=
null
;
this
.
minOrderPrice
=
null
;
this
.
minOrderPriceTakeaway
=
null
;
this
.
minPrice
=
null
;
this
.
maxPrice
=
null
;
this
.
urlName
=
null
;
}
public
Merchant
(
boolean
isUniversal
)
{
this
.
address
=
""
;
this
.
city
=
""
;
this
.
body
=
""
;
this
.
logo
=
""
;
this
.
country
=
""
;
this
.
name
=
""
;
this
.
postal_code
=
""
;
this
.
region
=
""
;
this
.
telephone
=
""
;
this
.
merchant_metadata
=
n
ew
JSONObject
()
;
this
.
admin_name
=
""
;
this
.
img_preview
=
""
;
this
.
website
=
""
;
this
.
address
=
null
;
this
.
city
=
null
;
this
.
body
=
null
;
this
.
logo
=
null
;
this
.
country
=
null
;
this
.
name
=
null
;
this
.
postal_code
=
null
;
this
.
region
=
null
;
this
.
telephone
=
null
;
this
.
merchant_metadata
=
n
ull
;
this
.
admin_name
=
null
;
this
.
img_preview
=
null
;
this
.
website
=
null
;
}
/**
...
...
@@ -209,96 +244,73 @@ public class Merchant implements Parcelable, Serializable {
*/
public
Merchant
(
JSONObject
json
)
{
if
(
json
!=
null
)
{
this
.
address
=
json
.
isNull
(
ADDRESS
)
?
""
:
json
.
optString
(
ADDRESS
);
this
.
id
=
json
.
optString
(
ID
);
this
.
store_id
=
json
.
optString
(
STORE_ID
);
this
.
name
=
json
.
isNull
(
NAME
)
?
""
:
json
.
optString
(
NAME
);
this
.
logo
=
json
.
optString
(
LOGO
);
this
.
website
=
json
.
optString
(
WEBSITE
);
this
.
email
=
json
.
optString
(
EMAIL
);
this
.
telephone
=
json
.
isNull
(
TELEPHONE
)
?
""
:
json
.
optString
(
TELEPHONE
);
this
.
category
=
json
.
optString
(
CATEGORY
);
this
.
description
=
json
.
optString
(
DESCRIPTION
);
this
.
short_description
=
json
.
optString
(
SHORT_DESCRIPTION
);
this
.
region
=
json
.
optString
(
REGION
);
this
.
latitude
=
json
.
isNull
(
LAT
)
?
0.0
:
json
.
optDouble
(
LAT
);
this
.
longitude
=
json
.
isNull
(
LON
)
?
0.0
:
json
.
optDouble
(
LON
);
this
.
image
=
json
.
optString
(
IMAGE
);
this
.
address
=
optNullableString
(
json
,
ADDRESS
);
this
.
id
=
optNullableString
(
json
,
ID
);
this
.
store_id
=
optNullableString
(
json
,
STORE_ID
);
this
.
name
=
optNullableString
(
json
,
NAME
);
this
.
logo
=
optNullableString
(
json
,
LOGO
);
this
.
website
=
optNullableString
(
json
,
WEBSITE
);
this
.
email
=
optNullableString
(
json
,
EMAIL
);
this
.
telephone
=
optNullableString
(
json
,
TELEPHONE
);
this
.
category
=
optNullableString
(
json
,
CATEGORY
);
this
.
description
=
optNullableString
(
json
,
DESCRIPTION
);
this
.
short_description
=
optNullableString
(
json
,
SHORT_DESCRIPTION
);
this
.
region
=
optNullableString
(
json
,
REGION
);
this
.
latitude
=
json
.
isNull
(
LAT
)
?
null
:
json
.
optDouble
(
LAT
);
this
.
longitude
=
json
.
isNull
(
LON
)
?
null
:
json
.
optDouble
(
LON
);
this
.
image
=
optNullableString
(
json
,
IMAGE
);
this
.
extra_fields
=
json
.
optJSONObject
(
EXTRA_FIELDS
);
this
.
active
=
json
.
optBoolean
(
ACTIVE
);
this
.
city
=
json
.
optString
(
CITY
);
this
.
country
=
json
.
optString
(
COUNTRY
);
this
.
postal_code
=
json
.
optString
(
POSTAL_CODE
);
this
.
vat
=
json
.
optString
(
VAT
);
this
.
uuid
=
json
.
optString
(
UUID
);
this
.
category_uuid
=
json
.
optString
(
CATEGORY_UUID
);
this
.
created
=
json
.
optString
(
CREATED
);
this
.
parent
=
json
.
optString
(
PARENT
);
this
.
city
=
optNullableString
(
json
,
CITY
);
this
.
country
=
optNullableString
(
json
,
COUNTRY
);
this
.
postal_code
=
optNullableString
(
json
,
POSTAL_CODE
);
this
.
vat
=
optNullableString
(
json
,
VAT
);
this
.
uuid
=
optNullableString
(
json
,
UUID
);
this
.
category_uuid
=
optNullableString
(
json
,
CATEGORY_UUID
);
this
.
created
=
optNullableString
(
json
,
CREATED
);
this
.
parent
=
optNullableString
(
json
,
PARENT
);
this
.
img
=
json
.
optJSONArray
(
IMG
);
this
.
img_preview
=
json
.
optString
(
IMG_PREVIEW
);
this
.
admin_name
=
json
.
optString
(
ADMIN_NAME
);
this
.
sorting
=
json
.
optInt
(
SORTING
);
this
.
body
=
json
.
optString
(
BODY
);
this
.
owner_name
=
json
.
optString
(
OWNER_NAME
);
this
.
preview
=
json
.
optString
(
PREVIEW
);
this
.
img_preview
=
optNullableString
(
json
,
IMG_PREVIEW
);
this
.
admin_name
=
optNullableString
(
json
,
ADMIN_NAME
);
this
.
sorting
=
json
.
isNull
(
SORTING
)
?
null
:
json
.
optInt
(
SORTING
);
this
.
body
=
optNullableString
(
json
,
BODY
);
this
.
owner_name
=
optNullableString
(
json
,
OWNER_NAME
);
this
.
preview
=
optNullableString
(
json
,
PREVIEW
);
this
.
merchant_metadata
=
json
.
optJSONObject
(
MERCHANT_METADATA
);
this
.
promoted
=
json
.
optBoolean
(
PROMOTED
);
this
.
distance
=
json
.
optInt
(
DISTANCE
);
this
.
distance
=
json
.
isNull
(
DISTANCE
)
?
null
:
json
.
optInt
(
DISTANCE
);
this
.
default_shown
=
json
.
optBoolean
(
DEFAULT_SHOWN
);
this
.
hidden
=
json
.
optBoolean
(
HIDDEN
);
this
.
working_hours
=
json
.
optJSONObject
(
WORKING_HOURS
);
this
.
working_hours
=
optNullableString
(
json
,
WORKING_HOURS
);
this
.
tags
=
json
.
optJSONArray
(
TAGS
);
this
.
product
=
json
.
optJSONObject
(
PRODUCT
);
this
.
telephonesRaw
=
optNullableString
(
json
,
TELEPHONES_RAW
);
this
.
yearEstablished
=
optNullableString
(
json
,
YEAR_ESTABLISHED
);
this
.
currency
=
optNullableString
(
json
,
CURRENCY
);
this
.
bank
=
optNullableString
(
json
,
BANK
);
this
.
minOrderPrice
=
optNullableString
(
json
,
MIN_ORDER_PRICE
);
this
.
minOrderPriceTakeaway
=
optNullableString
(
json
,
MIN_ORDER_PRICE_TAKEAWAY
);
this
.
minPrice
=
optNullableString
(
json
,
MIN_PRICE
);
this
.
maxPrice
=
optNullableString
(
json
,
MAX_PRICE
);
this
.
urlName
=
optNullableString
(
json
,
URL_NAME
);
}
}
public
Merchant
(
JSONObject
json
,
boolean
isUniversal
)
{
if
(
json
!=
null
)
{
this
.
address
=
json
.
isNull
(
ADDRESS
)
?
""
:
json
.
optString
(
ADDRESS
);
this
.
body
=
json
.
optString
(
BODY
);
this
.
city
=
json
.
optString
(
CITY
);
this
.
logo
=
json
.
optString
(
LOGO
);
this
.
country
=
json
.
optString
(
COUNTRY
);
this
.
name
=
json
.
isNull
(
NAME
)
?
""
:
json
.
optString
(
NAME
);
this
.
postal_code
=
json
.
optString
(
POSTAL_CODE
);
this
.
region
=
json
.
optString
(
REGION
);
this
.
telephone
=
json
.
isNull
(
TELEPHONE
)
?
""
:
json
.
optString
(
TELEPHONE
);
this
.
address
=
optNullableString
(
json
,
ADDRESS
);
this
.
body
=
optNullableString
(
json
,
BODY
);
this
.
city
=
optNullableString
(
json
,
CITY
);
this
.
logo
=
optNullableString
(
json
,
LOGO
);
this
.
country
=
optNullableString
(
json
,
COUNTRY
);
this
.
name
=
optNullableString
(
json
,
NAME
);
this
.
postal_code
=
optNullableString
(
json
,
POSTAL_CODE
);
this
.
region
=
optNullableString
(
json
,
REGION
);
this
.
telephone
=
optNullableString
(
json
,
TELEPHONE
);
this
.
merchant_metadata
=
json
.
optJSONObject
(
MERCHANT_METADATA
);
this
.
admin_name
=
json
.
optString
(
ADMIN_NAME
);
this
.
img_preview
=
json
.
optString
(
IMG_PREVIEW
);
this
.
website
=
json
.
optString
(
WEBSITE
);
// this.id = json.optString(ID);
// this.store_id = json.optString(STORE_ID);
// this.website = json.optString(WEBSITE);
// this.email = json.optString(EMAIL);
// this.category = json.optString(CATEGORY);
// this.description = json.optString(DESCRIPTION);
// this.short_description = json.optString(SHORT_DESCRIPTION);
// this.latitude = json.isNull(LAT) ? 0.0 : json.optDouble(LAT);
// this.longitude = json.isNull(LON) ? 0.0 : json.optDouble(LON);
// this.image = json.optString(IMAGE);
// this.extra_fields = json.optJSONObject(EXTRA_FIELDS);
// this.active = json.optBoolean(ACTIVE);
// this.vat = json.optString(VAT);
// this.uuid = json.optString(UUID);
// this.category_uuid = json.optString(CATEGORY_UUID);
// this.created = json.optString(CREATED);
// this.parent = json.optString(PARENT);
// this.img = json.optJSONArray(IMG);
// this.img_preview = json.optString(IMG_PREVIEW);
// this.admin_name = json.optString(ADMIN_NAME);
// this.sorting = json.optInt(SORTING);
// this.owner_name = json.optString(OWNER_NAME);
// this.preview = json.optString(PREVIEW);
// this.promoted = json.optBoolean(PROMOTED);
// this.distance = json.optInt(DISTANCE);
// this.default_shown = json.optBoolean(DEFAULT_SHOWN);
// this.hidden = json.optBoolean(HIDDEN);
// this.working_hours = json.optJSONObject(WORKING_HOURS);
// this.tags = json.optJSONArray(TAGS);
// this.product = json.optJSONObject(PRODUCT);
// coordinates = new LatLng(this.latitude, this.longitude);
this
.
admin_name
=
optNullableString
(
json
,
ADMIN_NAME
);
this
.
img_preview
=
optNullableString
(
json
,
IMG_PREVIEW
);
this
.
website
=
optNullableString
(
json
,
WEBSITE
);
}
}
...
...
@@ -315,9 +327,17 @@ public class Merchant implements Parcelable, Serializable {
this
.
description
=
source
.
readString
();
this
.
short_description
=
source
.
readString
();
this
.
region
=
source
.
readString
();
this
.
latitude
=
source
.
readDouble
();
this
.
longitude
=
source
.
readDouble
();
double
latVal
=
source
.
readDouble
();
this
.
latitude
=
latVal
==
Double
.
MIN_VALUE
?
null
:
latVal
;
double
lonVal
=
source
.
readDouble
();
this
.
longitude
=
lonVal
==
Double
.
MIN_VALUE
?
null
:
lonVal
;
this
.
image
=
source
.
readString
();
try
{
String
extraFieldsStr
=
source
.
readString
();
this
.
extra_fields
=
extraFieldsStr
!=
null
?
new
JSONObject
(
extraFieldsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
extra_fields
=
null
;
}
this
.
active
=
source
.
readByte
()
!=
0
;
this
.
city
=
source
.
readString
();
this
.
country
=
source
.
readString
();
...
...
@@ -327,16 +347,52 @@ public class Merchant implements Parcelable, Serializable {
this
.
category_uuid
=
source
.
readString
();
this
.
created
=
source
.
readString
();
this
.
parent
=
source
.
readString
();
try
{
String
imgStr
=
source
.
readString
();
this
.
img
=
imgStr
!=
null
?
new
JSONArray
(
imgStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
img
=
null
;
}
this
.
img_preview
=
source
.
readString
();
this
.
admin_name
=
source
.
readString
();
this
.
sorting
=
source
.
readInt
();
int
sortingVal
=
source
.
readInt
();
this
.
sorting
=
sortingVal
==
Integer
.
MIN_VALUE
?
null
:
sortingVal
;
this
.
body
=
source
.
readString
();
this
.
owner_name
=
source
.
readString
();
this
.
preview
=
source
.
readString
();
try
{
String
metadataStr
=
source
.
readString
();
this
.
merchant_metadata
=
metadataStr
!=
null
?
new
JSONObject
(
metadataStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
merchant_metadata
=
null
;
}
this
.
promoted
=
source
.
readByte
()
!=
0
;
this
.
distance
=
source
.
readInt
();
int
distanceVal
=
source
.
readInt
();
this
.
distance
=
distanceVal
==
Integer
.
MIN_VALUE
?
null
:
distanceVal
;
this
.
default_shown
=
source
.
readByte
()
!=
0
;
this
.
hidden
=
source
.
readByte
()
!=
0
;
this
.
working_hours
=
source
.
readString
();
try
{
String
tagsStr
=
source
.
readString
();
this
.
tags
=
tagsStr
!=
null
?
new
JSONArray
(
tagsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
tags
=
null
;
}
try
{
String
productStr
=
source
.
readString
();
this
.
product
=
productStr
!=
null
?
new
JSONObject
(
productStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
product
=
null
;
}
this
.
telephonesRaw
=
source
.
readString
();
this
.
yearEstablished
=
source
.
readString
();
this
.
currency
=
source
.
readString
();
this
.
bank
=
source
.
readString
();
this
.
minOrderPrice
=
source
.
readString
();
this
.
minOrderPriceTakeaway
=
source
.
readString
();
this
.
minPrice
=
source
.
readString
();
this
.
maxPrice
=
source
.
readString
();
this
.
urlName
=
source
.
readString
();
}
@Override
...
...
@@ -353,9 +409,10 @@ public class Merchant implements Parcelable, Serializable {
dest
.
writeString
(
this
.
description
);
dest
.
writeString
(
this
.
short_description
);
dest
.
writeString
(
this
.
region
);
dest
.
writeDouble
(
this
.
latitude
);
dest
.
writeDouble
(
this
.
longitude
);
dest
.
writeDouble
(
this
.
latitude
!=
null
?
this
.
latitude
:
Double
.
MIN_VALUE
);
dest
.
writeDouble
(
this
.
longitude
!=
null
?
this
.
longitude
:
Double
.
MIN_VALUE
);
dest
.
writeString
(
this
.
image
);
dest
.
writeString
(
this
.
extra_fields
!=
null
?
this
.
extra_fields
.
toString
()
:
null
);
dest
.
writeByte
((
byte
)
(
this
.
active
?
1
:
0
));
dest
.
writeString
(
this
.
city
);
dest
.
writeString
(
this
.
country
);
...
...
@@ -365,16 +422,30 @@ public class Merchant implements Parcelable, Serializable {
dest
.
writeString
(
this
.
category_uuid
);
dest
.
writeString
(
this
.
created
);
dest
.
writeString
(
this
.
parent
);
dest
.
writeString
(
this
.
img
!=
null
?
this
.
img
.
toString
()
:
null
);
dest
.
writeString
(
this
.
img_preview
);
dest
.
writeString
(
this
.
admin_name
);
dest
.
writeInt
(
this
.
sorting
);
dest
.
writeInt
(
this
.
sorting
!=
null
?
this
.
sorting
:
Integer
.
MIN_VALUE
);
dest
.
writeString
(
this
.
body
);
dest
.
writeString
(
this
.
owner_name
);
dest
.
writeString
(
this
.
preview
);
dest
.
writeString
(
this
.
merchant_metadata
!=
null
?
this
.
merchant_metadata
.
toString
()
:
null
);
dest
.
writeByte
((
byte
)
(
this
.
promoted
?
1
:
0
));
dest
.
writeInt
(
this
.
distance
);
dest
.
writeInt
(
this
.
distance
!=
null
?
this
.
distance
:
Integer
.
MIN_VALUE
);
dest
.
writeByte
((
byte
)
(
this
.
default_shown
?
1
:
0
));
dest
.
writeByte
((
byte
)
(
this
.
hidden
?
1
:
0
));
dest
.
writeString
(
this
.
working_hours
);
dest
.
writeString
(
this
.
tags
!=
null
?
this
.
tags
.
toString
()
:
null
);
dest
.
writeString
(
this
.
product
!=
null
?
this
.
product
.
toString
()
:
null
);
dest
.
writeString
(
this
.
telephonesRaw
);
dest
.
writeString
(
this
.
yearEstablished
);
dest
.
writeString
(
this
.
currency
);
dest
.
writeString
(
this
.
bank
);
dest
.
writeString
(
this
.
minOrderPrice
);
dest
.
writeString
(
this
.
minOrderPriceTakeaway
);
dest
.
writeString
(
this
.
minPrice
);
dest
.
writeString
(
this
.
maxPrice
);
dest
.
writeString
(
this
.
urlName
);
}
/**
...
...
@@ -385,46 +456,55 @@ public class Merchant implements Parcelable, Serializable {
public
JSONObject
toJSONObject
()
{
JSONObject
jObj
=
new
JSONObject
();
try
{
jObj
.
put
Opt
(
ADDRESS
,
this
.
address
);
jObj
.
put
Opt
(
ID
,
this
.
id
);
jObj
.
put
Opt
(
STORE_ID
,
this
.
store_id
);
jObj
.
put
Opt
(
NAME
,
this
.
name
);
jObj
.
put
Opt
(
LOGO
,
this
.
logo
);
jObj
.
put
Opt
(
WEBSITE
,
this
.
website
);
jObj
.
put
Opt
(
EMAIL
,
this
.
email
);
jObj
.
put
Opt
(
TELEPHONE
,
this
.
telephone
);
jObj
.
put
Opt
(
CATEGORY
,
this
.
category
);
jObj
.
put
Opt
(
DESCRIPTION
,
this
.
description
);
jObj
.
put
Opt
(
SHORT_DESCRIPTION
,
this
.
short_description
);
jObj
.
put
Opt
(
REGION
,
this
.
region
);
jObj
.
put
Opt
(
LAT
,
this
.
latitude
);
jObj
.
put
Opt
(
LON
,
this
.
longitude
);
jObj
.
put
Opt
(
IMAGE
,
this
.
image
);
jObj
.
put
Opt
(
EXTRA_FIELDS
,
this
.
extra_fields
);
jObj
.
put
(
ADDRESS
,
this
.
address
!=
null
?
this
.
address
:
JSONObject
.
NULL
);
jObj
.
put
(
ID
,
this
.
id
!=
null
?
this
.
id
:
JSONObject
.
NULL
);
jObj
.
put
(
STORE_ID
,
this
.
store_id
!=
null
?
this
.
store_id
:
JSONObject
.
NULL
);
jObj
.
put
(
NAME
,
this
.
name
!=
null
?
this
.
name
:
JSONObject
.
NULL
);
jObj
.
put
(
LOGO
,
this
.
logo
!=
null
?
this
.
logo
:
JSONObject
.
NULL
);
jObj
.
put
(
WEBSITE
,
this
.
website
!=
null
?
this
.
website
:
JSONObject
.
NULL
);
jObj
.
put
(
EMAIL
,
this
.
email
!=
null
?
this
.
email
:
JSONObject
.
NULL
);
jObj
.
put
(
TELEPHONE
,
this
.
telephone
!=
null
?
this
.
telephone
:
JSONObject
.
NULL
);
jObj
.
put
(
CATEGORY
,
this
.
category
!=
null
?
this
.
category
:
JSONObject
.
NULL
);
jObj
.
put
(
DESCRIPTION
,
this
.
description
!=
null
?
this
.
description
:
JSONObject
.
NULL
);
jObj
.
put
(
SHORT_DESCRIPTION
,
this
.
short_description
!=
null
?
this
.
short_description
:
JSONObject
.
NULL
);
jObj
.
put
(
REGION
,
this
.
region
!=
null
?
this
.
region
:
JSONObject
.
NULL
);
jObj
.
put
(
LAT
,
this
.
latitude
!=
null
?
this
.
latitude
:
JSONObject
.
NULL
);
jObj
.
put
(
LON
,
this
.
longitude
!=
null
?
this
.
longitude
:
JSONObject
.
NULL
);
jObj
.
put
(
IMAGE
,
this
.
image
!=
null
?
this
.
image
:
JSONObject
.
NULL
);
jObj
.
put
(
EXTRA_FIELDS
,
this
.
extra_fields
!=
null
?
this
.
extra_fields
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
ACTIVE
,
this
.
active
);
jObj
.
put
Opt
(
CITY
,
this
.
city
);
jObj
.
put
Opt
(
COUNTRY
,
this
.
country
);
jObj
.
put
Opt
(
POSTAL_CODE
,
this
.
postal_code
);
jObj
.
put
Opt
(
VAT
,
this
.
vat
);
jObj
.
put
Opt
(
UUID
,
this
.
uuid
);
jObj
.
put
Opt
(
CATEGORY_UUID
,
this
.
category_uuid
);
jObj
.
put
Opt
(
CREATED
,
this
.
created
);
jObj
.
put
Opt
(
PARENT
,
this
.
parent
);
jObj
.
put
Opt
(
IMG
,
this
.
img
);
jObj
.
put
Opt
(
IMG_PREVIEW
,
this
.
img_preview
);
jObj
.
put
Opt
(
ADMIN_NAME
,
this
.
admin_name
);
jObj
.
put
Opt
(
SORTING
,
this
.
sorting
);
jObj
.
put
Opt
(
BODY
,
this
.
body
);
jObj
.
put
Opt
(
OWNER_NAME
,
this
.
owner_name
);
jObj
.
put
Opt
(
PREVIEW
,
this
.
preview
);
jObj
.
put
Opt
(
MERCHANT_METADATA
,
this
.
merchant_metadata
);
jObj
.
put
(
CITY
,
this
.
city
!=
null
?
this
.
city
:
JSONObject
.
NULL
);
jObj
.
put
(
COUNTRY
,
this
.
country
!=
null
?
this
.
country
:
JSONObject
.
NULL
);
jObj
.
put
(
POSTAL_CODE
,
this
.
postal_code
!=
null
?
this
.
postal_code
:
JSONObject
.
NULL
);
jObj
.
put
(
VAT
,
this
.
vat
!=
null
?
this
.
vat
:
JSONObject
.
NULL
);
jObj
.
put
(
UUID
,
this
.
uuid
!=
null
?
this
.
uuid
:
JSONObject
.
NULL
);
jObj
.
put
(
CATEGORY_UUID
,
this
.
category_uuid
!=
null
?
this
.
category_uuid
:
JSONObject
.
NULL
);
jObj
.
put
(
CREATED
,
this
.
created
!=
null
?
this
.
created
:
JSONObject
.
NULL
);
jObj
.
put
(
PARENT
,
this
.
parent
!=
null
?
this
.
parent
:
JSONObject
.
NULL
);
jObj
.
put
(
IMG
,
this
.
img
!=
null
?
this
.
img
:
JSONObject
.
NULL
);
jObj
.
put
(
IMG_PREVIEW
,
this
.
img_preview
!=
null
?
this
.
img_preview
:
JSONObject
.
NULL
);
jObj
.
put
(
ADMIN_NAME
,
this
.
admin_name
!=
null
?
this
.
admin_name
:
JSONObject
.
NULL
);
jObj
.
put
(
SORTING
,
this
.
sorting
!=
null
?
this
.
sorting
:
JSONObject
.
NULL
);
jObj
.
put
(
BODY
,
this
.
body
!=
null
?
this
.
body
:
JSONObject
.
NULL
);
jObj
.
put
(
OWNER_NAME
,
this
.
owner_name
!=
null
?
this
.
owner_name
:
JSONObject
.
NULL
);
jObj
.
put
(
PREVIEW
,
this
.
preview
!=
null
?
this
.
preview
:
JSONObject
.
NULL
);
jObj
.
put
(
MERCHANT_METADATA
,
this
.
merchant_metadata
!=
null
?
this
.
merchant_metadata
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
PROMOTED
,
this
.
promoted
);
jObj
.
put
Opt
(
DISTANCE
,
this
.
distance
);
jObj
.
put
(
DISTANCE
,
this
.
distance
!=
null
?
this
.
distance
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
DEFAULT_SHOWN
,
this
.
default_shown
);
jObj
.
putOpt
(
HIDDEN
,
this
.
hidden
);
jObj
.
putOpt
(
WORKING_HOURS
,
this
.
working_hours
);
jObj
.
putOpt
(
TAGS
,
this
.
tags
);
jObj
.
putOpt
(
PRODUCT
,
this
.
product
);
jObj
.
put
(
WORKING_HOURS
,
this
.
working_hours
!=
null
?
this
.
working_hours
:
JSONObject
.
NULL
);
jObj
.
put
(
TAGS
,
this
.
tags
!=
null
?
this
.
tags
:
JSONObject
.
NULL
);
jObj
.
put
(
PRODUCT
,
this
.
product
!=
null
?
this
.
product
:
JSONObject
.
NULL
);
jObj
.
put
(
TELEPHONES_RAW
,
this
.
telephonesRaw
!=
null
?
this
.
telephonesRaw
:
JSONObject
.
NULL
);
jObj
.
put
(
YEAR_ESTABLISHED
,
this
.
yearEstablished
!=
null
?
this
.
yearEstablished
:
JSONObject
.
NULL
);
jObj
.
put
(
CURRENCY
,
this
.
currency
!=
null
?
this
.
currency
:
JSONObject
.
NULL
);
jObj
.
put
(
BANK
,
this
.
bank
!=
null
?
this
.
bank
:
JSONObject
.
NULL
);
jObj
.
put
(
MIN_ORDER_PRICE
,
this
.
minOrderPrice
!=
null
?
this
.
minOrderPrice
:
JSONObject
.
NULL
);
jObj
.
put
(
MIN_ORDER_PRICE_TAKEAWAY
,
this
.
minOrderPriceTakeaway
!=
null
?
this
.
minOrderPriceTakeaway
:
JSONObject
.
NULL
);
jObj
.
put
(
MIN_PRICE
,
this
.
minPrice
!=
null
?
this
.
minPrice
:
JSONObject
.
NULL
);
jObj
.
put
(
MAX_PRICE
,
this
.
maxPrice
!=
null
?
this
.
maxPrice
:
JSONObject
.
NULL
);
jObj
.
put
(
URL_NAME
,
this
.
urlName
!=
null
?
this
.
urlName
:
JSONObject
.
NULL
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
...
...
@@ -434,6 +514,24 @@ public class Merchant implements Parcelable, Serializable {
}
/**
* Helper method to parse the working_hours string into a JSONObject
*
* @return The working hours as a JSONObject, or null if parsing fails or value is null
*/
public
JSONObject
getWorkingHoursJSON
()
{
try
{
if
(
working_hours
!=
null
&&
!
working_hours
.
isEmpty
())
{
return
new
JSONObject
(
working_hours
);
}
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
}
}
return
null
;
}
/**
* String representation of the Merchant, as a JSON object
*
* @return A String representation of JSON object
...
...
@@ -511,11 +609,11 @@ public class Merchant implements Parcelable, Serializable {
return
region
;
}
public
d
ouble
getLatitude
()
{
public
D
ouble
getLatitude
()
{
return
latitude
;
}
public
d
ouble
getLongitude
()
{
public
D
ouble
getLongitude
()
{
return
longitude
;
}
...
...
@@ -567,6 +665,10 @@ public class Merchant implements Parcelable, Serializable {
return
jsonArrayToList
(
img
);
}
public
JSONArray
getImgRaw
()
{
return
img
;
}
public
String
getImgPreview
()
{
return
img_preview
;
}
...
...
@@ -575,7 +677,7 @@ public class Merchant implements Parcelable, Serializable {
return
admin_name
;
}
public
int
getSorting
()
{
public
Integer
getSorting
()
{
return
sorting
;
}
...
...
@@ -599,7 +701,7 @@ public class Merchant implements Parcelable, Serializable {
return
promoted
;
}
public
int
getDistance
()
{
public
Integer
getDistance
()
{
return
distance
;
}
...
...
@@ -611,7 +713,7 @@ public class Merchant implements Parcelable, Serializable {
return
hidden
;
}
public
JSONObject
getWorkingHours
()
{
public
String
getWorkingHours
()
{
return
working_hours
;
}
...
...
@@ -619,10 +721,54 @@ public class Merchant implements Parcelable, Serializable {
return
jsonArrayToList
(
tags
);
}
public
JSONArray
getTagsRaw
()
{
return
tags
;
}
public
JSONObject
getProduct
()
{
return
product
;
}
public
String
getTelephonesRaw
()
{
return
telephonesRaw
;
}
public
String
getYearEstablished
()
{
return
yearEstablished
;
}
public
String
getCurrency
()
{
return
currency
;
}
public
String
getBank
()
{
return
bank
;
}
public
String
getMinOrderPrice
()
{
return
minOrderPrice
;
}
public
String
getMinOrderPriceTakeaway
()
{
return
minOrderPriceTakeaway
;
}
public
String
getMinPrice
()
{
return
minPrice
;
}
public
String
getMaxPrice
()
{
return
maxPrice
;
}
public
String
getUrlName
()
{
return
urlName
;
}
// ================================================================================
// Setters
// ================================================================================
public
void
setAddress
(
String
address
)
{
this
.
address
=
address
;
}
...
...
@@ -671,11 +817,11 @@ public class Merchant implements Parcelable, Serializable {
this
.
region
=
region
;
}
public
void
setLatitude
(
d
ouble
latitude
)
{
public
void
setLatitude
(
D
ouble
latitude
)
{
this
.
latitude
=
latitude
;
}
public
void
setLongitude
(
d
ouble
longitude
)
{
public
void
setLongitude
(
D
ouble
longitude
)
{
this
.
longitude
=
longitude
;
}
...
...
@@ -735,7 +881,7 @@ public class Merchant implements Parcelable, Serializable {
this
.
admin_name
=
admin_name
;
}
public
void
setSorting
(
int
sorting
)
{
public
void
setSorting
(
Integer
sorting
)
{
this
.
sorting
=
sorting
;
}
...
...
@@ -759,7 +905,7 @@ public class Merchant implements Parcelable, Serializable {
this
.
promoted
=
promoted
;
}
public
void
setDistance
(
int
distance
)
{
public
void
setDistance
(
Integer
distance
)
{
this
.
distance
=
distance
;
}
...
...
@@ -771,7 +917,7 @@ public class Merchant implements Parcelable, Serializable {
this
.
hidden
=
hidden
;
}
public
void
setWorking_hours
(
JSONObject
working_hours
)
{
public
void
setWorking_hours
(
String
working_hours
)
{
this
.
working_hours
=
working_hours
;
}
...
...
@@ -783,6 +929,42 @@ public class Merchant implements Parcelable, Serializable {
this
.
product
=
product
;
}
public
void
setTelephonesRaw
(
String
telephonesRaw
)
{
this
.
telephonesRaw
=
telephonesRaw
;
}
public
void
setYearEstablished
(
String
yearEstablished
)
{
this
.
yearEstablished
=
yearEstablished
;
}
public
void
setCurrency
(
String
currency
)
{
this
.
currency
=
currency
;
}
public
void
setBank
(
String
bank
)
{
this
.
bank
=
bank
;
}
public
void
setMinOrderPrice
(
String
minOrderPrice
)
{
this
.
minOrderPrice
=
minOrderPrice
;
}
public
void
setMinOrderPriceTakeaway
(
String
minOrderPriceTakeaway
)
{
this
.
minOrderPriceTakeaway
=
minOrderPriceTakeaway
;
}
public
void
setMinPrice
(
String
minPrice
)
{
this
.
minPrice
=
minPrice
;
}
public
void
setMaxPrice
(
String
maxPrice
)
{
this
.
maxPrice
=
maxPrice
;
}
public
void
setUrlName
(
String
urlName
)
{
this
.
urlName
=
urlName
;
}
@Override
public
int
describeContents
()
{
return
0
;
...
...
@@ -805,7 +987,6 @@ public class Merchant implements Parcelable, Serializable {
listData
.
add
(
jArray
.
optString
(
i
));
}
}
return
listData
;
}
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/User.java
0 → 100644
View file @
2b9f74f
/*
* Copyright 2010-2013 Warply Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package
ly
.
warp
.
sdk
.
io
.
models
;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
ly.warp.sdk.utils.WarpUtils
;
import
ly.warp.sdk.utils.constants.WarpConstants
;
/**
* Created by Panagiotis Triantafyllou on 27-Feb-26.
*/
public
class
User
implements
Parcelable
,
Serializable
{
private
static
final
long
serialVersionUID
=
-
4754964462459705285L
;
/* Constants used to export the User in JSON format and vice versa */
private
static
final
String
CONSUMER_METADATA
=
"consumer_metadata"
;
private
static
final
String
ELIGIBILITY_TYPE
=
"eligibility_type"
;
private
static
final
String
EMAIL
=
"email"
;
private
static
final
String
FAVORITE_COUPONSETS
=
"favorite_couponsets"
;
private
static
final
String
IS_ELIGIBLE
=
"is_eligible"
;
private
static
final
String
MSISDN
=
"msisdn"
;
private
static
final
String
PROFILE_METADATA
=
"profile_metadata"
;
private
static
final
String
QUESTIONNAIRE
=
"questionnaire"
;
private
static
final
String
QUESTIONNAIRE_ANSWERS
=
"questionnaire_answers"
;
private
static
final
String
USER_ANSWERS
=
"user_answers"
;
private
static
final
String
USER_ID
=
"user_id"
;
private
static
final
String
USER_SEGMENTS
=
"user_segments"
;
private
static
final
String
UUID
=
"uuid"
;
/* Member variables of the User object */
private
JSONObject
consumerMetadata
;
private
String
eligibilityType
;
private
String
email
;
private
JSONArray
favoriteCouponsets
;
private
boolean
isEligible
=
false
;
private
String
msisdn
;
private
String
profileMetadata
;
private
JSONObject
questionnaire
;
private
JSONObject
questionnaireAnswers
;
private
JSONObject
userAnswers
;
private
String
userId
;
private
JSONArray
userSegments
;
private
String
uuid
;
/**
* Helper method to get a nullable String from a JSONObject.
* Returns null if the JSON value is null, otherwise returns the String value.
*/
private
static
String
optNullableString
(
JSONObject
json
,
String
key
)
{
return
json
.
isNull
(
key
)
?
null
:
json
.
optString
(
key
);
}
public
User
()
{
this
.
consumerMetadata
=
null
;
this
.
eligibilityType
=
null
;
this
.
email
=
null
;
this
.
favoriteCouponsets
=
null
;
this
.
isEligible
=
false
;
this
.
msisdn
=
null
;
this
.
profileMetadata
=
null
;
this
.
questionnaire
=
null
;
this
.
questionnaireAnswers
=
null
;
this
.
userAnswers
=
null
;
this
.
userId
=
null
;
this
.
userSegments
=
null
;
this
.
uuid
=
null
;
}
/**
* Basic constructor used to create an object from a String, representing a
* JSON Object
*
* @param json The String, representing the JSON Object
* @throws JSONException Thrown if the String cannot be converted to JSON
*/
public
User
(
String
json
)
throws
JSONException
{
this
(
new
JSONObject
(
json
));
}
/**
* Constructor used to create an Object from a given JSON Object
*
* @param json JSON Object used to create the User
*/
public
User
(
JSONObject
json
)
{
if
(
json
!=
null
)
{
this
.
consumerMetadata
=
json
.
optJSONObject
(
CONSUMER_METADATA
);
this
.
eligibilityType
=
optNullableString
(
json
,
ELIGIBILITY_TYPE
);
this
.
email
=
optNullableString
(
json
,
EMAIL
);
this
.
favoriteCouponsets
=
json
.
optJSONArray
(
FAVORITE_COUPONSETS
);
this
.
isEligible
=
json
.
optBoolean
(
IS_ELIGIBLE
);
this
.
msisdn
=
optNullableString
(
json
,
MSISDN
);
this
.
profileMetadata
=
optNullableString
(
json
,
PROFILE_METADATA
);
this
.
questionnaire
=
json
.
optJSONObject
(
QUESTIONNAIRE
);
this
.
questionnaireAnswers
=
json
.
optJSONObject
(
QUESTIONNAIRE_ANSWERS
);
this
.
userAnswers
=
json
.
optJSONObject
(
USER_ANSWERS
);
this
.
userId
=
optNullableString
(
json
,
USER_ID
);
this
.
userSegments
=
json
.
optJSONArray
(
USER_SEGMENTS
);
this
.
uuid
=
optNullableString
(
json
,
UUID
);
}
}
public
User
(
Parcel
source
)
{
this
.
eligibilityType
=
source
.
readString
();
this
.
email
=
source
.
readString
();
this
.
isEligible
=
source
.
readByte
()
!=
0
;
this
.
msisdn
=
source
.
readString
();
this
.
profileMetadata
=
source
.
readString
();
this
.
userId
=
source
.
readString
();
this
.
uuid
=
source
.
readString
();
try
{
String
consumerMetadataStr
=
source
.
readString
();
this
.
consumerMetadata
=
consumerMetadataStr
!=
null
?
new
JSONObject
(
consumerMetadataStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
consumerMetadata
=
null
;
}
try
{
String
favoriteCouponsetsStr
=
source
.
readString
();
this
.
favoriteCouponsets
=
favoriteCouponsetsStr
!=
null
?
new
JSONArray
(
favoriteCouponsetsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
favoriteCouponsets
=
null
;
}
try
{
String
questionnaireStr
=
source
.
readString
();
this
.
questionnaire
=
questionnaireStr
!=
null
?
new
JSONObject
(
questionnaireStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
questionnaire
=
null
;
}
try
{
String
questionnaireAnswersStr
=
source
.
readString
();
this
.
questionnaireAnswers
=
questionnaireAnswersStr
!=
null
?
new
JSONObject
(
questionnaireAnswersStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
questionnaireAnswers
=
null
;
}
try
{
String
userAnswersStr
=
source
.
readString
();
this
.
userAnswers
=
userAnswersStr
!=
null
?
new
JSONObject
(
userAnswersStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
userAnswers
=
null
;
}
try
{
String
userSegmentsStr
=
source
.
readString
();
this
.
userSegments
=
userSegmentsStr
!=
null
?
new
JSONArray
(
userSegmentsStr
)
:
null
;
}
catch
(
JSONException
e
)
{
this
.
userSegments
=
null
;
}
}
@Override
public
void
writeToParcel
(
Parcel
dest
,
int
flags
)
{
dest
.
writeString
(
this
.
eligibilityType
);
dest
.
writeString
(
this
.
email
);
dest
.
writeByte
((
byte
)
(
this
.
isEligible
?
1
:
0
));
dest
.
writeString
(
this
.
msisdn
);
dest
.
writeString
(
this
.
profileMetadata
);
dest
.
writeString
(
this
.
userId
);
dest
.
writeString
(
this
.
uuid
);
dest
.
writeString
(
this
.
consumerMetadata
!=
null
?
this
.
consumerMetadata
.
toString
()
:
null
);
dest
.
writeString
(
this
.
favoriteCouponsets
!=
null
?
this
.
favoriteCouponsets
.
toString
()
:
null
);
dest
.
writeString
(
this
.
questionnaire
!=
null
?
this
.
questionnaire
.
toString
()
:
null
);
dest
.
writeString
(
this
.
questionnaireAnswers
!=
null
?
this
.
questionnaireAnswers
.
toString
()
:
null
);
dest
.
writeString
(
this
.
userAnswers
!=
null
?
this
.
userAnswers
.
toString
()
:
null
);
dest
.
writeString
(
this
.
userSegments
!=
null
?
this
.
userSegments
.
toString
()
:
null
);
}
/**
* Converts the User into a JSON Object
*
* @return The JSON Object created from this User
*/
public
JSONObject
toJSONObject
()
{
JSONObject
jObj
=
new
JSONObject
();
try
{
jObj
.
put
(
CONSUMER_METADATA
,
this
.
consumerMetadata
!=
null
?
this
.
consumerMetadata
:
JSONObject
.
NULL
);
jObj
.
put
(
ELIGIBILITY_TYPE
,
this
.
eligibilityType
!=
null
?
this
.
eligibilityType
:
JSONObject
.
NULL
);
jObj
.
put
(
EMAIL
,
this
.
email
!=
null
?
this
.
email
:
JSONObject
.
NULL
);
jObj
.
put
(
FAVORITE_COUPONSETS
,
this
.
favoriteCouponsets
!=
null
?
this
.
favoriteCouponsets
:
JSONObject
.
NULL
);
jObj
.
putOpt
(
IS_ELIGIBLE
,
this
.
isEligible
);
jObj
.
put
(
MSISDN
,
this
.
msisdn
!=
null
?
this
.
msisdn
:
JSONObject
.
NULL
);
jObj
.
put
(
PROFILE_METADATA
,
this
.
profileMetadata
!=
null
?
this
.
profileMetadata
:
JSONObject
.
NULL
);
jObj
.
put
(
QUESTIONNAIRE
,
this
.
questionnaire
!=
null
?
this
.
questionnaire
:
JSONObject
.
NULL
);
jObj
.
put
(
QUESTIONNAIRE_ANSWERS
,
this
.
questionnaireAnswers
!=
null
?
this
.
questionnaireAnswers
:
JSONObject
.
NULL
);
jObj
.
put
(
USER_ANSWERS
,
this
.
userAnswers
!=
null
?
this
.
userAnswers
:
JSONObject
.
NULL
);
jObj
.
put
(
USER_ID
,
this
.
userId
!=
null
?
this
.
userId
:
JSONObject
.
NULL
);
jObj
.
put
(
USER_SEGMENTS
,
this
.
userSegments
!=
null
?
this
.
userSegments
:
JSONObject
.
NULL
);
jObj
.
put
(
UUID
,
this
.
uuid
!=
null
?
this
.
uuid
:
JSONObject
.
NULL
);
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
}
}
return
jObj
;
}
/**
* String representation of the User, as a JSON object
*
* @return A String representation of JSON object
*/
public
String
toString
()
{
if
(
toJSONObject
()
!=
null
)
return
toJSONObject
().
toString
();
return
null
;
}
/**
* String representation of the User, as a human readable JSON object
*
* @return A human readable String representation of JSON object
*/
public
String
toHumanReadableString
()
{
String
humanReadableString
=
null
;
try
{
humanReadableString
=
toJSONObject
().
toString
(
2
);
}
catch
(
JSONException
e
)
{
WarpUtils
.
warn
(
"Failed converting User JSON object to String"
,
e
);
}
return
humanReadableString
;
}
/**
* Helper method to parse the profile_metadata string into a JSONObject
*
* @return The profile metadata as a JSONObject, or null if parsing fails or value is null
*/
public
JSONObject
getProfileMetadataJSON
()
{
try
{
if
(
profileMetadata
!=
null
&&
!
profileMetadata
.
isEmpty
())
{
return
new
JSONObject
(
profileMetadata
);
}
}
catch
(
JSONException
e
)
{
if
(
WarpConstants
.
DEBUG
)
{
e
.
printStackTrace
();
}
}
return
null
;
}
// ================================================================================
// Getters
// ================================================================================
public
JSONObject
getConsumerMetadata
()
{
return
consumerMetadata
;
}
public
String
getEligibilityType
()
{
return
eligibilityType
;
}
public
String
getEmail
()
{
return
email
;
}
public
JSONArray
getFavoriteCouponsets
()
{
return
favoriteCouponsets
;
}
public
ArrayList
<
String
>
getFavoriteCouponsetsList
()
{
return
jsonArrayToList
(
favoriteCouponsets
);
}
public
boolean
isEligible
()
{
return
isEligible
;
}
public
String
getMsisdn
()
{
return
msisdn
;
}
public
String
getProfileMetadata
()
{
return
profileMetadata
;
}
public
JSONObject
getQuestionnaire
()
{
return
questionnaire
;
}
public
JSONObject
getQuestionnaireAnswers
()
{
return
questionnaireAnswers
;
}
public
JSONObject
getUserAnswers
()
{
return
userAnswers
;
}
public
String
getUserId
()
{
return
userId
;
}
public
JSONArray
getUserSegments
()
{
return
userSegments
;
}
public
ArrayList
<
String
>
getUserSegmentsList
()
{
return
jsonArrayToList
(
userSegments
);
}
public
String
getUuid
()
{
return
uuid
;
}
// ================================================================================
// Setters
// ================================================================================
public
void
setConsumerMetadata
(
JSONObject
consumerMetadata
)
{
this
.
consumerMetadata
=
consumerMetadata
;
}
public
void
setEligibilityType
(
String
eligibilityType
)
{
this
.
eligibilityType
=
eligibilityType
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
public
void
setFavoriteCouponsets
(
JSONArray
favoriteCouponsets
)
{
this
.
favoriteCouponsets
=
favoriteCouponsets
;
}
public
void
setEligible
(
boolean
eligible
)
{
isEligible
=
eligible
;
}
public
void
setMsisdn
(
String
msisdn
)
{
this
.
msisdn
=
msisdn
;
}
public
void
setProfileMetadata
(
String
profileMetadata
)
{
this
.
profileMetadata
=
profileMetadata
;
}
public
void
setQuestionnaire
(
JSONObject
questionnaire
)
{
this
.
questionnaire
=
questionnaire
;
}
public
void
setQuestionnaireAnswers
(
JSONObject
questionnaireAnswers
)
{
this
.
questionnaireAnswers
=
questionnaireAnswers
;
}
public
void
setUserAnswers
(
JSONObject
userAnswers
)
{
this
.
userAnswers
=
userAnswers
;
}
public
void
setUserId
(
String
userId
)
{
this
.
userId
=
userId
;
}
public
void
setUserSegments
(
JSONArray
userSegments
)
{
this
.
userSegments
=
userSegments
;
}
public
void
setUuid
(
String
uuid
)
{
this
.
uuid
=
uuid
;
}
@Override
public
int
describeContents
()
{
return
0
;
}
public
static
final
Creator
<
User
>
CREATOR
=
new
Creator
<
User
>()
{
public
User
createFromParcel
(
Parcel
source
)
{
return
new
User
(
source
);
}
public
User
[]
newArray
(
int
size
)
{
return
new
User
[
size
];
}
};
private
ArrayList
<
String
>
jsonArrayToList
(
JSONArray
jArray
)
{
ArrayList
<
String
>
listData
=
new
ArrayList
<
String
>();
if
(
jArray
!=
null
)
{
for
(
int
i
=
0
;
i
<
jArray
.
length
();
i
++)
{
listData
.
add
(
jArray
.
optString
(
i
));
}
}
return
listData
;
}
}
warply_android_sdk/src/main/java/ly/warp/sdk/io/volley/ApiClient.java
View file @
2b9f74f
...
...
@@ -5,6 +5,7 @@ import java.util.concurrent.TimeUnit;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.utils.WarplyProperty
;
import
okhttp3.OkHttpClient
;
import
okhttp3.logging.HttpLoggingInterceptor
;
import
retrofit2.Retrofit
;
import
retrofit2.converter.gson.GsonConverterFactory
;
...
...
@@ -48,11 +49,11 @@ public class ApiClient {
private
static
OkHttpClient
getClient
()
{
/* Logs Enabled */
//
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
//
interceptor.setLevel(HttpLoggingInterceptor.Level.BODY);
HttpLoggingInterceptor
interceptor
=
new
HttpLoggingInterceptor
();
interceptor
.
setLevel
(
HttpLoggingInterceptor
.
Level
.
BODY
);
return
new
OkHttpClient
.
Builder
()
//
.addInterceptor(interceptor) // Logs Enabled
.
addInterceptor
(
interceptor
)
// Logs Enabled
.
connectTimeout
(
30
,
TimeUnit
.
SECONDS
)
.
writeTimeout
(
30
,
TimeUnit
.
SECONDS
)
.
readTimeout
(
30
,
TimeUnit
.
SECONDS
)
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/volley/ApiService.java
View file @
2b9f74f
...
...
@@ -32,23 +32,25 @@ public interface ApiService {
@Headers
(
"Content-Type: application/json"
)
@POST
(
"/partners/dei/app_login"
)
Call
<
ResponseBody
>
dehUser
(
@Body
RequestBody
request
,
Call
<
ResponseBody
>
loginUser
(
@Body
RequestBody
request
,
@Header
(
WarpConstants
.
HEADER_DATE
)
String
timeStamp
,
@Header
(
WarpConstants
.
HEADER_LOYALTY_BUNDLE_ID
)
String
bundleId
,
@Header
(
WarpConstants
.
HEADER_UNIQUE_DEVICE_ID
)
String
deviceId
,
@Header
(
WarpConstants
.
HEADER_CHANNEL
)
String
channel
,
@Header
(
WarpConstants
.
HEADER_WEB_ID
)
String
webId
,
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
);
@Headers
(
"Content-Type: application/json"
)
@POST
(
"/oauth/{appUuid}/context"
)
Call
<
ResponseBody
>
getUser
(
@Path
(
"appUuid"
)
String
appUuid
,
@Body
RequestBody
request
,
@Header
(
WarpConstants
.
HEADER_DATE
)
String
timeStamp
,
@Header
(
WarpConstants
.
HEADER_LOYALTY_BUNDLE_ID
)
String
bundleId
,
@Header
(
WarpConstants
.
HEADER_UNIQUE_DEVICE_ID
)
String
deviceId
,
@Header
(
WarpConstants
.
HEADER_CHANNEL
)
String
channel
,
@Header
(
WarpConstants
.
HEADER_WEB_ID
)
String
webId
,
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
);
@Headers
(
"Content-Type: application/json"
)
@POST
(
"/partners/dei/verify"
)
Call
<
ResponseBody
>
verifyUser
(
@Body
RequestBody
request
,
@Header
(
WarpConstants
.
HEADER_DATE
)
String
timeStamp
,
@Header
(
WarpConstants
.
HEADER_LOYALTY_BUNDLE_ID
)
String
bundleId
,
@Header
(
WarpConstants
.
HEADER_UNIQUE_DEVICE_ID
)
String
deviceId
,
@Header
(
WarpConstants
.
HEADER_CHANNEL
)
String
channel
,
@Header
(
WarpConstants
.
HEADER_WEB_ID
)
String
webId
,
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
);
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
,
@Header
(
WarpConstants
.
HEADER_AUTHORIZATION
)
String
bearer
);
@Headers
(
"Content-Type: application/json"
)
@POST
(
"/oauth/{appUuid}/logout"
)
...
...
@@ -59,7 +61,8 @@ public interface ApiService {
@Header
(
WarpConstants
.
HEADER_UNIQUE_DEVICE_ID
)
String
deviceId
,
@Header
(
WarpConstants
.
HEADER_CHANNEL
)
String
channel
,
@Header
(
WarpConstants
.
HEADER_WEB_ID
)
String
webId
,
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
);
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
,
@Header
(
WarpConstants
.
HEADER_AUTHORIZATION
)
String
bearer
);
@Headers
(
"Content-Type: application/json"
)
@POST
(
"/user/v5/{appUuid}/logout"
)
...
...
@@ -70,7 +73,8 @@ public interface ApiService {
@Header
(
WarpConstants
.
HEADER_UNIQUE_DEVICE_ID
)
String
deviceId
,
@Header
(
WarpConstants
.
HEADER_CHANNEL
)
String
channel
,
@Header
(
WarpConstants
.
HEADER_WEB_ID
)
String
webId
,
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
);
@Header
(
WarpConstants
.
HEADER_SIGNATURE
)
String
signature
,
@Header
(
WarpConstants
.
HEADER_AUTHORIZATION
)
String
bearer
);
@Headers
(
"Content-Type: application/json"
)
@POST
(
"/oauth/{appUuid}/context"
)
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/WarplyManagerHelper.java
View file @
2b9f74f
...
...
@@ -29,12 +29,14 @@ import org.json.JSONException;
import
org.json.JSONObject
;
import
java.util.ArrayList
;
import
java.util.LinkedHashMap
;
import
ly.warp.sdk.Warply
;
import
ly.warp.sdk.db.WarplyDBHelper
;
import
ly.warp.sdk.io.models.BannerItem
;
import
ly.warp.sdk.io.models.Campaign
;
import
ly.warp.sdk.io.models.CouponList
;
import
ly.warp.sdk.io.models.Couponset
;
import
ly.warp.sdk.utils.managers.WarplyManager
;
/**
...
...
@@ -54,6 +56,7 @@ public class WarplyManagerHelper {
private
static
CouponList
mCouponRedeemedList
=
new
CouponList
();
private
static
ArrayList
<
Campaign
>
mCampaignListAll
=
new
ArrayList
<
Campaign
>();
private
static
ArrayList
<
BannerItem
>
mBannerListAll
=
new
ArrayList
<
BannerItem
>();
private
static
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
mCouponsetCategorizedMap
=
new
LinkedHashMap
<>();
// ===========================================================
// Methods for/from SuperClass/Interfaces
...
...
@@ -81,6 +84,15 @@ public class WarplyManagerHelper {
return
mBannerListAll
;
}
public
static
void
setCouponsetCategorizedMap
(
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
couponsetMap
)
{
mCouponsetCategorizedMap
.
clear
();
mCouponsetCategorizedMap
.
putAll
(
couponsetMap
);
}
public
static
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
getCouponsetCategorizedMap
()
{
return
mCouponsetCategorizedMap
;
}
public
static
void
setCouponRedeemedList
(
CouponList
couponRedeemedList
)
{
mCouponRedeemedList
.
clear
();
mCouponRedeemedList
.
addAll
(
couponRedeemedList
);
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/utils/managers/WarplyManager.java
View file @
2b9f74f
...
...
@@ -45,6 +45,8 @@ import org.json.JSONObject;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.LinkedHashMap
;
import
java.util.LinkedHashSet
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -62,8 +64,7 @@ import ly.warp.sdk.io.models.Coupon;
import
ly.warp.sdk.io.models.CouponList
;
import
ly.warp.sdk.io.models.Couponset
;
import
ly.warp.sdk.io.models.Merchant
;
import
ly.warp.sdk.io.models.NewCampaign
;
import
ly.warp.sdk.io.models.RedeemedSMHistoryModel
;
import
ly.warp.sdk.io.models.User
;
import
ly.warp.sdk.io.request.WarplyRefreshTokenRequest
;
import
ly.warp.sdk.io.volley.ApiClient
;
import
ly.warp.sdk.io.volley.ApiService
;
...
...
@@ -149,7 +150,8 @@ public class WarplyManager {
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
)
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
),
"Bearer "
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
)
)
:
service
.
logoutUser
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
loginRequest
,
...
...
@@ -158,7 +160,8 @@ public class WarplyManager {
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
)
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
),
"Bearer "
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
)
);
logoutCall
.
enqueue
(
new
Callback
<
ResponseBody
>()
{
@Override
...
...
@@ -187,23 +190,23 @@ public class WarplyManager {
});
}
public
static
void
getDehUser
(
String
email
,
final
CallbackReceiver
<
JSONObject
>
receiver
)
{
WarpUtils
.
log
(
"************* WARPLY
Deh User
Request ********************"
);
WarpUtils
.
log
(
"[WARP Trace] WARPLY
Deh User Request
is active"
);
public
static
void
login
(
String
email
,
final
CallbackReceiver
<
JSONObject
>
receiver
)
{
WarpUtils
.
log
(
"************* WARPLY
Login
Request ********************"
);
WarpUtils
.
log
(
"[WARP Trace] WARPLY
Login
is active"
);
WarpUtils
.
log
(
"**************************************************"
);
if
(
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
isTableNotEmpty
(
"auth"
))
{
JSONObject
newResult
=
new
JSONObject
();
try
{
newResult
.
putOpt
(
"status"
,
1
);
newResult
.
putOpt
(
"message"
,
"Success"
);
receiver
.
onSuccess
(
newResult
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
receiver
.
onFailure
(
2
);
}
return
;
}
//
if (WarplyDBHelper.getInstance(Warply.getWarplyContext()).isTableNotEmpty("auth")) {
//
JSONObject newResult = new JSONObject();
//
try {
//
newResult.putOpt("status", 1);
//
newResult.putOpt("message", "Success");
//
receiver.onSuccess(newResult);
//
} catch (JSONException e) {
//
e.printStackTrace();
//
receiver.onFailure(2);
//
}
//
return;
//
}
ApiService
service
=
ApiClient
.
getRetrofitInstance
().
create
(
ApiService
.
class
);
...
...
@@ -216,7 +219,7 @@ public class WarplyManager {
RequestBody
loginRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParams
)).
toString
());
Call
<
ResponseBody
>
loginCall
=
service
.
deh
User
(
Call
<
ResponseBody
>
loginCall
=
service
.
login
User
(
loginRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
...
...
@@ -238,7 +241,7 @@ public class WarplyManager {
}
if
(
jobjLoginResponse
!=
null
&&
jobjLoginResponse
.
has
(
"status"
)
&&
jobjLoginResponse
.
optString
(
"status"
,
"2"
).
equals
(
"1"
))
{
JSONObject
tokens
=
jobjLoginResponse
.
optJSONObject
(
"
result
"
);
JSONObject
tokens
=
jobjLoginResponse
.
optJSONObject
(
"
tokens
"
);
if
(
tokens
!=
null
)
{
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
saveClientAccess
(
tokens
.
optString
(
"client_id"
,
""
),
tokens
.
optString
(
"client_secret"
,
""
));
...
...
@@ -269,80 +272,93 @@ public class WarplyManager {
});
}
public
static
void
verifyTicket
(
String
ticket
,
String
guid
,
final
CallbackReceiver
<
JSONObject
>
receiver
)
{
WarpUtils
.
log
(
"************* WARPLY
Verify Ticket
Request ********************"
);
WarpUtils
.
log
(
"[WARP Trace] WARPLY
Verify Ticket
Request is active"
);
public
static
void
getUser
(
final
CallbackReceiver
<
User
>
receiver
)
{
WarpUtils
.
log
(
"************* WARPLY
User
Request ********************"
);
WarpUtils
.
log
(
"[WARP Trace] WARPLY
User
Request is active"
);
WarpUtils
.
log
(
"**************************************************"
);
if
(
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
isTableNotEmpty
(
"auth"
))
{
JSONObject
newResult
=
new
JSONObject
();
try
{
newResult
.
putOpt
(
"status"
,
1
);
newResult
.
putOpt
(
"message"
,
"Success"
);
receiver
.
onSuccess
(
newResult
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
receiver
.
onFailure
(
2
);
}
return
;
}
ApiService
service
=
ApiClient
.
getRetrofitInstance
().
create
(
ApiService
.
class
);
String
timeStamp
=
DateFormat
.
format
(
"yyyy-MM-dd hh:mm:ss"
,
System
.
currentTimeMillis
()).
toString
();
String
apiKey
=
WarpUtils
.
getApiKey
(
Warply
.
getWarplyContext
());
String
webId
=
WarpUtils
.
getWebId
(
Warply
.
getWarplyContext
());
Map
<
String
,
Object
>
jsonParamsUser
=
new
ArrayMap
<>();
Map
<
String
,
Object
>
jsonParams
=
new
ArrayMap
<>();
jsonParams
.
put
(
"app_uuid"
,
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()));
jsonParams
.
put
(
"guid"
,
guid
);
jsonParams
.
put
(
"ticket"
,
ticket
);
jsonParams
.
put
(
"action"
,
"handle_user_details"
);
jsonParams
.
put
(
"process"
,
"get"
);
RequestBody
loginRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParams
)).
toString
());
jsonParamsUser
.
put
(
"consumer_data"
,
jsonParams
);
RequestBody
userRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParamsUser
)).
toString
());
Call
<
ResponseBody
>
loginCall
=
service
.
verifyUser
(
loginRequest
,
Call
<
ResponseBody
>
profileCall
=
service
.
getUser
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
userRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
"mobile"
,
webId
,
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
)
WarpUtils
.
produceSignature
(
apiKey
+
timeStamp
),
"Bearer "
+
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
getAuthValue
(
"access_token"
)
);
login
Call
.
enqueue
(
new
Callback
<
ResponseBody
>()
{
profile
Call
.
enqueue
(
new
Callback
<
ResponseBody
>()
{
@Override
public
void
onResponse
(
@NonNull
Call
<
ResponseBody
>
call
,
@NonNull
Response
<
ResponseBody
>
response
)
{
if
(
response
.
code
()
==
200
&&
response
.
body
()
!=
null
)
{
JSONObject
jobj
Login
Response
=
null
;
JSONObject
jobj
User
Response
=
null
;
try
{
jobj
Login
Response
=
new
JSONObject
(
response
.
body
().
string
());
jobj
User
Response
=
new
JSONObject
(
response
.
body
().
string
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
if
(
jobjLoginResponse
!=
null
&&
jobjLoginResponse
.
has
(
"result"
)
&&
jobjLoginResponse
.
optString
(
"result"
,
"2"
).
equals
(
"1"
))
{
JSONObject
tokens
=
jobjLoginResponse
.
optJSONObject
(
"tokens"
);
if
(
tokens
!=
null
)
{
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
saveClientAccess
(
tokens
.
optString
(
"client_id"
,
""
),
tokens
.
optString
(
"client_secret"
,
""
));
if
(
jobjUserResponse
!=
null
&&
jobjUserResponse
.
has
(
"status"
)
&&
jobjUserResponse
.
optString
(
"status"
,
"2"
).
equals
(
"1"
))
{
JSONObject
jUserBody
=
null
;
try
{
jUserBody
=
jobjUserResponse
.
optJSONObject
(
"result"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
WarplyDBHelper
.
getInstance
(
Warply
.
getWarplyContext
()).
saveAuthAccess
(
tokens
.
optString
(
"access_token"
,
""
),
tokens
.
optString
(
"refresh_token"
,
""
));
if
(
jUserBody
!=
null
)
{
User
user
=
new
User
(
jUserBody
);
JSONObject
newResult
=
new
JSONObject
();
try
{
newResult
.
putOpt
(
"status"
,
1
);
newResult
.
putOpt
(
"message"
,
"Success"
);
receiver
.
onSuccess
(
newResult
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
receiver
.
onFailure
(
2
);
}
receiver
.
onSuccess
(
user
);
}
else
{
receiver
.
onFailure
(
2
);
}
}
else
{
receiver
.
onFailure
(
2
);
}
}
else
if
(
response
.
code
()
==
401
)
{
refreshToken
(
new
WarplyRefreshTokenRequest
(),
new
CallbackReceiver
<
JSONObject
>()
{
@Override
public
void
onSuccess
(
JSONObject
result
)
{
int
status
=
result
.
optInt
(
"status"
,
2
);
if
(
status
==
1
)
getUser
(
receiver
/*, tries*/
);
else
{
// if (tries < MAX_RETRIES) {
// getUser(receiver, (tries + 1));
// } else {
receiver
.
onFailure
(
status
);
// }
}
}
@Override
public
void
onFailure
(
int
errorCode
)
{
// if (tries < MAX_RETRIES) {
// getUser(receiver, (tries + 1));
// } else {
receiver
.
onFailure
(
2
);
// }
}
});
}
else
if
(
String
.
valueOf
(
response
.
code
()).
startsWith
(
"5"
))
{
receiver
.
onFailure
(
2
);
}
else
{
receiver
.
onFailure
(
response
.
code
());
}
...
...
@@ -387,7 +403,59 @@ public class WarplyManager {
},
executorService
);
}
public
static
void
getCouponsets
(
final
CallbackReceiver
<
ArrayList
<
Couponset
>>
receiver
)
{
private
static
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
mergeCouponsetsResults
(
ArrayList
<
Couponset
>
resultCouponsets
,
ArrayList
<
Merchant
>
resultMerchants
)
{
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
categorizedMap
=
new
LinkedHashMap
<>();
if
(
resultCouponsets
==
null
||
resultCouponsets
.
isEmpty
())
{
WarplyManagerHelper
.
setCouponsetCategorizedMap
(
categorizedMap
);
return
categorizedMap
;
}
HashMap
<
String
,
Merchant
>
merchantLookup
=
new
HashMap
<>();
if
(
resultMerchants
!=
null
)
{
for
(
Merchant
merchant
:
resultMerchants
)
{
if
(
merchant
.
getUuid
()
!=
null
)
{
merchantLookup
.
put
(
merchant
.
getUuid
(),
merchant
);
}
}
}
ArrayList
<
Couponset
>
topOffers
=
new
ArrayList
<>();
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>
categoryGroups
=
new
LinkedHashMap
<>();
for
(
Couponset
couponset
:
resultCouponsets
)
{
// Match merchant by merchantUuid
if
(
couponset
.
getMerchantUuid
()
!=
null
&&
merchantLookup
.
containsKey
(
couponset
.
getMerchantUuid
()))
{
couponset
.
setMerchant
(
merchantLookup
.
get
(
couponset
.
getMerchantUuid
()));
}
if
(
couponset
.
isPromoted
())
{
topOffers
.
add
(
couponset
);
}
else
{
String
category
=
couponset
.
getOfferCategory
();
if
(
category
==
null
||
category
.
isEmpty
())
{
category
=
"Other"
;
}
categoryGroups
.
computeIfAbsent
(
category
,
k
->
new
ArrayList
<>()).
add
(
couponset
);
}
}
if
(!
topOffers
.
isEmpty
())
{
categorizedMap
.
put
(
"Top offers"
,
topOffers
);
}
for
(
Map
.
Entry
<
String
,
ArrayList
<
Couponset
>>
entry
:
categoryGroups
.
entrySet
())
{
if
(!
entry
.
getValue
().
isEmpty
())
{
categorizedMap
.
put
(
entry
.
getKey
(),
entry
.
getValue
());
}
}
WarplyManagerHelper
.
setCouponsetCategorizedMap
(
categorizedMap
);
return
categorizedMap
;
}
public
static
void
getCouponsets
(
final
CallbackReceiver
<
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>>
receiver
)
{
WarpUtils
.
log
(
"************* WARPLY Couponsets Request ********************"
);
WarpUtils
.
log
(
"[WARP Trace] WARPLY Couponsets Request is active"
);
WarpUtils
.
log
(
"**************************************************"
);
...
...
@@ -399,14 +467,15 @@ public class WarplyManager {
ListenableFuture
<
ArrayList
<
Merchant
>>
futureMerchants
=
getMerchantsRetro
(
service
);
ListenableFuture
<
List
<
Object
>>
allResultsFuture
=
Futures
.
allAsList
(
futureCouponsets
,
futureMerchants
);
ListenableFuture
<
ArrayList
<
Couponset
>>
mergedResultFuture
=
Futures
.
transformAsync
(
allResultsFuture
,
results
->
{
ArrayList
<
Couponset
>
resultCoupons
=
(
ArrayList
<
Couponset
>)
results
.
get
(
0
);
return
executorService
.
submit
(()
->
resultCoupons
/*createCouponSetsSection(resultCoupons)*/
);
ListenableFuture
<
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>>>
mergedResultFuture
=
Futures
.
transformAsync
(
allResultsFuture
,
results
->
{
ArrayList
<
Couponset
>
resultCouponsets
=
(
ArrayList
<
Couponset
>)
results
.
get
(
0
);
ArrayList
<
Merchant
>
resultMerchants
=
(
ArrayList
<
Merchant
>)
results
.
get
(
1
);
return
executorService
.
submit
(()
->
mergeCouponsetsResults
(
resultCouponsets
,
resultMerchants
));
},
executorService
);
Futures
.
addCallback
(
mergedResultFuture
,
new
FutureCallback
<
ArrayList
<
Couponset
>>()
{
Futures
.
addCallback
(
mergedResultFuture
,
new
FutureCallback
<
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>
>>()
{
@Override
public
void
onSuccess
(
ArrayList
<
Couponset
>
mergedResult
)
{
public
void
onSuccess
(
LinkedHashMap
<
String
,
ArrayList
<
Couponset
>
>
mergedResult
)
{
executorService
.
shutdownNow
();
new
Handler
(
Looper
.
getMainLooper
()).
post
(()
->
receiver
.
onSuccess
(
mergedResult
));
}
...
...
@@ -511,10 +580,10 @@ public class WarplyManager {
jsonParams
.
put
(
"language"
,
WarplyProperty
.
getLanguage
(
Warply
.
getWarplyContext
()));
jsonParamsMerchants
.
put
(
"shops"
,
jsonParams
);
RequestBody
couponse
tsRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParamsMerchants
)).
toString
());
RequestBody
merchan
tsRequest
=
RequestBody
.
create
(
MediaType
.
get
(
"application/json; charset=utf-8"
),
(
new
JSONObject
(
jsonParamsMerchants
)).
toString
());
Call
<
ResponseBody
>
merchantsCall
=
service
.
getMerchants
(
WarplyProperty
.
getAppUuid
(
Warply
.
getWarplyContext
()),
couponse
tsRequest
,
merchan
tsRequest
,
timeStamp
,
"android:"
+
Warply
.
getWarplyContext
().
getPackageName
(),
new
WarplyDeviceInfoCollector
(
Warply
.
getWarplyContext
()).
getUniqueDeviceId
(),
...
...
@@ -546,8 +615,8 @@ public class WarplyManager {
JSONArray
finalJMerchantsBody
=
jMerchantsBody
;
executorCouponsets
.
submit
(()
->
{
for
(
int
i
=
0
;
i
<
finalJMerchantsBody
.
length
();
++
i
)
{
Merchant
temp
Couponse
t
=
new
Merchant
(
finalJMerchantsBody
.
optJSONObject
(
i
));
mMerchantList
.
add
(
temp
Couponse
t
);
Merchant
temp
Merchan
t
=
new
Merchant
(
finalJMerchantsBody
.
optJSONObject
(
i
));
mMerchantList
.
add
(
temp
Merchan
t
);
}
executorCouponsets
.
shutdownNow
();
...
...
@@ -574,15 +643,15 @@ public class WarplyManager {
return
future
;
}
private
static
ArrayList
<
BannerItem
>
mergeCampaignResults
(
ArrayList
<
Campaign
>
resultCampaigns
,
ArrayList
<
Campaign
>
resultPersonalizedCampaigns
,
ArrayList
<
Content
>
resultArticles
)
{
private
static
ArrayList
<
BannerItem
>
mergeCampaignResults
(
ArrayList
<
Campaign
>
resultCampaigns
,
/*ArrayList<Campaign> resultPersonalizedCampaigns,*/
ArrayList
<
Content
>
resultArticles
)
{
ArrayList
<
BannerItem
>
allItems
=
new
ArrayList
<>();
ArrayList
<
Campaign
>
newCampaignList
=
new
ArrayList
<
Campaign
>();
ArrayList
<
Campaign
>
campaignLoyaltyList
=
new
ArrayList
<>();
if
(
resultCampaigns
!=
null
&&
!
resultCampaigns
.
isEmpty
())
newCampaignList
.
addAll
(
resultCampaigns
);
if
(
resultPersonalizedCampaigns
!=
null
&&
!
resultPersonalizedCampaigns
.
isEmpty
())
newCampaignList
.
addAll
(
resultPersonalizedCampaigns
);
//
if (resultPersonalizedCampaigns != null && !resultPersonalizedCampaigns.isEmpty())
//
newCampaignList.addAll(resultPersonalizedCampaigns);
if
(
newCampaignList
!=
null
&&
!
newCampaignList
.
isEmpty
())
{
newCampaignList
.
stream
().
filter
((
item
)
->
item
.
getType
().
equals
(
"contest"
)
||
item
.
getOfferCategory
().
equals
(
"contest"
));
...
...
@@ -616,18 +685,18 @@ public class WarplyManager {
WarpUtils
.
log
(
"**************************************************"
);
ApiService
service
=
ApiClient
.
getRetrofitInstance
().
create
(
ApiService
.
class
);
ListeningExecutorService
executorService
=
MoreExecutors
.
listeningDecorator
(
Executors
.
newFixedThreadPool
(
3
));
ListeningExecutorService
executorService
=
MoreExecutors
.
listeningDecorator
(
Executors
.
newFixedThreadPool
(
2
));
ListenableFuture
<
ArrayList
<
Campaign
>>
futureCampaigns
=
getCampaignsRetro
(
service
);
ListenableFuture
<
ArrayList
<
Campaign
>>
futurePersonalizedCampaigns
=
getCampaignsPersonalizedRetro
(
service
,
0
);
//
ListenableFuture<ArrayList<Campaign>> futurePersonalizedCampaigns = getCampaignsPersonalizedRetro(service, 0);
ListenableFuture
<
ArrayList
<
Content
>>
futureArticles
=
getArticlesRetro
(
service
,
new
JSONArray
().
put
(
"Carousel"
));
ListenableFuture
<
List
<
Object
>>
allResultsFuture
=
Futures
.
allAsList
(
futureCampaigns
,
futurePersonalizedCampaigns
,
futureArticles
);
ListenableFuture
<
List
<
Object
>>
allResultsFuture
=
Futures
.
allAsList
(
futureCampaigns
,
/*futurePersonalizedCampaigns,*/
futureArticles
);
ListenableFuture
<
ArrayList
<
BannerItem
>>
mergedResultFuture
=
Futures
.
transformAsync
(
allResultsFuture
,
results
->
{
ArrayList
<
Campaign
>
resultCampaigns
=
(
ArrayList
<
Campaign
>)
results
.
get
(
0
);
ArrayList
<
Campaign
>
resultPersonalizedCampaigns
=
(
ArrayList
<
Campaign
>)
results
.
get
(
1
);
ArrayList
<
Content
>
resultArticles
=
(
ArrayList
<
Content
>)
results
.
get
(
2
);
return
executorService
.
submit
(()
->
mergeCampaignResults
(
resultCampaigns
,
resultPersonalizedCampaigns
,
resultArticles
));
//
ArrayList<Campaign> resultPersonalizedCampaigns = (ArrayList<Campaign>) results.get(1);
ArrayList
<
Content
>
resultArticles
=
(
ArrayList
<
Content
>)
results
.
get
(
1
);
return
executorService
.
submit
(()
->
mergeCampaignResults
(
resultCampaigns
,
/*resultPersonalizedCampaigns,*/
resultArticles
));
},
executorService
);
Futures
.
addCallback
(
mergedResultFuture
,
new
FutureCallback
<
ArrayList
<
BannerItem
>>()
{
...
...
@@ -689,25 +758,7 @@ public class WarplyManager {
JSONArray
finalCampaignsJBody
=
jCampaignsBody
;
executorCampaigns
.
submit
(()
->
{
for
(
int
i
=
0
;
i
<
finalCampaignsJBody
.
length
();
++
i
)
{
Campaign
camp
=
new
Campaign
();
NewCampaign
tempNewCampaign
=
new
NewCampaign
(
finalCampaignsJBody
.
optJSONObject
(
i
));
camp
.
setIndexUrl
(
tempNewCampaign
.
getCampaignUrl
());
camp
.
setLogoUrl
(
tempNewCampaign
.
getBannerImageMobile
());
camp
.
setMessage
(
tempNewCampaign
.
getMessage
());
camp
.
setOfferCategory
(
tempNewCampaign
.
getCommunicationCategory
());
camp
.
setSessionUUID
(
tempNewCampaign
.
getCommunicationUUID
());
camp
.
setTitle
(
tempNewCampaign
.
getTitle
());
camp
.
setSubtitle
(
tempNewCampaign
.
getSubtitle
());
camp
.
setSorting
(
tempNewCampaign
.
getSorting
());
camp
.
setNew
(
tempNewCampaign
.
getIsNew
());
camp
.
setType
(
tempNewCampaign
.
getCampaignType
());
camp
.
setEndDate
(
tempNewCampaign
.
getEndDate
());
camp
.
setStartDate
(
tempNewCampaign
.
getStartDate
());
camp
.
setShowExpiration
(
tempNewCampaign
.
isShowExpiration
());
camp
.
setCouponImg
(
tempNewCampaign
.
getCouponImg
());
camp
.
setFilter
(
tempNewCampaign
.
getFilter
());
Campaign
camp
=
new
Campaign
(
finalCampaignsJBody
.
optJSONObject
(
i
));
mCampaignsList
.
add
(
camp
);
}
...
...
@@ -784,25 +835,7 @@ public class WarplyManager {
JSONArray
finalCampaignsJBody
=
jCampaignsBody
;
executorPersonalizedCampaigns
.
submit
(()
->
{
for
(
int
i
=
0
;
i
<
finalCampaignsJBody
.
length
();
++
i
)
{
Campaign
camp
=
new
Campaign
();
NewCampaign
tempNewCampaign
=
new
NewCampaign
(
finalCampaignsJBody
.
optJSONObject
(
i
));
camp
.
setIndexUrl
(
tempNewCampaign
.
getCampaignUrl
());
camp
.
setLogoUrl
(
tempNewCampaign
.
getBannerImageMobile
());
camp
.
setMessage
(
tempNewCampaign
.
getMessage
());
camp
.
setOfferCategory
(
tempNewCampaign
.
getCommunicationCategory
());
camp
.
setSessionUUID
(
tempNewCampaign
.
getCommunicationUUID
());
camp
.
setTitle
(
tempNewCampaign
.
getTitle
());
camp
.
setSubtitle
(
tempNewCampaign
.
getSubtitle
());
camp
.
setSorting
(
tempNewCampaign
.
getSorting
());
camp
.
setNew
(
tempNewCampaign
.
getIsNew
());
camp
.
setType
(
tempNewCampaign
.
getCampaignType
());
camp
.
setEndDate
(
tempNewCampaign
.
getEndDate
());
camp
.
setStartDate
(
tempNewCampaign
.
getStartDate
());
camp
.
setShowExpiration
(
tempNewCampaign
.
isShowExpiration
());
camp
.
setCouponImg
(
tempNewCampaign
.
getCouponImg
());
camp
.
setFilter
(
tempNewCampaign
.
getFilter
());
Campaign
camp
=
new
Campaign
(
finalCampaignsJBody
.
optJSONObject
(
i
));
mCampaignsList
.
add
(
camp
);
}
...
...
warply_android_sdk/src/main/res/layout/activity_home.xml
View file @
2b9f74f
...
...
@@ -24,7 +24,8 @@
android:layout_gravity=
"center"
android:background=
"@color/custom_grey_light"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
>
android:paddingHorizontal=
"16dp"
android:paddingVertical=
"16dp"
>
<LinearLayout
android:layout_width=
"0dp"
...
...
@@ -85,12 +86,12 @@
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@android:color/transparent"
app:layout_constraintStart_toStartOf=
"@+id/banner_viewpager"
app:layout_constraintEnd_toEndOf=
"@+id/banner_viewpager"
app:layout_constraintTop_toTopOf=
"@+id/banner_viewpager"
app:layout_constraintBottom_toBottomOf=
"@+id/banner_viewpager"
android:translationZ=
"100dp"
android:visibility=
"gone"
app:layout_constraintBottom_toBottomOf=
"@+id/banner_viewpager"
app:layout_constraintEnd_toEndOf=
"@+id/banner_viewpager"
app:layout_constraintStart_toStartOf=
"@+id/banner_viewpager"
app:layout_constraintTop_toTopOf=
"@+id/banner_viewpager"
tools:visibility=
"visible"
>
<ProgressBar
...
...
@@ -103,374 +104,31 @@
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- Top Offers Section -->
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"24dp"
>
<LinearLayout
android:id=
"@+id/ll_recycler1"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
>
<TextView
android:id=
"@+id/tv_recycler_category1"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:textColor=
"@color/custom_black2"
android:textSize=
"16sp"
tools:text=
"Top Offers (10)"
/>
<TextView
android:id=
"@+id/tv_recycler_all1"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/demo_shape_transparent_border_black"
android:paddingHorizontal=
"16dp"
android:paddingVertical=
"5dp"
android:text=
"@string/demo_all"
android:textColor=
"@color/custom_black3"
android:textSize=
"14sp"
/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rl_recycler1"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_recycler1"
android:layout_marginTop=
"16dp"
android:clipToPadding=
"false"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
/>
</RelativeLayout>
<!-- Favorites Section -->
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"48dp"
>
<LinearLayout
android:id=
"@+id/ll_recycler2"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
>
<TextView
android:id=
"@+id/tv_recycler_category2"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:textColor=
"@color/custom_black2"
android:textSize=
"16sp"
tools:text=
"Favorites (10)"
/>
<TextView
android:id=
"@+id/tv_recycler_all2"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/demo_shape_transparent_border_black"
android:paddingHorizontal=
"16dp"
android:paddingVertical=
"5dp"
android:text=
"@string/demo_all"
android:textColor=
"@color/custom_black3"
android:textSize=
"14sp"
/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rl_recycler2"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_recycler2"
android:layout_marginTop=
"16dp"
android:clipToPadding=
"false"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
/>
</RelativeLayout>
<!-- Viability Section -->
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"48dp"
>
<LinearLayout
android:id=
"@+id/ll_recycler3"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
>
<TextView
android:id=
"@+id/tv_recycler_category3"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:textColor=
"@color/custom_black2"
android:textSize=
"16sp"
tools:text=
"Viability (10)"
/>
<TextView
android:id=
"@+id/tv_recycler_all3"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/demo_shape_transparent_border_black"
android:paddingHorizontal=
"16dp"
android:paddingVertical=
"5dp"
android:text=
"@string/demo_all"
android:textColor=
"@color/custom_black3"
android:textSize=
"14sp"
/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rl_recycler3"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_recycler3"
android:layout_marginTop=
"16dp"
android:clipToPadding=
"false"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
/>
</RelativeLayout>
<!-- Family Section -->
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"48dp"
>
<LinearLayout
android:id=
"@+id/ll_recycler4"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
>
<TextView
android:id=
"@+id/tv_recycler_category4"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:textColor=
"@color/custom_black2"
android:textSize=
"16sp"
tools:text=
"Family (10)"
/>
<TextView
android:id=
"@+id/tv_recycler_all4"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/demo_shape_transparent_border_black"
android:paddingHorizontal=
"16dp"
android:paddingVertical=
"5dp"
android:text=
"@string/demo_all"
android:textColor=
"@color/custom_black3"
android:textSize=
"14sp"
/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rl_recycler4"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_recycler4"
android:layout_marginTop=
"16dp"
android:clipToPadding=
"false"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
/>
</RelativeLayout>
<!-- Food and Coffee Section -->
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"48dp"
>
<LinearLayout
android:id=
"@+id/ll_recycler5"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
>
<TextView
android:id=
"@+id/tv_recycler_category5"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:textColor=
"@color/custom_black2"
android:textSize=
"16sp"
tools:text=
"Food and Coffee (10)"
/>
<TextView
android:id=
"@+id/tv_recycler_all5"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/demo_shape_transparent_border_black"
android:paddingHorizontal=
"16dp"
android:paddingVertical=
"5dp"
android:text=
"@string/demo_all"
android:textColor=
"@color/custom_black3"
android:textSize=
"14sp"
/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rl_recycler5"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_recycler5"
android:layout_marginTop=
"16dp"
android:clipToPadding=
"false"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
/>
</RelativeLayout>
<!-- Travelling Section -->
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"48dp"
>
<LinearLayout
android:id=
"@+id/ll_recycler6"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
>
<TextView
android:id=
"@+id/tv_recycler_category6"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:textColor=
"@color/custom_black2"
android:textSize=
"16sp"
tools:text=
"Travelling (10)"
/>
<TextView
android:id=
"@+id/tv_recycler_all6"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/demo_shape_transparent_border_black"
android:paddingHorizontal=
"16dp"
android:paddingVertical=
"5dp"
android:text=
"@string/demo_all"
android:textColor=
"@color/custom_black3"
android:textSize=
"14sp"
/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rl_recycler6"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_recycler6"
android:layout_marginTop=
"16dp"
android:clipToPadding=
"false"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
/>
</RelativeLayout>
<!-- Kids Section -->
<RelativeLayout
android:id=
"@+id/rl_sections_loading"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"48dp"
>
<LinearLayout
android:id=
"@+id/ll_recycler7"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
>
<TextView
android:id=
"@+id/tv_recycler_category7"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:textColor=
"@color/custom_black2"
android:textSize=
"16sp"
tools:text=
"Kids (10)"
/>
<TextView
android:id=
"@+id/tv_recycler_all7"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/demo_shape_transparent_border_black"
android:paddingHorizontal=
"16dp"
android:paddingVertical=
"5dp"
android:text=
"@string/demo_all"
android:textColor=
"@color/custom_black3"
android:textSize=
"14sp"
/>
</LinearLayout>
android:background=
"@android:color/transparent"
android:layout_marginTop=
"48dp"
android:translationZ=
"100dp"
android:visibility=
"gone"
tools:visibility=
"visible"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rl_recycler7"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_recycler7"
android:layout_marginTop=
"16dp"
android:clipToPadding=
"false"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
/>
<ProgressBar
android:layout_width=
"40dp"
android:layout_height=
"40dp"
android:layout_centerInParent=
"true"
android:indeterminate=
"true"
android:indeterminateTint=
"@color/custom_light_blue"
android:indeterminateTintMode=
"src_atop"
/>
</RelativeLayout>
<
!-- Purchases Section -->
<RelativeLayout
<
LinearLayout
android:id=
"@+id/ll_sections_container"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"48dp"
android:layout_marginBottom=
"48dp"
>
<LinearLayout
android:id=
"@+id/ll_recycler8"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
>
<TextView
android:id=
"@+id/tv_recycler_category8"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:textColor=
"@color/custom_black2"
android:textSize=
"16sp"
tools:text=
"Purchases (10)"
/>
<TextView
android:id=
"@+id/tv_recycler_all8"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/demo_shape_transparent_border_black"
android:paddingHorizontal=
"16dp"
android:paddingVertical=
"5dp"
android:text=
"@string/demo_all"
android:textColor=
"@color/custom_black3"
android:textSize=
"14sp"
/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rl_recycler8"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_recycler8"
android:layout_marginTop=
"16dp"
android:clipToPadding=
"false"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
/>
</RelativeLayout>
android:layout_marginBottom=
"48dp"
android:orientation=
"vertical"
/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
...
...
warply_android_sdk/src/main/res/layout/demo_item_offer.xml
View file @
2b9f74f
...
...
@@ -6,15 +6,12 @@
android:layout_height=
"260dp"
android:background=
"@drawable/demo_shape_white_border_grey"
>
<!-- Main Offer Image -->
<ImageView
android:id=
"@+id/iv_offer_image"
android:layout_width=
"match_parent"
android:layout_height=
"140dp"
android:scaleType=
"centerCrop"
tools:src=
"@drawable/demo_home_banner1"
/>
android:scaleType=
"centerCrop"
/>
<!-- Heart Icon (Favorite) -->
<ImageView
android:id=
"@+id/iv_favorite"
android:layout_width=
"32dp"
...
...
@@ -22,7 +19,6 @@
android:layout_margin=
"8dp"
android:src=
"@drawable/demo_heart"
/>
<!-- Price Badge -->
<TextView
android:id=
"@+id/tv_price"
android:layout_width=
"68dp"
...
...
@@ -35,7 +31,6 @@
android:textSize=
"16sp"
tools:text=
"17,95€"
/>
<!-- Content Section -->
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
...
...
@@ -50,7 +45,6 @@
android:orientation=
"vertical"
app:layout_constraintGuide_percent=
"0.7"
/>
<!-- Title -->
<TextView
android:id=
"@+id/tv_title"
android:layout_width=
"0dp"
...
...
@@ -63,7 +57,6 @@
app:layout_constraintTop_toTopOf=
"parent"
tools:text=
"Móvo 17,95"
/>
<!-- Description -->
<TextView
android:id=
"@+id/tv_description"
android:layout_width=
"0dp"
...
...
@@ -77,7 +70,6 @@
app:layout_constraintTop_toBottomOf=
"@+id/tv_title"
tools:text=
"2 πίτσες & Coca-COLA 1,5lt"
/>
<!-- Validity Date -->
<TextView
android:id=
"@+id/tv_validity"
android:layout_width=
"wrap_content"
...
...
@@ -92,7 +84,6 @@
app:layout_constraintBottom_toBottomOf=
"parent"
tools:text=
"έως 30-09"
/>
<!-- Brand Logo -->
<ImageView
android:id=
"@+id/iv_logo"
android:layout_width=
"60dp"
...
...
@@ -100,7 +91,6 @@
android:layout_alignParentEnd=
"true"
android:layout_centerVertical=
"true"
android:scaleType=
"centerInside"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
tools:src=
"@drawable/demo_avis"
/>
...
...
warply_android_sdk/src/main/res/layout/fragment_home.xml
View file @
2b9f74f
...
...
@@ -43,8 +43,8 @@
android:layout_marginBottom=
"8dp"
android:maxLines=
"1"
android:scrollHorizontally=
"true"
android:text
Color=
"@color/custom_black2
"
android:text
=
"@string/welcome_user
"
/>
android:text
=
"@string/welcome_user
"
android:text
Color=
"@color/custom_black2
"
/>
</RelativeLayout>
<ImageView
...
...
@@ -83,7 +83,8 @@
android:layout_marginHorizontal=
"8dp"
android:layout_marginTop=
"24dp"
android:layout_marginBottom=
"16dp"
android:background=
"@drawable/shape_rectangle_rounded_white"
>
android:background=
"@drawable/shape_rectangle_rounded_white"
android:visibility=
"gone"
>
<LinearLayout
android:id=
"@+id/ll_sm_flow"
...
...
@@ -94,7 +95,8 @@
android:layout_marginStart=
"16dp"
android:background=
"@drawable/selector_button_light_blue"
android:gravity=
"center"
android:orientation=
"horizontal"
>
android:orientation=
"horizontal"
android:visibility=
"gone"
>
<TextView
android:layout_width=
"wrap_content"
...
...
@@ -107,5 +109,40 @@
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id=
"@+id/ll_login_view"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/rl_header"
android:layout_marginTop=
"24dp"
android:paddingHorizontal=
"24dp"
android:orientation=
"vertical"
>
<EditText
android:id=
"@+id/et_login"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:inputType=
"textEmailAddress"
android:text=
"p.anagnostou+1201@dei.gr"
/>
<LinearLayout
android:id=
"@+id/ll_login"
android:layout_width=
"match_parent"
android:layout_height=
"45dp"
android:layout_marginTop=
"16dp"
android:background=
"@drawable/selector_button_light_blue"
android:gravity=
"center"
android:orientation=
"horizontal"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:gravity=
"center"
android:includeFontPadding=
"false"
android:text=
"@string/demo_login"
android:textColor=
"@color/white"
android:textSize=
"16sp"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
...
...
warply_android_sdk/src/main/res/layout/item_couponset_section.xml
0 → 100644
View file @
2b9f74f
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"48dp"
>
<LinearLayout
android:id=
"@+id/ll_section_header"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"center"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
>
<TextView
android:id=
"@+id/tv_section_title"
android:layout_width=
"0dp"
android:layout_height=
"wrap_content"
android:layout_weight=
"1"
android:textColor=
"@color/custom_black2"
android:textSize=
"16sp"
tools:text=
"Top Offers (10)"
/>
<TextView
android:id=
"@+id/tv_section_all"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:background=
"@drawable/demo_shape_transparent_border_black"
android:paddingHorizontal=
"16dp"
android:paddingVertical=
"5dp"
android:text=
"@string/demo_all"
android:textColor=
"@color/custom_black3"
android:textSize=
"14sp"
/>
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_section_list"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@+id/ll_section_header"
android:layout_marginTop=
"16dp"
android:clipToPadding=
"false"
android:orientation=
"horizontal"
android:paddingHorizontal=
"16dp"
/>
</RelativeLayout>
warply_android_sdk/src/main/res/values/strings.xml
View file @
2b9f74f
...
...
@@ -6,6 +6,7 @@
<string
name=
"welcome_user"
>
User
</string>
<string
name=
"menu_home"
>
Αρχική
</string>
<string
name=
"demo_home"
>
Αρχική οθόνη
</string>
<string
name=
"demo_login"
>
Σύνδεση
</string>
<string
name=
"demo_all"
>
Όλα
</string>
<string
name=
"demo_offer"
>
Προσφορά
</string>
<string
name=
"demo_more"
>
Περισσότερα
</string>
...
...
Please
register
or
login
to post a comment