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
2024-10-22 11:47:19 +0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6aa99da00003930c5bcb5ddedf741d7b99f88443
6aa99da0
1 parent
d5fbc3da
unified screen basket part6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
106 additions
and
17 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/activities/CouponInfoActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/activities/UnifiedCouponInfoActivity.java
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Couponset.java
warply_android_sdk/src/main/res/drawable-xhdpi/ic_merchant_ab.png
warply_android_sdk/src/main/res/drawable-xhdpi/ic_merchant_masoutis.png
warply_android_sdk/src/main/res/layout/item_sheet_merchant.xml
warply_android_sdk/src/main/java/ly/warp/sdk/activities/CouponInfoActivity.java
View file @
6aa99da
...
...
@@ -43,6 +43,7 @@ import java.util.Date;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.io.models.Coupon
;
import
ly.warp.sdk.io.models.Couponset
;
import
ly.warp.sdk.io.models.Merchant
;
import
ly.warp.sdk.io.models.UnifiedCoupon
;
import
ly.warp.sdk.services.EventCouponsService
;
import
ly.warp.sdk.utils.WarpUtils
;
...
...
@@ -113,6 +114,14 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
for
(
Coupon
cpn
:
WarplyManagerHelper
.
getSmCouponsList
())
{
if
(
cpn
.
getCoupon
().
equals
(
couponCode
))
{
mCoupon
=
cpn
;
for
(
Couponset
cpns
:
WarplyManagerHelper
.
getCouponsetsDeals
())
{
if
(
cpns
.
getUuid
().
equals
(
mCoupon
.
getCouponsetUuid
()))
{
mCoupon
.
setCouponsetDetails
(
cpns
);
break
;
}
}
break
;
}
}
...
...
@@ -288,8 +297,17 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
if
(!
mIsFindItPressed
)
{
mIsFindItPressed
=
true
;
//TODO: add check to open the sheet only if there are available merchants
showChooseMerchantDialog
();
JSONObject
extraFields
=
mCoupon
.
getCouponsetDetails
().
getExtraFields
();
if
(
extraFields
!=
null
&&
extraFields
.
has
(
"shop_availability"
))
{
try
{
JSONArray
shopAvailability
=
new
JSONArray
(
extraFields
.
optString
(
"shop_availability"
));
if
(
shopAvailability
.
length
()
>
0
)
{
showChooseMerchantDialog
(
shopAvailability
);
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
}
}
}
}
...
...
@@ -298,7 +316,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
// Methods
// ===========================================================
private
void
showChooseMerchantDialog
()
{
private
void
showChooseMerchantDialog
(
JSONArray
shopAvailability
)
{
final
BottomSheetDialog
bottomSheetDialog
=
new
BottomSheetDialog
(
this
,
R
.
style
.
BottomSheetDialog
);
bottomSheetDialog
.
setContentView
(
R
.
layout
.
dl_bottom_sheet_merchants
);
bottomSheetDialog
.
setOnDismissListener
(
dialog
->
{
...
...
@@ -317,20 +335,46 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
mIsFindItPressed
=
false
;
});
int
tempLoop
=
2
;
for
(
int
i
=
0
;
i
<
tempLoop
;
i
++)
{
for
(
int
i
=
0
;
i
<
shopAvailability
.
length
();
i
++)
{
int
tempIndex
=
i
;
String
productUrl
=
""
;
String
merchantUuid
=
""
;
Merchant
tempMerchant
=
new
Merchant
();
try
{
JSONObject
extraFieldsByItem
=
(
JSONObject
)
shopAvailability
.
get
(
tempIndex
);
productUrl
=
extraFieldsByItem
.
optString
(
"product_url"
);
merchantUuid
=
extraFieldsByItem
.
optString
(
"merchant_uuid"
);
for
(
Merchant
merc
:
WarplyManagerHelper
.
getMerchantList
())
{
if
(
merc
.
getUuid
().
equals
(
merchantUuid
))
{
tempMerchant
=
merc
;
break
;
}
}
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
String
finalProductUrl
=
productUrl
;
LayoutInflater
vi
=
(
LayoutInflater
)
getApplicationContext
().
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
LinearLayout
v
=
(
LinearLayout
)
vi
.
inflate
(
R
.
layout
.
item_sheet_merchant
,
null
);
TextView
textView
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
button_sm_buy_it
);
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
peridot_semi_bold
,
textView
);
ImageView
merchantLogo
=
(
ImageView
)
v
.
findViewById
(
R
.
id
.
iv_merchant_sheet_logo
);
Glide
.
with
(
this
)
.
load
(
tempMerchant
.
getImgPreview
())
.
diskCacheStrategy
(
DiskCacheStrategy
.
DATA
)
.
into
(
merchantLogo
);
ConstraintLayout
buyButton
=
(
ConstraintLayout
)
v
.
findViewById
(
R
.
id
.
cl_button_sm_buy_it
);
buyButton
.
setOnClickListener
(
view
->
{
//TODO: open webview with the specified url
bottomSheetDialog
.
dismiss
();
if
(!
TextUtils
.
isEmpty
(
finalProductUrl
))
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
this
,
finalProductUrl
));
});
parent
.
addView
(
v
,
0
,
new
ViewGroup
.
LayoutParams
(
parent
.
addView
(
v
,
tempIndex
,
new
ViewGroup
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
));
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/activities/UnifiedCouponInfoActivity.java
View file @
6aa99da
...
...
@@ -20,6 +20,7 @@ import androidx.core.content.ContextCompat;
import
androidx.recyclerview.widget.LinearLayoutManager
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.bumptech.glide.Glide
;
import
com.google.android.gms.common.ConnectionResult
;
import
com.google.android.gms.common.GoogleApiAvailability
;
import
com.google.android.material.bottomsheet.BottomSheetDialog
;
...
...
@@ -28,6 +29,9 @@ import com.google.zxing.common.BitMatrix;
import
com.google.zxing.oned.EAN13Writer
;
import
org.greenrobot.eventbus.EventBus
;
import
org.json.JSONArray
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
...
...
@@ -38,6 +42,7 @@ import ly.warp.sdk.R;
import
ly.warp.sdk.io.callbacks.CallbackReceiver
;
import
ly.warp.sdk.io.models.Coupon
;
import
ly.warp.sdk.io.models.CouponList
;
import
ly.warp.sdk.io.models.Merchant
;
import
ly.warp.sdk.io.models.RefreshUnifiedCouponsEventModel
;
import
ly.warp.sdk.io.models.UnifiedCoupon
;
import
ly.warp.sdk.utils.WarpUtils
;
...
...
@@ -70,6 +75,7 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
private
RecyclerView
mRecyclerCoupons
;
private
ActiveCouponAdapter
mAdapterCoupons
;
private
AlertDialog
mErrorAlertDialog
,
mSuccessAlertDialog
,
mAskCancelUnifiedAlertDialog
;
private
JSONArray
mBottomSheetData
;
// ===========================================================
// Methods for/from SuperClass/Interfaces
...
...
@@ -143,7 +149,7 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
return
;
}
if
(
view
.
getId
()
==
R
.
id
.
ll_shops
)
{
showChooseCategoryDialog
();
showChoose
Merchant
CategoryDialog
();
}
if
(
view
.
getId
()
==
R
.
id
.
ll_terms_inner
)
{
if
(
mIsTermsShown
)
{
...
...
@@ -182,7 +188,7 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
// Methods
// ===========================================================
private
void
showChooseCategoryDialog
()
{
private
void
showChoose
Merchant
CategoryDialog
()
{
final
BottomSheetDialog
bottomSheetDialog
=
new
BottomSheetDialog
(
this
,
R
.
style
.
BottomSheetDialog
);
bottomSheetDialog
.
setContentView
(
R
.
layout
.
dl_bottom_sheet_categories
);
bottomSheetDialog
.
setOnDismissListener
(
dialog
->
bottomSheetDialog
.
dismiss
());
...
...
@@ -233,23 +239,57 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
ImageView
dialogClose
=
(
ImageView
)
bottomSheetDialog
.
findViewById
(
R
.
id
.
iv_sm_sheet_close
);
dialogClose
.
setOnClickListener
(
view
->
bottomSheetDialog
.
dismiss
());
int
tempLoop
=
2
;
for
(
int
i
=
0
;
i
<
tempLoop
;
i
++)
{
JSONObject
tempObject
=
new
JSONObject
();
mBottomSheetData
=
new
JSONArray
();
try
{
tempObject
.
put
(
"merchant_key"
,
"ab"
);
tempObject
.
put
(
"merchant_url"
,
"https://www.ab.gr"
);
mBottomSheetData
.
put
(
tempObject
);
tempObject
=
new
JSONObject
();
tempObject
.
put
(
"merchant_key"
,
"masoutis"
);
tempObject
.
put
(
"merchant_url"
,
"https://www.masoutis.gr"
);
mBottomSheetData
.
put
(
tempObject
);
}
catch
(
JSONException
e
)
{
throw
new
RuntimeException
(
e
);
}
for
(
int
i
=
0
;
i
<
mBottomSheetData
.
length
();
i
++)
{
int
tempIndex
=
i
;
String
merchantUrl
=
""
;
String
merchantKey
=
""
;
try
{
JSONObject
bottomSheetData
=
(
JSONObject
)
mBottomSheetData
.
get
(
tempIndex
);
merchantUrl
=
bottomSheetData
.
optString
(
"merchant_url"
);
merchantKey
=
bottomSheetData
.
optString
(
"merchant_key"
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
String
finalMerchantUrl
=
merchantUrl
;
LayoutInflater
vi
=
(
LayoutInflater
)
getApplicationContext
().
getSystemService
(
Context
.
LAYOUT_INFLATER_SERVICE
);
LinearLayout
v
=
(
LinearLayout
)
vi
.
inflate
(
R
.
layout
.
item_sheet_merchant
,
null
);
TextView
textView
=
(
TextView
)
v
.
findViewById
(
R
.
id
.
button_sm_buy_it
);
textView
.
setText
(
R
.
string
.
cos_markets_eshop_item
);
WarpUtils
.
renderCustomFont
(
this
,
R
.
font
.
peridot_semi_bold
,
textView
);
ImageView
buttonIcon
=
(
ImageView
)
v
.
findViewById
(
R
.
id
.
iv_sheet_cart
);
buttonIcon
.
setVisibility
(
View
.
GONE
);
ImageView
buttonIcon
=
(
ImageView
)
v
.
findViewById
(
R
.
id
.
iv_merchant_sheet_logo
);
if
(
merchantKey
.
equals
(
"ab"
))
{
Glide
.
with
(
this
)
.
load
(
R
.
drawable
.
ic_merchant_ab
)
.
into
(
buttonIcon
);
}
else
if
(
merchantKey
.
equals
(
"masoutis"
))
{
Glide
.
with
(
this
)
.
load
(
R
.
drawable
.
ic_merchant_masoutis
)
.
into
(
buttonIcon
);
}
ConstraintLayout
buyButton
=
(
ConstraintLayout
)
v
.
findViewById
(
R
.
id
.
cl_button_sm_buy_it
);
buyButton
.
setOnClickListener
(
view
->
{
//TODO: open webview with the specified url
bottomSheetDialog
.
dismiss
();
startActivity
(
WarpViewActivity
.
createIntentFromURL
(
this
,
finalMerchantUrl
));
});
parent
.
addView
(
v
,
0
,
new
ViewGroup
.
LayoutParams
(
parent
.
addView
(
v
,
tempIndex
,
new
ViewGroup
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
WRAP_CONTENT
));
}
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/io/models/Couponset.java
View file @
6aa99da
...
...
@@ -223,7 +223,10 @@ public class Couponset implements Parcelable, Serializable {
this
.
innerText
=
json
.
optString
(
INNER_TEXT
);
this
.
discount_type
=
json
.
isNull
(
DISCOUNT_TYPE
)
?
""
:
json
.
optString
(
DISCOUNT_TYPE
);
this
.
final_price
=
json
.
isNull
(
FINAL_PRICE
)
?
0.0d
:
json
.
optDouble
(
FINAL_PRICE
);
this
.
extraFields
=
json
.
optJSONObject
(
EXTRA_FIELDS
);
// this.extraFields = json.optJSONObject(EXTRA_FIELDS);
JSONObject
ef
=
null
;
ef
=
json
.
optJSONObject
(
EXTRA_FIELDS
);
this
.
extraFields
=
ef
;
}
}
...
...
warply_android_sdk/src/main/res/drawable-xhdpi/ic_merchant_ab.png
0 → 100644
View file @
6aa99da
6.71 KB
warply_android_sdk/src/main/res/drawable-xhdpi/ic_merchant_masoutis.png
0 → 100644
View file @
6aa99da
5.45 KB
warply_android_sdk/src/main/res/layout/item_sheet_merchant.xml
View file @
6aa99da
...
...
@@ -3,6 +3,7 @@
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
xmlns:tools=
"http://schemas.android.com/tools"
android:background=
"@android:color/white"
>
<androidx.constraintlayout.widget.ConstraintLayout
...
...
@@ -12,10 +13,11 @@
android:background=
"@drawable/shape_cos_sheet_item"
>
<ImageView
android:id=
"@+id/iv_merchant_sheet_logo"
android:layout_width=
"140dp"
android:layout_height=
"36dp"
android:layout_marginStart=
"24dp"
android:background=
"@color/blue_dark
"
tools:src=
"@drawable/cosmote_insurance_logo
"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
/>
...
...
Please
register
or
login
to post a comment