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
thkouk00
2022-03-23 15:16:06 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
4a732c8daaa595da68c42c1cee5c2159a646340c
4a732c8d
1 parent
3df6c07e
home campaigns recycler v1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
143 additions
and
8 deletions
warply_android_sdk/src/main/java/ly/warp/sdk/fragments/HomeFragment.java
warply_android_sdk/src/main/java/ly/warp/sdk/views/adapters/HomeCampaignAdapter.java
warply_android_sdk/src/main/res/layout/carousel_item.xml
warply_android_sdk/src/main/res/layout/fragment_home.xml
warply_android_sdk/src/main/java/ly/warp/sdk/fragments/HomeFragment.java
View file @
4a732c8
...
...
@@ -17,17 +17,20 @@ import androidx.recyclerview.widget.RecyclerView;
import
org.json.JSONException
;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.views.adapters.HomeCampaignAdapter
;
import
ly.warp.sdk.views.adapters.HomeCouponAdapter
;
import
ly.warp.sdk.activities.WarpViewActivity
;
import
ly.warp.sdk.io.models.Coupon
;
import
ly.warp.sdk.io.models.CouponList
;
import
ly.warp.sdk.views.adapters.ProfileCampaignAdapter
;
import
ly.warp.sdk.io.models.Campaign
;
import
ly.warp.sdk.io.models.CampaignList
;
public
class
HomeFragment
extends
Fragment
{
private
RelativeLayout
mOptionOne
,
mOptionTwo
,
mOptionThree
;
private
RecyclerView
mRecyclerCoupons
;
private
RecyclerView
mRecyclerC
ampaigns
,
mRecyclerC
oupons
;
private
HomeCouponAdapter
mAdapterCoupons
;
private
HomeCampaignAdapter
mAdapterCampaigns
;
@Override
public
View
onCreateView
(
...
...
@@ -73,7 +76,32 @@ public class HomeFragment extends Fragment {
mOptionThreeText
.
setText
(
"1"
);
mOptionThreeImage
.
setImageResource
(
R
.
drawable
.
tv_option
);
/********* TEST DATA **********/
/********* TEST CAMPAIGNS DATA **********/
CampaignList
clistCampaigns
=
new
CampaignList
();
try
{
clistCampaigns
.
add
(
new
Campaign
(
"{\"session_uuid\": \"a724e911a71a42408b6ba50ae6c08dbb\", \"title\": \"\\u039a\\u03ac\\u03bd\\u03b5 strike\", \"subtitle\": \"\\u03ba\\u03b1\\u03b9 \\u03ba\\u03ad\\u03c1\\u03b4\\u03b9\\u03c3\\u03b5!\", \"offer_message\": null, \"message\": null, \"index_url\": \"https://warply.s3.amazonaws.com/artworks/034fba10ceac4e0f9338bd8e60086292/index.html\", \"logo_url\": \"https://warply.s3.amazonaws.com/temp/96322898cc824981aece923d8b5afc88/drggtdr.jpg\", \"starts\": 1644494400, \"expires\": 1881522000, \"delivered\": 1644607293, \"action\": 0, \"opened\": 1, \"offer_category\": \"standard-offer\", \"sorting\": 0, \"is_new\": true, \"session_metadata\": \"\\\"\\\"\", \"display_type\": null, \"delivery_method\": 2, \"extra_fields\": \"{}\", \"campaign_type\": null, \"campaign_type_settings\": null, \"actions\": null, \"show\": true, \"expired\": false, \"audience\": \"all\"}"
));
clistCampaigns
.
add
(
new
Campaign
(
"{\"session_uuid\": \"a724e911a71a42408b6ba50ae6c08dbb\", \"title\": \"\\u039a\\u03ac\\u03bd\\u03b5 strike\", \"subtitle\": \"\\u03ba\\u03b1\\u03b9 \\u03ba\\u03ad\\u03c1\\u03b4\\u03b9\\u03c3\\u03b5!\", \"offer_message\": null, \"message\": null, \"index_url\": \"https://warply.s3.amazonaws.com/artworks/034fba10ceac4e0f9338bd8e60086292/index.html\", \"logo_url\": \"https://warply.s3.amazonaws.com/temp/96322898cc824981aece923d8b5afc88/drggtdr.jpg\", \"starts\": 1644494400, \"expires\": 1881522000, \"delivered\": 1644607293, \"action\": 0, \"opened\": 1, \"offer_category\": \"standard-offer\", \"sorting\": 0, \"is_new\": true, \"session_metadata\": \"\\\"\\\"\", \"display_type\": null, \"delivery_method\": 2, \"extra_fields\": \"{}\", \"campaign_type\": null, \"campaign_type_settings\": null, \"actions\": null, \"show\": true, \"expired\": false, \"audience\": \"all\"}"
));
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
/********* TEST CAMPAIGNS DATA **********/
mRecyclerCampaigns
=
view
.
findViewById
(
R
.
id
.
rv_home_campaigns
);
mRecyclerCampaigns
.
setLayoutManager
(
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
HORIZONTAL
,
false
));
mAdapterCampaigns
=
new
HomeCampaignAdapter
(
getContext
(),
clistCampaigns
);
mRecyclerCampaigns
.
setAdapter
(
mAdapterCampaigns
);
mAdapterCampaigns
.
getPositionClicks
()
.
doOnNext
(
campaign
->
{
getContext
().
startActivity
(
WarpViewActivity
.
createIntentFromSessionUUID
(
getContext
(),
campaign
.
getSessionUUID
()));
})
.
doOnError
(
error
->
{
})
.
subscribe
();
/********* TEST COUPONS DATA **********/
CouponList
clist
=
new
CouponList
();
try
{
clist
.
add
(
new
Coupon
(
"{\"barcode\": \"a724e911a71a42408b6ba50ae6c08dbb\", \"coupon\": \"123456789\", \"name\": \"\\u039a\\u03ac\\u03bd\\u03b5 strike\", \"description\": \"\\u03ba\\u03b1\\u03b9 \\u03ba\\u03ad\\u03c1\\u03b4\\u03b9\\u03c3\\u03b5!\", \"image\": \"https://warply.s3.amazonaws.com/artworks/034fba10ceac4e0f9338bd8e60086292/index.html\"}"
));
...
...
@@ -81,7 +109,7 @@ public class HomeFragment extends Fragment {
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
/********* TEST DATA **********/
/********* TEST
COUPONS
DATA **********/
mRecyclerCoupons
=
view
.
findViewById
(
R
.
id
.
rv_home_coupons
);
mRecyclerCoupons
.
setLayoutManager
(
new
LinearLayoutManager
(
getContext
(),
LinearLayoutManager
.
HORIZONTAL
,
false
));
...
...
warply_android_sdk/src/main/java/ly/warp/sdk/views/adapters/HomeCampaignAdapter.java
0 → 100644
View file @
4a732c8
package
ly
.
warp
.
sdk
.
views
.
adapters
;
import
android.content.Context
;
import
android.text.TextUtils
;
import
android.view.LayoutInflater
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.widget.ImageView
;
import
android.widget.TextView
;
import
androidx.recyclerview.widget.RecyclerView
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
io.reactivex.Observable
;
import
io.reactivex.subjects.PublishSubject
;
import
ly.warp.sdk.R
;
import
ly.warp.sdk.io.models.Campaign
;
import
ly.warp.sdk.io.models.CampaignList
;
public
class
HomeCampaignAdapter
extends
RecyclerView
.
Adapter
<
HomeCampaignAdapter
.
HomeCampaignViewHolder
>
{
private
Context
mContext
;
private
CampaignList
mCampaigns
;
private
final
PublishSubject
<
Campaign
>
onClickSubject
=
PublishSubject
.
create
();
public
HomeCampaignAdapter
(
Context
mContext
,
CampaignList
campaignList
)
{
this
.
mContext
=
mContext
;
this
.
mCampaigns
=
campaignList
;
}
public
class
HomeCampaignViewHolder
extends
RecyclerView
.
ViewHolder
{
private
ImageView
ivCampaignTitle
;
private
TextView
tvCampaignTitle
;
public
HomeCampaignViewHolder
(
View
view
)
{
super
(
view
);
ivCampaignTitle
=
view
.
findViewById
(
R
.
id
.
iv_campaign_logo
);
tvCampaignTitle
=
view
.
findViewById
(
R
.
id
.
tv_campaign_title
);
}
}
@Override
public
int
getItemCount
()
{
if
(
mCampaigns
==
null
)
return
0
;
else
return
mCampaigns
.
size
();
}
public
Campaign
getItem
(
int
id
)
{
return
mCampaigns
.
get
(
id
);
}
public
void
updateData
(
CampaignList
campaignList
)
{
mCampaigns
.
clear
();
mCampaigns
.
addAll
(
campaignList
);
notifyDataSetChanged
();
}
@Override
public
HomeCampaignViewHolder
onCreateViewHolder
(
ViewGroup
parent
,
int
viewType
)
{
View
itemView
=
LayoutInflater
.
from
(
parent
.
getContext
()).
inflate
(
R
.
layout
.
carousel_item
,
parent
,
false
);
return
new
HomeCampaignViewHolder
(
itemView
);
}
@Override
public
void
onBindViewHolder
(
final
HomeCampaignViewHolder
holder
,
int
position
)
{
Campaign
campaignItem
=
mCampaigns
.
get
(
position
);
// if (campaignItem != null) {
// if (!TextUtils.isEmpty(campaignItem.getLogoUrl())) {
// Glide.with(mContext)
//// .setDefaultRequestOptions(
//// RequestOptions
//// .placeholderOf(R.drawable.ic_default_contact_photo)
//// .error(R.drawable.ic_default_contact_photo))
// .load(campaignItem.getLogoUrl())
// .diskCacheStrategy(DiskCacheStrategy.DATA)
// .into(holder.ivCampaignTitle);
// } else {
// Glide.with(mContext)
// .load(R.drawable.ic_cosmote_logo_horizontal_grey)
// .into(holder.ivCampaignTitle);
// }
//
// holder.tvCampaignTitle.setText(campaignItem.getTitle());
//
// holder.itemView.setOnClickListener(v -> onClickSubject.onNext(campaignItem));
// }
}
public
Observable
<
Campaign
>
getPositionClicks
()
{
return
onClickSubject
.
cache
();
}
}
warply_android_sdk/src/main/res/layout/carousel_item.xml
View file @
4a732c8
...
...
@@ -4,6 +4,7 @@
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"240dp"
android:layout_marginLeft=
"10dp"
android:background=
"@drawable/bottom_border"
>
<LinearLayout
...
...
warply_android_sdk/src/main/res/layout/fragment_home.xml
View file @
4a732c8
...
...
@@ -92,10 +92,15 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_below=
"@id/rl_header"
android:layout_marginTop=
"16dp"
android:paddingHorizontal=
"16dp"
>
<include
layout=
"@layout/carousel_item"
/>
android:layout_marginTop=
"16dp"
>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/rv_home_campaigns"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginBottom=
"8dp"
android:clipToPadding=
"false"
android:orientation=
"horizontal"
android:paddingEnd=
"10dp"
/>
</RelativeLayout>
<LinearLayout
...
...
Please
register
or
login
to post a comment