Showing
6 changed files
with
165 additions
and
18 deletions
... | @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' | ... | @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' |
2 | 2 | ||
3 | ext { | 3 | ext { |
4 | PUBLISH_GROUP_ID = 'ly.warp' | 4 | PUBLISH_GROUP_ID = 'ly.warp' |
5 | - PUBLISH_VERSION = '4.5.4-cosbeta24' | 5 | + PUBLISH_VERSION = '4.5.4-cosbeta25' |
6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' | 6 | PUBLISH_ARTIFACT_ID = 'warply-android-sdk' |
7 | } | 7 | } |
8 | 8 | ... | ... |
... | @@ -16,6 +16,7 @@ import org.greenrobot.eventbus.EventBus; | ... | @@ -16,6 +16,7 @@ import org.greenrobot.eventbus.EventBus; |
16 | 16 | ||
17 | import java.util.ArrayList; | 17 | import java.util.ArrayList; |
18 | import java.util.HashMap; | 18 | import java.util.HashMap; |
19 | +import java.util.HashSet; | ||
19 | 20 | ||
20 | import ly.warp.sdk.R; | 21 | import ly.warp.sdk.R; |
21 | import ly.warp.sdk.io.models.Campaign; | 22 | import ly.warp.sdk.io.models.Campaign; |
... | @@ -49,16 +50,35 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -49,16 +50,35 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
49 | private RecyclerView mRecyclerMergedGifts; | 50 | private RecyclerView mRecyclerMergedGifts; |
50 | private MergedGiftsAdapter mAdapterMergedGifts; | 51 | private MergedGiftsAdapter mAdapterMergedGifts; |
51 | 52 | ||
53 | + private ArrayList<Campaign> mValuesList = new ArrayList<>(); | ||
54 | + private HashSet<Campaign> mHashSetList = new HashSet<>(); | ||
55 | + private ArrayList<LoyaltyGiftsForYouPackage> mSeasonalList = new ArrayList<>(); | ||
56 | + private HashSet<LoyaltyGiftsForYouPackage> mHashSetSeasonalList = new HashSet<>(); | ||
57 | + | ||
52 | // =========================================================== | 58 | // =========================================================== |
53 | // Methods for/from SuperClass/Interfaces | 59 | // Methods for/from SuperClass/Interfaces |
54 | // =========================================================== | 60 | // =========================================================== |
61 | + | ||
55 | @Override | 62 | @Override |
56 | public void onCreate(Bundle savedInstanceState) { | 63 | public void onCreate(Bundle savedInstanceState) { |
57 | super.onCreate(savedInstanceState); | 64 | super.onCreate(savedInstanceState); |
58 | setContentView(R.layout.activity_gifts_for_you); | 65 | setContentView(R.layout.activity_gifts_for_you); |
66 | + | ||
67 | + if (WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you").size() > 0) { | ||
68 | + mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you")); | ||
69 | + mValuesList.clear(); | ||
70 | + mValuesList.addAll(mHashSetList); | ||
71 | + } | ||
72 | + | ||
73 | + if (WarplyManagerHelper.getSeasonalList() != null && WarplyManagerHelper.getSeasonalList().size() > 0) { | ||
74 | + mHashSetSeasonalList.addAll(WarplyManagerHelper.getSeasonalList()); | ||
75 | + mSeasonalList.clear(); | ||
76 | + mSeasonalList.addAll(mHashSetSeasonalList); | ||
77 | + } | ||
78 | + | ||
59 | mergeDatasets( | 79 | mergeDatasets( |
60 | - WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you"), | 80 | + mValuesList, |
61 | - WarplyManagerHelper.getSeasonalList() | 81 | + mSeasonalList |
62 | ); | 82 | ); |
63 | 83 | ||
64 | mIvBack = findViewById(R.id.iv_list_close); | 84 | mIvBack = findViewById(R.id.iv_list_close); |
... | @@ -142,7 +162,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -142,7 +162,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
142 | } | 162 | } |
143 | } | 163 | } |
144 | 164 | ||
145 | - private ArrayList<MergedGifts> mergeDatasets(CampaignList campaignList, ArrayList<LoyaltyGiftsForYouPackage> seasonalList) { | 165 | + private void mergeDatasets(ArrayList<Campaign> campaignList, ArrayList<LoyaltyGiftsForYouPackage> seasonalList) { |
146 | if (campaignList != null && campaignList.size() > 0) { | 166 | if (campaignList != null && campaignList.size() > 0) { |
147 | Log.v("GIFTS_FOR_YOU", String.valueOf(campaignList.size())); | 167 | Log.v("GIFTS_FOR_YOU", String.valueOf(campaignList.size())); |
148 | for (Campaign campaign : campaignList) { | 168 | for (Campaign campaign : campaignList) { |
... | @@ -155,6 +175,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -155,6 +175,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
155 | } | 175 | } |
156 | 176 | ||
157 | if (seasonalList != null && seasonalList.size() > 0) { | 177 | if (seasonalList != null && seasonalList.size() > 0) { |
178 | + Log.v("GIFTS_FOR_YOU", String.valueOf(seasonalList.size())); | ||
158 | for (LoyaltyGiftsForYouPackage seasonal : seasonalList) { | 179 | for (LoyaltyGiftsForYouPackage seasonal : seasonalList) { |
159 | MergedGifts data = new MergedGifts(); | 180 | MergedGifts data = new MergedGifts(); |
160 | data.setCampaign(null); | 181 | data.setCampaign(null); |
... | @@ -163,8 +184,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene | ... | @@ -163,8 +184,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene |
163 | mData.add(data); | 184 | mData.add(data); |
164 | } | 185 | } |
165 | } | 186 | } |
166 | - | ||
167 | - return mData; | ||
168 | } | 187 | } |
169 | 188 | ||
170 | // =========================================================== | 189 | // =========================================================== | ... | ... |
... | @@ -13,12 +13,16 @@ import androidx.recyclerview.widget.RecyclerView; | ... | @@ -13,12 +13,16 @@ import androidx.recyclerview.widget.RecyclerView; |
13 | 13 | ||
14 | import org.greenrobot.eventbus.EventBus; | 14 | import org.greenrobot.eventbus.EventBus; |
15 | 15 | ||
16 | +import java.util.ArrayList; | ||
17 | +import java.util.HashSet; | ||
18 | + | ||
16 | import ly.warp.sdk.R; | 19 | import ly.warp.sdk.R; |
20 | +import ly.warp.sdk.io.models.Campaign; | ||
17 | import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; | 21 | import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; |
18 | import ly.warp.sdk.utils.WarpUtils; | 22 | import ly.warp.sdk.utils.WarpUtils; |
19 | import ly.warp.sdk.utils.WarplyManagerHelper; | 23 | import ly.warp.sdk.utils.WarplyManagerHelper; |
20 | import ly.warp.sdk.utils.managers.WarplyEventBusManager; | 24 | import ly.warp.sdk.utils.managers.WarplyEventBusManager; |
21 | -import ly.warp.sdk.views.adapters.ProfileCampaignAdapter; | 25 | +import ly.warp.sdk.views.adapters.MoreCampaignAdapter; |
22 | 26 | ||
23 | 27 | ||
24 | public class MoreForYouActivity extends Activity implements View.OnClickListener { | 28 | public class MoreForYouActivity extends Activity implements View.OnClickListener { |
... | @@ -34,8 +38,10 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -34,8 +38,10 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
34 | private ImageView mIvBack, mIvPopupClose; | 38 | private ImageView mIvBack, mIvPopupClose; |
35 | private RecyclerView mRecyclerMore; | 39 | private RecyclerView mRecyclerMore; |
36 | private TextView mTvTitle; | 40 | private TextView mTvTitle; |
37 | - private ProfileCampaignAdapter mAdapterMore; | 41 | + private MoreCampaignAdapter mAdapterMore; |
38 | private LinearLayout mLlMorePopup; | 42 | private LinearLayout mLlMorePopup; |
43 | + private ArrayList<Campaign> mValuesList = new ArrayList<>(); | ||
44 | + private HashSet<Campaign> mHashSetList = new HashSet<>(); | ||
39 | 45 | ||
40 | // =========================================================== | 46 | // =========================================================== |
41 | // Methods for/from SuperClass/Interfaces | 47 | // Methods for/from SuperClass/Interfaces |
... | @@ -51,7 +57,14 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -51,7 +57,14 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
51 | mIvPopupClose = findViewById(R.id.iv_popup_more_close); | 57 | mIvPopupClose = findViewById(R.id.iv_popup_more_close); |
52 | mLlMorePopup = findViewById(R.id.ll_more_popup); | 58 | mLlMorePopup = findViewById(R.id.ll_more_popup); |
53 | 59 | ||
54 | - mRecyclerMore = findViewById(R.id.rv_more); | 60 | + mRecyclerMore = findViewById(R.id.rv_more_items); |
61 | + | ||
62 | + | ||
63 | + if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) { | ||
64 | + mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("more_for_you")); | ||
65 | + mValuesList.clear(); | ||
66 | + mValuesList.addAll(mHashSetList); | ||
67 | + } | ||
55 | 68 | ||
56 | initViews(); | 69 | initViews(); |
57 | } | 70 | } |
... | @@ -85,10 +98,10 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener | ... | @@ -85,10 +98,10 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener |
85 | // if (WarpUtils.getMorePopup(this)) | 98 | // if (WarpUtils.getMorePopup(this)) |
86 | // mLlMorePopup.setVisibility(View.VISIBLE); | 99 | // mLlMorePopup.setVisibility(View.VISIBLE); |
87 | 100 | ||
88 | - if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) { | 101 | + if (mValuesList != null && mValuesList.size() > 0) { |
89 | - Log.v("MORE_FOR_YOU", String.valueOf(WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size())); | 102 | + Log.v("MORE_FOR_YOU", String.valueOf(mValuesList.size())); |
90 | mRecyclerMore.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); | 103 | mRecyclerMore.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)); |
91 | - mAdapterMore = new ProfileCampaignAdapter(this, WarplyManagerHelper.getUniqueCampaignList().get("more_for_you"), true); | 104 | + mAdapterMore = new MoreCampaignAdapter(this, mValuesList); |
92 | mRecyclerMore.setAdapter(mAdapterMore); | 105 | mRecyclerMore.setAdapter(mAdapterMore); |
93 | mAdapterMore.getPositionClicks() | 106 | mAdapterMore.getPositionClicks() |
94 | .doOnNext(gift -> { | 107 | .doOnNext(gift -> { | ... | ... |
... | @@ -567,10 +567,6 @@ public class WarplyManagerHelper { | ... | @@ -567,10 +567,6 @@ public class WarplyManagerHelper { |
567 | mConsumer = consumer; | 567 | mConsumer = consumer; |
568 | } | 568 | } |
569 | 569 | ||
570 | - public static void setUniqueCampaignList(HashMap<String, CampaignList> uniqueCampaignList) { | ||
571 | - mUniqueCampaignList = uniqueCampaignList; | ||
572 | - } | ||
573 | - | ||
574 | public static void setUniqueCampaignList(CampaignList campaignList) { | 570 | public static void setUniqueCampaignList(CampaignList campaignList) { |
575 | mCampaignList = campaignList; | 571 | mCampaignList = campaignList; |
576 | if (campaignList != null) { | 572 | if (campaignList != null) { | ... | ... |
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 | +import com.bumptech.glide.load.resource.bitmap.CenterCrop; | ||
16 | +import com.bumptech.glide.load.resource.bitmap.RoundedCorners; | ||
17 | + | ||
18 | +import java.util.ArrayList; | ||
19 | + | ||
20 | +import io.reactivex.Observable; | ||
21 | +import io.reactivex.subjects.PublishSubject; | ||
22 | +import ly.warp.sdk.R; | ||
23 | +import ly.warp.sdk.io.models.Campaign; | ||
24 | + | ||
25 | + | ||
26 | +public class MoreCampaignAdapter extends RecyclerView.Adapter<MoreCampaignAdapter.ProfileCampaignViewHolder> { | ||
27 | + | ||
28 | + private Context mContext; | ||
29 | + private ArrayList<Campaign> mCampaigns; | ||
30 | + private final PublishSubject<Campaign> onClickSubject = PublishSubject.create(); | ||
31 | + | ||
32 | + public MoreCampaignAdapter(Context mContext, ArrayList<Campaign> campaignList) { | ||
33 | + this.mContext = mContext; | ||
34 | + this.mCampaigns = campaignList; | ||
35 | + } | ||
36 | + | ||
37 | + public class ProfileCampaignViewHolder extends RecyclerView.ViewHolder { | ||
38 | + private ImageView ivCampaignTitle, ivIsNew; | ||
39 | + private TextView tvCampaignTitle, tvCampaignSubtitle, tvCampaignMessage; | ||
40 | + | ||
41 | + public ProfileCampaignViewHolder(View view) { | ||
42 | + super(view); | ||
43 | + ivCampaignTitle = view.findViewById(R.id.iv_campaign_logo); | ||
44 | + tvCampaignTitle = view.findViewById(R.id.tv_campaign_title); | ||
45 | + } | ||
46 | + | ||
47 | + public ProfileCampaignViewHolder(View view, boolean vertical) { | ||
48 | + super(view); | ||
49 | + ivCampaignTitle = view.findViewById(R.id.iv_campaign_logo); | ||
50 | + tvCampaignTitle = view.findViewById(R.id.tv_campaign_title); | ||
51 | + ivIsNew = view.findViewById(R.id.iv_campaign_new); | ||
52 | + if (vertical) { | ||
53 | + tvCampaignSubtitle = view.findViewById(R.id.tv_campaign_subtitle); | ||
54 | + tvCampaignMessage = view.findViewById(R.id.tv_campaign_message); | ||
55 | + } | ||
56 | + } | ||
57 | + } | ||
58 | + | ||
59 | + @Override | ||
60 | + public int getItemCount() { | ||
61 | + if (mCampaigns == null) | ||
62 | + return 0; | ||
63 | + else | ||
64 | + return mCampaigns.size(); | ||
65 | + } | ||
66 | + | ||
67 | + | ||
68 | + public Campaign getItem(int id) { | ||
69 | + return mCampaigns.get(id); | ||
70 | + } | ||
71 | + | ||
72 | + public void updateData(ArrayList<Campaign> campaignList) { | ||
73 | + mCampaigns.clear(); | ||
74 | + mCampaigns.addAll(campaignList); | ||
75 | + notifyDataSetChanged(); | ||
76 | + } | ||
77 | + | ||
78 | + @Override | ||
79 | + public ProfileCampaignViewHolder onCreateViewHolder(ViewGroup parent, int viewType) { | ||
80 | + View itemView; | ||
81 | + | ||
82 | + itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_profile_recycler_vertical, parent, false); | ||
83 | + return new ProfileCampaignViewHolder(itemView, true); | ||
84 | + } | ||
85 | + | ||
86 | + @Override | ||
87 | + public void onBindViewHolder(final ProfileCampaignViewHolder holder, int position) { | ||
88 | + Campaign campaignItem = mCampaigns.get(position); | ||
89 | + | ||
90 | + if (campaignItem != null) { | ||
91 | + if (!TextUtils.isEmpty(campaignItem.getLogoUrl())) { | ||
92 | + Glide.with(mContext) | ||
93 | + .load(campaignItem.getLogoUrl()) | ||
94 | + .transform(new CenterCrop(), new RoundedCorners(4)) | ||
95 | + .diskCacheStrategy(DiskCacheStrategy.DATA) | ||
96 | + .into(holder.ivCampaignTitle); | ||
97 | + } else { | ||
98 | + Glide.with(mContext) | ||
99 | + .load(R.drawable.ic_cosmote_logo_horizontal_grey) | ||
100 | + .into(holder.ivCampaignTitle); | ||
101 | + } | ||
102 | + | ||
103 | + holder.tvCampaignTitle.setText(campaignItem.getTitle()); | ||
104 | + holder.tvCampaignSubtitle.setText(campaignItem.getSubtitle()); | ||
105 | + holder.tvCampaignMessage.setText(campaignItem.getMessage()); | ||
106 | + if (campaignItem.getIsNew()) | ||
107 | + holder.ivIsNew.setVisibility(View.VISIBLE); | ||
108 | + else | ||
109 | + holder.ivIsNew.setVisibility(View.GONE); | ||
110 | + | ||
111 | + holder.itemView.setOnClickListener(v -> onClickSubject.onNext(campaignItem)); | ||
112 | + } | ||
113 | + } | ||
114 | + | ||
115 | + public Observable<Campaign> getPositionClicks() { | ||
116 | + return onClickSubject.cache(); | ||
117 | + } | ||
118 | + | ||
119 | +} |
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | 2 | <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
3 | xmlns:app="http://schemas.android.com/apk/res-auto" | 3 | xmlns:app="http://schemas.android.com/apk/res-auto" |
4 | + xmlns:tools="http://schemas.android.com/tools" | ||
4 | android:layout_width="match_parent" | 5 | android:layout_width="match_parent" |
5 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
6 | - xmlns:tools="http://schemas.android.com/tools" | ||
7 | android:background="@android:color/white" | 7 | android:background="@android:color/white" |
8 | android:fillViewport="true"> | 8 | android:fillViewport="true"> |
9 | 9 | ||
... | @@ -93,7 +93,7 @@ | ... | @@ -93,7 +93,7 @@ |
93 | </LinearLayout> | 93 | </LinearLayout> |
94 | 94 | ||
95 | <androidx.recyclerview.widget.RecyclerView | 95 | <androidx.recyclerview.widget.RecyclerView |
96 | - android:id="@+id/rv_more" | 96 | + android:id="@+id/rv_more_items" |
97 | android:layout_width="match_parent" | 97 | android:layout_width="match_parent" |
98 | android:layout_height="match_parent" | 98 | android:layout_height="match_parent" |
99 | android:layout_below="@+id/ll_more_popup" | 99 | android:layout_below="@+id/ll_more_popup" | ... | ... |
-
Please register or login to post a comment