Panagiotis Triantafyllou

Merge remote-tracking branch 'origin/cosmote' into cosmote

...@@ -17,17 +17,20 @@ import androidx.recyclerview.widget.RecyclerView; ...@@ -17,17 +17,20 @@ import androidx.recyclerview.widget.RecyclerView;
17 import org.json.JSONException; 17 import org.json.JSONException;
18 18
19 import ly.warp.sdk.R; 19 import ly.warp.sdk.R;
20 +import ly.warp.sdk.views.adapters.HomeCampaignAdapter;
20 import ly.warp.sdk.views.adapters.HomeCouponAdapter; 21 import ly.warp.sdk.views.adapters.HomeCouponAdapter;
21 import ly.warp.sdk.activities.WarpViewActivity; 22 import ly.warp.sdk.activities.WarpViewActivity;
22 import ly.warp.sdk.io.models.Coupon; 23 import ly.warp.sdk.io.models.Coupon;
23 import ly.warp.sdk.io.models.CouponList; 24 import ly.warp.sdk.io.models.CouponList;
24 -import ly.warp.sdk.views.adapters.ProfileCampaignAdapter; 25 +import ly.warp.sdk.io.models.Campaign;
26 +import ly.warp.sdk.io.models.CampaignList;
25 27
26 public class HomeFragment extends Fragment { 28 public class HomeFragment extends Fragment {
27 29
28 private RelativeLayout mOptionOne, mOptionTwo, mOptionThree; 30 private RelativeLayout mOptionOne, mOptionTwo, mOptionThree;
29 - private RecyclerView mRecyclerCoupons; 31 + private RecyclerView mRecyclerCampaigns, mRecyclerCoupons;
30 private HomeCouponAdapter mAdapterCoupons; 32 private HomeCouponAdapter mAdapterCoupons;
33 + private HomeCampaignAdapter mAdapterCampaigns;
31 34
32 @Override 35 @Override
33 public View onCreateView( 36 public View onCreateView(
...@@ -73,15 +76,40 @@ public class HomeFragment extends Fragment { ...@@ -73,15 +76,40 @@ public class HomeFragment extends Fragment {
73 mOptionThreeText.setText("1"); 76 mOptionThreeText.setText("1");
74 mOptionThreeImage.setImageResource(R.drawable.tv_option); 77 mOptionThreeImage.setImageResource(R.drawable.tv_option);
75 78
76 - /********* TEST DATA **********/ 79 + /********* TEST CAMPAIGNS DATA **********/
80 + CampaignList clistCampaigns = new CampaignList();
81 + try {
82 + 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\"}"));
83 + 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\"}"));
84 + } catch (JSONException e) {
85 + e.printStackTrace();
86 + }
87 + /********* TEST CAMPAIGNS DATA **********/
88 +
89 + mRecyclerCampaigns = view.findViewById(R.id.rv_home_campaigns);
90 + mRecyclerCampaigns.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
91 + mAdapterCampaigns = new HomeCampaignAdapter(getContext(), clistCampaigns);
92 + mRecyclerCampaigns.setAdapter(mAdapterCampaigns);
93 + mAdapterCampaigns.getPositionClicks()
94 + .doOnNext(campaign -> {
95 + getContext().startActivity(
96 + WarpViewActivity.createIntentFromSessionUUID(getContext(),
97 + campaign.getSessionUUID()));
98 + })
99 + .doOnError(error -> {
100 + })
101 + .subscribe();
102 +
103 +
104 + /********* TEST COUPONS DATA **********/
77 CouponList clist = new CouponList(); 105 CouponList clist = new CouponList();
78 try { 106 try {
79 - clist.add(new Coupon("{\"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\"}")); 107 + 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\"}"));
80 - clist.add(new Coupon("{\"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\"}")); 108 + clist.add(new Coupon("{\"barcode\": \"a724e911a71a42408b6ba50ae6c08dbb\", \"coupon\": \"12345678910\", \"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 } catch (JSONException e) { 109 } catch (JSONException e) {
82 e.printStackTrace(); 110 e.printStackTrace();
83 } 111 }
84 - /********* TEST DATA **********/ 112 + /********* TEST COUPONS DATA **********/
85 113
86 mRecyclerCoupons = view.findViewById(R.id.rv_home_coupons); 114 mRecyclerCoupons = view.findViewById(R.id.rv_home_coupons);
87 mRecyclerCoupons.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false)); 115 mRecyclerCoupons.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
...@@ -91,7 +119,7 @@ public class HomeFragment extends Fragment { ...@@ -91,7 +119,7 @@ public class HomeFragment extends Fragment {
91 .doOnNext(coupon -> { 119 .doOnNext(coupon -> {
92 getContext().startActivity( 120 getContext().startActivity(
93 WarpViewActivity.createIntentFromSessionUUID(getContext(), 121 WarpViewActivity.createIntentFromSessionUUID(getContext(),
94 - coupon.getSessionUUID())); 122 + coupon.getCoupon()));
95 }) 123 })
96 .doOnError(error -> { 124 .doOnError(error -> {
97 }) 125 })
......
1 +package ly.warp.sdk.views.adapters;
2 +
3 +import android.content.Context;
4 +import android.text.TextUtils;
5 +import android.view.LayoutInflater;
6 +import android.view.View;
7 +import android.view.ViewGroup;
8 +import android.widget.ImageView;
9 +import android.widget.TextView;
10 +
11 +import androidx.recyclerview.widget.RecyclerView;
12 +
13 +import com.bumptech.glide.Glide;
14 +import com.bumptech.glide.load.engine.DiskCacheStrategy;
15 +
16 +import io.reactivex.Observable;
17 +import io.reactivex.subjects.PublishSubject;
18 +import ly.warp.sdk.R;
19 +import ly.warp.sdk.io.models.Campaign;
20 +import ly.warp.sdk.io.models.CampaignList;
21 +
22 +
23 +public class HomeCampaignAdapter extends RecyclerView.Adapter<HomeCampaignAdapter.HomeCampaignViewHolder> {
24 +
25 + private Context mContext;
26 + private CampaignList mCampaigns;
27 + private final PublishSubject<Campaign> onClickSubject = PublishSubject.create();
28 +
29 + public HomeCampaignAdapter(Context mContext, CampaignList campaignList) {
30 + this.mContext = mContext;
31 + this.mCampaigns = campaignList;
32 + }
33 +
34 + public class HomeCampaignViewHolder extends RecyclerView.ViewHolder {
35 + private ImageView ivCampaignTitle;
36 + private TextView tvCampaignTitle;
37 +
38 + public HomeCampaignViewHolder(View view) {
39 + super(view);
40 + ivCampaignTitle = view.findViewById(R.id.iv_campaign_logo);
41 + tvCampaignTitle = view.findViewById(R.id.tv_campaign_title);
42 + }
43 + }
44 +
45 + @Override
46 + public int getItemCount() {
47 + if (mCampaigns == null)
48 + return 0;
49 + else
50 + return mCampaigns.size();
51 + }
52 +
53 +
54 + public Campaign getItem(int id) {
55 + return mCampaigns.get(id);
56 + }
57 +
58 + public void updateData(CampaignList campaignList) {
59 + mCampaigns.clear();
60 + mCampaigns.addAll(campaignList);
61 + notifyDataSetChanged();
62 + }
63 +
64 +
65 + @Override
66 + public HomeCampaignViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
67 + View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.carousel_item, parent, false);
68 + return new HomeCampaignViewHolder(itemView);
69 + }
70 +
71 + @Override
72 + public void onBindViewHolder(final HomeCampaignViewHolder holder, int position) {
73 + Campaign campaignItem = mCampaigns.get(position);
74 +
75 +// if (campaignItem != null) {
76 +// if (!TextUtils.isEmpty(campaignItem.getLogoUrl())) {
77 +// Glide.with(mContext)
78 +//// .setDefaultRequestOptions(
79 +//// RequestOptions
80 +//// .placeholderOf(R.drawable.ic_default_contact_photo)
81 +//// .error(R.drawable.ic_default_contact_photo))
82 +// .load(campaignItem.getLogoUrl())
83 +// .diskCacheStrategy(DiskCacheStrategy.DATA)
84 +// .into(holder.ivCampaignTitle);
85 +// } else {
86 +// Glide.with(mContext)
87 +// .load(R.drawable.ic_cosmote_logo_horizontal_grey)
88 +// .into(holder.ivCampaignTitle);
89 +// }
90 +//
91 +// holder.tvCampaignTitle.setText(campaignItem.getTitle());
92 +//
93 +// holder.itemView.setOnClickListener(v -> onClickSubject.onNext(campaignItem));
94 +// }
95 + }
96 +
97 + public Observable<Campaign> getPositionClicks() {
98 + return onClickSubject.cache();
99 + }
100 +
101 +}
...@@ -31,13 +31,13 @@ public class HomeCouponAdapter extends RecyclerView.Adapter<HomeCouponAdapter.Ho ...@@ -31,13 +31,13 @@ public class HomeCouponAdapter extends RecyclerView.Adapter<HomeCouponAdapter.Ho
31 } 31 }
32 32
33 public class HomeCouponViewHolder extends RecyclerView.ViewHolder { 33 public class HomeCouponViewHolder extends RecyclerView.ViewHolder {
34 - private ImageView ivCampaignTitle; 34 + private ImageView ivCouponTitle;
35 - private TextView tvCampaignTitle; 35 + private TextView tvCouponTitle;
36 36
37 public HomeCouponViewHolder(View view) { 37 public HomeCouponViewHolder(View view) {
38 super(view); 38 super(view);
39 - ivCampaignTitle = view.findViewById(R.id.iv_campaign_logo); 39 + ivCouponTitle = view.findViewById(R.id.iv_coupon_logo);
40 - tvCampaignTitle = view.findViewById(R.id.tv_campaign_title); 40 + tvCouponTitle = view.findViewById(R.id.tv_coupon_subtitle);
41 } 41 }
42 } 42 }
43 43
...@@ -72,22 +72,22 @@ public class HomeCouponAdapter extends RecyclerView.Adapter<HomeCouponAdapter.Ho ...@@ -72,22 +72,22 @@ public class HomeCouponAdapter extends RecyclerView.Adapter<HomeCouponAdapter.Ho
72 Coupon couponItem = mCoupons.get(position); 72 Coupon couponItem = mCoupons.get(position);
73 73
74 if (couponItem != null) { 74 if (couponItem != null) {
75 - if (!TextUtils.isEmpty(couponItem.getLogoUrl())) { 75 +// if (!TextUtils.isEmpty(couponItem.getImage())) {
76 - Glide.with(mContext) 76 +// Glide.with(mContext)
77 -// .setDefaultRequestOptions( 77 +//// .setDefaultRequestOptions(
78 -// RequestOptions 78 +//// RequestOptions
79 -// .placeholderOf(R.drawable.ic_default_contact_photo) 79 +//// .placeholderOf(R.drawable.ic_default_contact_photo)
80 -// .error(R.drawable.ic_default_contact_photo)) 80 +//// .error(R.drawable.ic_default_contact_photo))
81 - .load(couponItem.getLogoUrl()) 81 +// .load(couponItem.getImage())
82 - .diskCacheStrategy(DiskCacheStrategy.DATA) 82 +// .diskCacheStrategy(DiskCacheStrategy.DATA)
83 - .into(holder.ivCampaignTitle); 83 +// .into(holder.ivCouponTitle);
84 - } else { 84 +// } else {
85 - Glide.with(mContext) 85 +// Glide.with(mContext)
86 - .load(R.drawable.ic_cosmote_logo_horizontal_grey) 86 +// .load(R.drawable.ic_cosmote_logo_horizontal_grey)
87 - .into(holder.ivCampaignTitle); 87 +// .into(holder.ivCouponTitle);
88 - } 88 +// }
89 - 89 +
90 - holder.tvCampaignTitle.setText(couponItem.getTitle()); 90 +// holder.tvCouponTitle.setText(couponItem.getName());
91 91
92 holder.itemView.setOnClickListener(v -> onClickSubject.onNext(couponItem)); 92 holder.itemView.setOnClickListener(v -> onClickSubject.onNext(couponItem));
93 } 93 }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
4 xmlns:tools="http://schemas.android.com/tools" 4 xmlns:tools="http://schemas.android.com/tools"
5 android:layout_width="match_parent" 5 android:layout_width="match_parent"
6 android:layout_height="240dp" 6 android:layout_height="240dp"
7 + android:layout_marginLeft="10dp"
7 android:background="@drawable/bottom_border"> 8 android:background="@drawable/bottom_border">
8 9
9 <LinearLayout 10 <LinearLayout
......
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
66 app:layout_constraintVertical_bias="0.2" /> 66 app:layout_constraintVertical_bias="0.2" />
67 67
68 <ImageView 68 <ImageView
69 + android:id="@+id/iv_coupon_logo"
69 android:layout_width="80dp" 70 android:layout_width="80dp"
70 android:layout_height="60dp" 71 android:layout_height="60dp"
71 android:src="@drawable/sklavenitis_logo" 72 android:src="@drawable/sklavenitis_logo"
......
...@@ -92,29 +92,31 @@ ...@@ -92,29 +92,31 @@
92 android:layout_width="match_parent" 92 android:layout_width="match_parent"
93 android:layout_height="wrap_content" 93 android:layout_height="wrap_content"
94 android:layout_below="@id/rl_header" 94 android:layout_below="@id/rl_header"
95 - android:layout_marginTop="16dp" 95 + android:layout_marginTop="16dp">
96 - android:paddingHorizontal="16dp"> 96 + <androidx.recyclerview.widget.RecyclerView
97 - 97 + android:id="@+id/rv_home_campaigns"
98 - <include layout="@layout/carousel_item" /> 98 + android:layout_width="match_parent"
99 + android:layout_height="wrap_content"
100 + android:layout_marginBottom="8dp"
101 + android:clipToPadding="false"
102 + android:orientation="horizontal"
103 + android:paddingEnd="10dp"/>
99 </RelativeLayout> 104 </RelativeLayout>
100 105
101 <LinearLayout 106 <LinearLayout
102 android:id="@+id/rl_home_coupons" 107 android:id="@+id/rl_home_coupons"
103 android:layout_width="match_parent" 108 android:layout_width="match_parent"
104 android:layout_height="wrap_content" 109 android:layout_height="wrap_content"
105 - android:layout_below="@id/rl_home_campaigns" 110 + android:layout_below="@id/rl_home_campaigns">
106 - android:layout_marginVertical="25dp" 111 + <androidx.recyclerview.widget.RecyclerView
107 - android:paddingHorizontal="15dp"> 112 + android:id="@+id/rv_home_coupons"
108 - <!-- <androidx.recyclerview.widget.RecyclerView--> 113 + android:layout_width="match_parent"
109 - <!-- android:id="@+id/rv_home_coupons"--> 114 + android:layout_height="wrap_content"
110 - <!-- android:layout_width="match_parent"--> 115 + android:layout_marginBottom="8dp"
111 - <!-- android:layout_height="wrap_content"--> 116 + android:clipToPadding="false"
112 - <!-- android:layout_marginBottom="8dp"--> 117 + android:orientation="horizontal"
113 - <!-- android:clipToPadding="false"--> 118 + android:paddingStart="10dp"
114 - <!-- android:orientation="horizontal"--> 119 + android:paddingEnd="10dp"/>
115 - <!-- android:paddingEnd="10dp"-->
116 - <!-- />-->
117 - <include layout="@layout/coupon_layout" />
118 </LinearLayout> 120 </LinearLayout>
119 121
120 <androidx.constraintlayout.widget.ConstraintLayout 122 <androidx.constraintlayout.widget.ConstraintLayout
......