Panagiotis Triantafyllou

possible duplicate fix

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4-cosbeta24'
PUBLISH_VERSION = '4.5.4-cosbeta25'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -16,6 +16,7 @@ import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.Campaign;
......@@ -49,16 +50,35 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
private RecyclerView mRecyclerMergedGifts;
private MergedGiftsAdapter mAdapterMergedGifts;
private ArrayList<Campaign> mValuesList = new ArrayList<>();
private HashSet<Campaign> mHashSetList = new HashSet<>();
private ArrayList<LoyaltyGiftsForYouPackage> mSeasonalList = new ArrayList<>();
private HashSet<LoyaltyGiftsForYouPackage> mHashSetSeasonalList = new HashSet<>();
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gifts_for_you);
if (WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you").size() > 0) {
mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you"));
mValuesList.clear();
mValuesList.addAll(mHashSetList);
}
if (WarplyManagerHelper.getSeasonalList() != null && WarplyManagerHelper.getSeasonalList().size() > 0) {
mHashSetSeasonalList.addAll(WarplyManagerHelper.getSeasonalList());
mSeasonalList.clear();
mSeasonalList.addAll(mHashSetSeasonalList);
}
mergeDatasets(
WarplyManagerHelper.getUniqueCampaignList().get("gifts_for_you"),
WarplyManagerHelper.getSeasonalList()
mValuesList,
mSeasonalList
);
mIvBack = findViewById(R.id.iv_list_close);
......@@ -142,7 +162,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
}
}
private ArrayList<MergedGifts> mergeDatasets(CampaignList campaignList, ArrayList<LoyaltyGiftsForYouPackage> seasonalList) {
private void mergeDatasets(ArrayList<Campaign> campaignList, ArrayList<LoyaltyGiftsForYouPackage> seasonalList) {
if (campaignList != null && campaignList.size() > 0) {
Log.v("GIFTS_FOR_YOU", String.valueOf(campaignList.size()));
for (Campaign campaign : campaignList) {
......@@ -155,6 +175,7 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
}
if (seasonalList != null && seasonalList.size() > 0) {
Log.v("GIFTS_FOR_YOU", String.valueOf(seasonalList.size()));
for (LoyaltyGiftsForYouPackage seasonal : seasonalList) {
MergedGifts data = new MergedGifts();
data.setCampaign(null);
......@@ -163,8 +184,6 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
mData.add(data);
}
}
return mData;
}
// ===========================================================
......
......@@ -13,12 +13,16 @@ import androidx.recyclerview.widget.RecyclerView;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.HashSet;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.Campaign;
import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
import ly.warp.sdk.views.adapters.ProfileCampaignAdapter;
import ly.warp.sdk.views.adapters.MoreCampaignAdapter;
public class MoreForYouActivity extends Activity implements View.OnClickListener {
......@@ -34,8 +38,10 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
private ImageView mIvBack, mIvPopupClose;
private RecyclerView mRecyclerMore;
private TextView mTvTitle;
private ProfileCampaignAdapter mAdapterMore;
private MoreCampaignAdapter mAdapterMore;
private LinearLayout mLlMorePopup;
private ArrayList<Campaign> mValuesList = new ArrayList<>();
private HashSet<Campaign> mHashSetList = new HashSet<>();
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -51,7 +57,14 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mIvPopupClose = findViewById(R.id.iv_popup_more_close);
mLlMorePopup = findViewById(R.id.ll_more_popup);
mRecyclerMore = findViewById(R.id.rv_more);
mRecyclerMore = findViewById(R.id.rv_more_items);
if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) {
mHashSetList.addAll(WarplyManagerHelper.getUniqueCampaignList().get("more_for_you"));
mValuesList.clear();
mValuesList.addAll(mHashSetList);
}
initViews();
}
......@@ -85,10 +98,10 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
// if (WarpUtils.getMorePopup(this))
// mLlMorePopup.setVisibility(View.VISIBLE);
if (WarplyManagerHelper.getUniqueCampaignList().get("more_for_you") != null && WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size() > 0) {
Log.v("MORE_FOR_YOU", String.valueOf(WarplyManagerHelper.getUniqueCampaignList().get("more_for_you").size()));
if (mValuesList != null && mValuesList.size() > 0) {
Log.v("MORE_FOR_YOU", String.valueOf(mValuesList.size()));
mRecyclerMore.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
mAdapterMore = new ProfileCampaignAdapter(this, WarplyManagerHelper.getUniqueCampaignList().get("more_for_you"), true);
mAdapterMore = new MoreCampaignAdapter(this, mValuesList);
mRecyclerMore.setAdapter(mAdapterMore);
mAdapterMore.getPositionClicks()
.doOnNext(gift -> {
......
......@@ -567,10 +567,6 @@ public class WarplyManagerHelper {
mConsumer = consumer;
}
public static void setUniqueCampaignList(HashMap<String, CampaignList> uniqueCampaignList) {
mUniqueCampaignList = uniqueCampaignList;
}
public static void setUniqueCampaignList(CampaignList campaignList) {
mCampaignList = campaignList;
if (campaignList != null) {
......
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 com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import java.util.ArrayList;
import io.reactivex.Observable;
import io.reactivex.subjects.PublishSubject;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.Campaign;
public class MoreCampaignAdapter extends RecyclerView.Adapter<MoreCampaignAdapter.ProfileCampaignViewHolder> {
private Context mContext;
private ArrayList<Campaign> mCampaigns;
private final PublishSubject<Campaign> onClickSubject = PublishSubject.create();
public MoreCampaignAdapter(Context mContext, ArrayList<Campaign> campaignList) {
this.mContext = mContext;
this.mCampaigns = campaignList;
}
public class ProfileCampaignViewHolder extends RecyclerView.ViewHolder {
private ImageView ivCampaignTitle, ivIsNew;
private TextView tvCampaignTitle, tvCampaignSubtitle, tvCampaignMessage;
public ProfileCampaignViewHolder(View view) {
super(view);
ivCampaignTitle = view.findViewById(R.id.iv_campaign_logo);
tvCampaignTitle = view.findViewById(R.id.tv_campaign_title);
}
public ProfileCampaignViewHolder(View view, boolean vertical) {
super(view);
ivCampaignTitle = view.findViewById(R.id.iv_campaign_logo);
tvCampaignTitle = view.findViewById(R.id.tv_campaign_title);
ivIsNew = view.findViewById(R.id.iv_campaign_new);
if (vertical) {
tvCampaignSubtitle = view.findViewById(R.id.tv_campaign_subtitle);
tvCampaignMessage = view.findViewById(R.id.tv_campaign_message);
}
}
}
@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(ArrayList<Campaign> campaignList) {
mCampaigns.clear();
mCampaigns.addAll(campaignList);
notifyDataSetChanged();
}
@Override
public ProfileCampaignViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView;
itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_profile_recycler_vertical, parent, false);
return new ProfileCampaignViewHolder(itemView, true);
}
@Override
public void onBindViewHolder(final ProfileCampaignViewHolder holder, int position) {
Campaign campaignItem = mCampaigns.get(position);
if (campaignItem != null) {
if (!TextUtils.isEmpty(campaignItem.getLogoUrl())) {
Glide.with(mContext)
.load(campaignItem.getLogoUrl())
.transform(new CenterCrop(), new RoundedCorners(4))
.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.tvCampaignSubtitle.setText(campaignItem.getSubtitle());
holder.tvCampaignMessage.setText(campaignItem.getMessage());
if (campaignItem.getIsNew())
holder.ivIsNew.setVisibility(View.VISIBLE);
else
holder.ivIsNew.setVisibility(View.GONE);
holder.itemView.setOnClickListener(v -> onClickSubject.onNext(campaignItem));
}
}
public Observable<Campaign> getPositionClicks() {
return onClickSubject.cache();
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:background="@android:color/white"
android:fillViewport="true">
......@@ -93,7 +93,7 @@
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_more"
android:id="@+id/rv_more_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/ll_more_popup"
......