Panagiotis Triantafyllou

new model, new event bus, new version

......@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
ext {
PUBLISH_GROUP_ID = 'ly.warp'
PUBLISH_VERSION = '4.5.4-cosbeta8'
PUBLISH_VERSION = '4.5.4-cosbeta9'
PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
}
......
......@@ -8,10 +8,10 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONException;
import org.json.JSONObject;
......@@ -24,12 +24,14 @@ import ly.warp.sdk.io.models.Campaign;
import ly.warp.sdk.io.models.CampaignList;
import ly.warp.sdk.io.models.Couponset;
import ly.warp.sdk.io.models.CouponsetsList;
import ly.warp.sdk.io.models.LoyaltyContextualOfferModel;
import ly.warp.sdk.io.models.LoyaltyGiftsForYouOfferClickEvent;
import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
import ly.warp.sdk.io.models.MergedGifts;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.views.adapters.CouponsetsAdapter;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
import ly.warp.sdk.views.adapters.MergedGiftsAdapter;
import ly.warp.sdk.views.adapters.ProfileCampaignAdapter;
public class GiftsForYouActivity extends Activity implements View.OnClickListener {
......@@ -178,8 +180,12 @@ public class GiftsForYouActivity extends Activity implements View.OnClickListene
mAdapterMergedGifts.getPositionClicks()
.doOnNext(dataItem -> {
if (dataItem.getDataType() == 1) {
EventBus.getDefault().post(new WarplyEventBusManager().postWarplyEventBus("gifts", new LoyaltyGiftsForYouOfferClickEvent()));
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(dataItem.getCampaign())));
} else if (dataItem.getDataType() == 2) {
EventBus.getDefault().post(new WarplyEventBusManager().postWarplyEventBus("ccms", new LoyaltyContextualOfferModel()));
Intent intent = new Intent(GiftsForYouActivity.this, CouponsetInfoActivity.class);
intent.putExtra("couponset", (Serializable) dataItem.getCouponset());
startActivity(intent);
......
......@@ -10,9 +10,13 @@ import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import org.greenrobot.eventbus.EventBus;
import ly.warp.sdk.R;
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;
......@@ -86,6 +90,7 @@ public class MoreForYouActivity extends Activity implements View.OnClickListener
mRecyclerMore.setAdapter(mAdapterMore);
mAdapterMore.getPositionClicks()
.doOnNext(gift -> {
EventBus.getDefault().post(new WarplyEventBusManager().postWarplyEventBus("firebase", new LoyaltySDKFirebaseEventModel()));
startActivity(WarpViewActivity.createIntentFromURL(this, WarplyManagerHelper.constructCampaignUrl(gift)));
})
.doOnError(error -> {
......
/*
* Copyright 2010-2013 Warply Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE WARPLY LTD ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
* EVENT SHALL WARPLY LTD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package ly.warp.sdk.io.models;
import java.util.HashMap;
/**
* Created by Panagiotis Triantafyllou on 27-May-22.
*/
public class LoyaltyGiftsForYouOfferClickEvent {
private String title;
private String imageUrl;
private String loyaltyPackageId;
public LoyaltyGiftsForYouOfferClickEvent() {
this.title = "";
this.imageUrl = "";
this.loyaltyPackageId = "";
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
public String getLoyaltyPackageId() {
return loyaltyPackageId;
}
public void setLoyaltyPackageId(String loyaltyPackageId) {
this.loyaltyPackageId = loyaltyPackageId;
}
}
package ly.warp.sdk.utils.managers;
import java.util.HashMap;
import ly.warp.sdk.io.models.LoyaltyContextualOfferModel;
import ly.warp.sdk.io.models.LoyaltyGiftsForYouOfferClickEvent;
import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
import ly.warp.sdk.io.request.WarplyEditAddressRequest;
/**
* Created by Panagiotis Triantafyllou on 26/Απρ/2022.
......@@ -10,6 +14,11 @@ public class WarplyEventBusManager {
private String eventName;
private LoyaltySDKFirebaseEventModel fireEvent;
private LoyaltyContextualOfferModel ccms;
protected HashMap<String, Object> mWarplyEventBusManager = new HashMap();
public WarplyEventBusManager() {
}
public WarplyEventBusManager(String eventName) {
this.eventName = eventName;
......@@ -22,4 +31,26 @@ public class WarplyEventBusManager {
public WarplyEventBusManager(LoyaltyContextualOfferModel ccms) {
this.ccms = ccms;
}
public WarplyEventBusManager postWarplyEventBus(String eventName, LoyaltySDKFirebaseEventModel fireEvent) {
mWarplyEventBusManager.clear();
mWarplyEventBusManager.put(eventName, fireEvent);
return this;
}
public WarplyEventBusManager postWarplyEventBus(String eventName, LoyaltyContextualOfferModel ccms) {
mWarplyEventBusManager.clear();
mWarplyEventBusManager.put(eventName, ccms);
return this;
}
public WarplyEventBusManager postWarplyEventBus(String eventName, LoyaltyGiftsForYouOfferClickEvent gifts) {
mWarplyEventBusManager.clear();
mWarplyEventBusManager.put(eventName, gifts);
return this;
}
public HashMap<String, Object> subscribeWarplyEventBus() {
return mWarplyEventBusManager;
}
}
......