Panagiotis Triantafyllou

unified coupons basket fixes

......@@ -2,15 +2,26 @@ package warp.ly.android_sdk.activities;
import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;
import org.json.JSONObject;
import java.util.Timer;
import java.util.TimerTask;
import ly.warp.sdk.Warply;
import ly.warp.sdk.activities.BaseFragmentActivity;
import ly.warp.sdk.db.WarplyDBHelper;
import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.callbacks.SimpleCallbackReceiver;
import ly.warp.sdk.io.callbacks.WarplyReadyCallback;
import ly.warp.sdk.io.models.Consumer;
import ly.warp.sdk.io.request.WarplyConsumerRequest;
import ly.warp.sdk.utils.WarpJSONParser;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyInitializer;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyManager;
import warp.ly.android_sdk.R;
public class SplashActivity extends BaseActivity {
......@@ -25,7 +36,11 @@ public class SplashActivity extends BaseActivity {
mWarplyInitializer = Warply.getInitializer(this, new WarplyReadyCallback() {
@Override
public void onWarplyReady() {
startNextActivity();
if (WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) {
WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerCallback);
} else {
startNextActivity();
}
}
@Override
......@@ -76,4 +91,34 @@ public class SplashActivity extends BaseActivity {
}, MIN_SPLASH_TIME);
}
}
private CallbackReceiver<Consumer> mConsumerCallback = new CallbackReceiver<Consumer>() {
@Override
public void onSuccess(Consumer result) {
WarplyManagerHelper.setConsumerInternal(result);
if (result != null) {
JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata());
if (profMetadata != null && profMetadata.has("nonTelco")) {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), profMetadata.optBoolean("nonTelco"));
} else {
WarpUtils.setUserNonTelco(Warply.getWarplyContext(), false);
}
if (profMetadata != null) {
if (profMetadata.has("badge")) {
WarpUtils.setUserTag(Warply.getWarplyContext(), profMetadata.optString("badge"));
}
}
}
startNextActivity();
}
@Override
public void onFailure(int errorCode) {
startNextActivity();
Toast.makeText(SplashActivity.this, "GET PROFILE ERROR", Toast.LENGTH_SHORT).show();
}
};
}
......
......@@ -19,6 +19,7 @@ import androidx.recyclerview.widget.RecyclerView;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.json.JSONArray;
import org.json.JSONObject;
import java.io.Serializable;
import java.text.ParseException;
......@@ -63,8 +64,9 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
private RelativeLayout mRlUnifiedCoupons, mRlActiveUnifiedCoupons;
private ActiveCouponAdapter mAdapterCoupons;
private Set<Coupon> mSelectedItems = new HashSet<>();
private LinearLayout mLlActivateunified;
private LinearLayout mLlActivateUnified;
private AlertDialog mAlertDialog;
private RelativeLayout mPbLoading;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -95,8 +97,10 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
mTvActiveUnifiedCouponsTitle = mClActiveCouponsHeader.findViewById(R.id.tv_active_sm_coupons_title);
mTvChooseAll = mClActiveCouponsHeader.findViewById(R.id.tv_choose_all);
mIvChooseAll = mClActiveCouponsHeader.findViewById(R.id.iv_choose_all);
mLlActivateunified = findViewById(R.id.ll_activate_unified);
mTvActivate = mLlActivateunified.findViewById(R.id.button_activate);
mLlActivateUnified = findViewById(R.id.ll_activate_unified);
mTvActivate = mLlActivateUnified.findViewById(R.id.button_activate);
mPbLoading = findViewById(R.id.pb_loading);
mPbLoading.setOnTouchListener((v, event) -> true);
WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader, mTvInnerTitle,
mTvUnifieCouponsTitle, mTvActiveUnifiedCouponsTitle);
WarpUtils.renderCustomFont(this, R.font.peridot_regular, mTvEmptyUnifiedCoupons, mTvInnerSubtitle);
......@@ -113,7 +117,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
mUnifiedPressed = false;
mActiveUnifiedPressed = false;
mIsActivatePressed = false;
filterItems();
filterItems(false);
}
@Override
......@@ -138,6 +142,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
@Subscribe()
public void onMessageEvent(WarplyEventBusManager event) {
if (event.getRefreshUnifiedCouponsAdded() != null || event.getRefreshVouchersEventModel() != null) {
mPbLoading.setVisibility(View.VISIBLE);
WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
}
}
......@@ -161,12 +166,12 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
mSelectedItems.clear();
mSelectedItems.addAll(mAdapterCoupons.getItems());
mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_checked_skyblue);
mLlActivateunified.setBackgroundResource(R.drawable.selector_button_green);
mLlActivateUnified.setBackgroundResource(R.drawable.selector_button_green);
mAdapterCoupons.updateChecked(mSelectedItems);
} else if (mSelectedItems.size() == mAdapterCoupons.getItemCount()) {
mSelectedItems.clear();
mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_gray);
mLlActivateunified.setBackgroundResource(R.drawable.selector_button_grey_dark);
mLlActivateUnified.setBackgroundResource(R.drawable.selector_button_grey_dark);
mAdapterCoupons.updateChecked(mSelectedItems);
}
return;
......@@ -181,6 +186,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
tempArray.put(selectedCoupon.getCoupon());
}
mPbLoading.setVisibility(View.VISIBLE);
WarplyManager.createUnifiedCoupon(tempArray, mCreateUnifiedCallback);
}
}
......@@ -197,19 +203,22 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
mIvInfoClose.setOnClickListener(this);
mTvInnerClose.setOnClickListener(this);
mIvChooseAll.setOnClickListener(this);
mLlActivateunified.setOnClickListener(this);
mLlActivateUnified.setOnClickListener(this);
}
private void filterItems() {
private void filterItems(boolean isFromEvent) {
mClInfoView.setVisibility(View.GONE);
mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_gray);
mLlActivateunified.setBackgroundResource(R.drawable.selector_button_grey_dark);
mLlActivateUnified.setBackgroundResource(R.drawable.selector_button_grey_dark);
mSelectedItems.clear();
if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().isEmpty()
&& WarplyManagerHelper.getSmCouponsList() != null && WarplyManagerHelper.getSmCouponsList().isEmpty()) {
mLlActivateUnified.setVisibility(View.GONE);
mTvEmptyUnifiedCoupons.setVisibility(View.VISIBLE);
mLlActivateunified.setVisibility(View.GONE);
} else {
mTvEmptyUnifiedCoupons.setVisibility(View.GONE);
mLlActivateUnified.setVisibility(View.VISIBLE);
}
......@@ -291,15 +300,19 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
}
if (mSelectedItems.isEmpty()) {
mLlActivateunified.setBackgroundResource(R.drawable.selector_button_grey_dark);
mLlActivateUnified.setBackgroundResource(R.drawable.selector_button_grey_dark);
} else {
mLlActivateunified.setBackgroundResource(R.drawable.selector_button_green);
mLlActivateUnified.setBackgroundResource(R.drawable.selector_button_green);
}
})
.doOnError(error -> {
})
.subscribe();
if (isFromEvent) {
mAdapterCoupons.notifyDataSetChanged();
}
mRlActiveUnifiedCoupons.setVisibility(View.VISIBLE);
} else {
mRlActiveUnifiedCoupons.setVisibility(View.GONE);
......@@ -314,20 +327,26 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
@Override
public void onSuccess(ArrayList<UnifiedCoupon> result) {
Handler mUIHandler = new Handler(Looper.getMainLooper());
mUIHandler.post(ActiveUnifiedCouponsActivity.this::filterItems);
mUIHandler.post(() -> {
mPbLoading.setVisibility(View.GONE);
filterItems(true);
});
}
@Override
public void onFailure(int errorCode) {
Handler mUIHandler = new Handler(Looper.getMainLooper());
mUIHandler.post(() -> mPbLoading.setVisibility(View.GONE));
}
};
private final CallbackReceiver<ArrayList<UnifiedCoupon>> mCreateUnifiedCallback = new CallbackReceiver<ArrayList<UnifiedCoupon>>() {
private final CallbackReceiver<JSONObject> mCreateUnifiedCallback = new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(ArrayList<UnifiedCoupon> result) {
public void onSuccess(JSONObject result) {
mIsActivatePressed = false;
mPbLoading.setVisibility(View.GONE);
mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_gray);
mLlActivateunified.setBackgroundResource(R.drawable.selector_button_grey_dark);
mLlActivateUnified.setBackgroundResource(R.drawable.selector_button_grey_dark);
mSelectedItems.clear();
if (!isFinishing()) {
......@@ -343,6 +362,9 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
@Override
public void onFailure(int errorCode) {
mIsActivatePressed = false;
mPbLoading.setVisibility(View.GONE);
if (!isFinishing()) {
mAlertDialog = new AlertDialog.Builder(ActiveUnifiedCouponsActivity.this)
.setTitle(R.string.cos_dlg_error_unified_title)
......
......@@ -12,6 +12,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
......@@ -76,6 +77,7 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
private ActiveCouponAdapter mAdapterCoupons;
private AlertDialog mErrorAlertDialog, mSuccessAlertDialog, mAskCancelUnifiedAlertDialog;
private JSONArray mBottomSheetData;
private RelativeLayout mPbLoading;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -120,6 +122,8 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
mFontShopsLabel = findViewById(R.id.shops_label);
mFontCancelLabel = findViewById(R.id.cancel_label);
mTvBarcodeTitle = findViewById(R.id.tv_barcode_title);
mPbLoading = findViewById(R.id.pb_loading);
mPbLoading.setOnTouchListener((v, event) -> true);
WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader, mFontSMLabel);
WarpUtils.renderCustomFont(this, R.font.peridot_regular, mTvActiveValue,
mTvTermsValue);
......@@ -420,6 +424,7 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
if (TextUtils.isEmpty(transactionID)) return;
mPbLoading.setVisibility(View.VISIBLE);
WarplyManager.cancelUnifiedCoupon(transactionID, mCancelUnifiedCallback);
}
......@@ -470,11 +475,13 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
private final CallbackReceiver<Integer> mCancelUnifiedCallback = new CallbackReceiver<Integer>() {
@Override
public void onSuccess(Integer result) {
mPbLoading.setVisibility(View.GONE);
successDialog();
}
@Override
public void onFailure(int errorCode) {
mPbLoading.setVisibility(View.GONE);
errorDialog();
}
};
......
......@@ -28,6 +28,7 @@ import ly.warp.sdk.io.callbacks.CallbackReceiver;
import ly.warp.sdk.io.models.Campaign;
import ly.warp.sdk.io.models.CouponList;
import ly.warp.sdk.io.models.UnifiedCoupon;
import ly.warp.sdk.utils.WarpJSONParser;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyManager;
......@@ -35,7 +36,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
private RelativeLayout mOptionOne, mOptionTwo, mOptionThree, mRlDriving,
mRlDrivingHistory, mPbLoading;
private TextView mTvUsername;
private TextView mTvUsername, mTvUser;
private SwipeRefreshLayout mSwipeRefresh;
private EditText mEtGuid;
private LinearLayout mLlAuthLogin, mLlAuthLogout;
......@@ -86,8 +87,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
mLlAuthLogin.setOnClickListener(this);
mLlAuthLogout = view.findViewById(R.id.ll_auth_logout);
mLlAuthLogout.setOnClickListener(this);
mTvUser = view.findViewById(R.id.tv_login);
if (!WarplyDBHelper.getInstance(getActivity()).isTableNotEmpty("auth")) {
mTvUser.setVisibility(View.GONE);
mLlAuthLogout.setVisibility(View.GONE);
mLlAuthLogin.setVisibility(View.VISIBLE);
mEtGuid.setVisibility(View.VISIBLE);
......@@ -95,6 +98,14 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
mEtGuid.setVisibility(View.GONE);
mLlAuthLogin.setVisibility(View.GONE);
mLlAuthLogout.setVisibility(View.VISIBLE);
mTvUser.setVisibility(View.VISIBLE);
if (WarplyManagerHelper.getConsumerInternal() != null) {
JSONObject profMetadata = WarpJSONParser.getJSONFromString(WarplyManagerHelper.getConsumerInternal().getProfileMetadata());
if (profMetadata != null && profMetadata.has("guid")) {
String userGuid = profMetadata.optString("guid", "");
mTvUser.setText(userGuid);
}
}
}
}
......@@ -105,10 +116,22 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
@Override
public void onRefresh() {
WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
WarplyManager.getCampaigns(mCampaignsCallback);
WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
mSwipeRefresh.setRefreshing(false);
if (WarplyManagerHelper.getConsumerInternal() != null) {
JSONObject profMetadata = WarpJSONParser.getJSONFromString(WarplyManagerHelper.getConsumerInternal().getProfileMetadata());
if (profMetadata != null && profMetadata.has("guid")) {
String userGuid = profMetadata.optString("guid", "");
mTvUser.setText(userGuid);
}
}
if (WarplyDBHelper.getInstance(getActivity()).isTableNotEmpty("auth")) {
WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
WarplyManager.getCampaigns(mCampaignsCallback);
WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
mSwipeRefresh.setRefreshing(false);
} else {
mSwipeRefresh.setRefreshing(false);
}
}
@Override
......@@ -181,6 +204,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
private final CallbackReceiver<JSONObject> mLogoutReceiver = new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
mTvUser.setVisibility(View.GONE);
mPbLoading.setVisibility(View.GONE);
mLlAuthLogout.setVisibility(View.GONE);
mLlAuthLogin.setVisibility(View.VISIBLE);
......@@ -202,11 +226,18 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
mLlAuthLogin.setVisibility(View.GONE);
mEtGuid.setVisibility(View.GONE);
mLlAuthLogout.setVisibility(View.VISIBLE);
if (result != null && result.optInt("status") == 1) {
WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
WarplyManager.getCampaigns(mCampaignsCallback);
WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
}
mTvUser.setVisibility(View.VISIBLE);
// if (WarplyManagerHelper.getConsumerInternal() != null) {
// JSONObject profMetadata = WarpJSONParser.getJSONFromString(WarplyManagerHelper.getConsumerInternal().getProfileMetadata());
// if (profMetadata != null && profMetadata.has("guid")) {
// String userGuid = profMetadata.optString("guid", "");
// mTvUser.setText(userGuid);
// }
// }
WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
WarplyManager.getCampaigns(mCampaignsCallback);
WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
}
@Override
......
......@@ -484,7 +484,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
Handler mUIHandler = new Handler(Looper.getMainLooper());
mUIHandler.post(() -> {
// if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() > 0)
mTvUnifiedCountBadge.setText(String.valueOf(WarplyManagerHelper.getMarketCouponsList().size() + WarplyManagerHelper.getSmCouponsList().size()));
mTvUnifiedCountBadge.setText(String.valueOf(WarplyManagerHelper.getMarketCouponsList().size() + WarplyManagerHelper.getSmCouponsList().size()));
// else
// mTvUnifiedCountBadge.setText("0");
// checkHistoryEmpty();
......@@ -528,6 +528,10 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
tileUnified.setCount(0);
tileUnified.setWeight(2);
}
if (WarplyManagerHelper.getSmCouponsList() != null && WarplyManagerHelper.getSmCouponsList().size() > 0) {
int smTileCount = tileUnified.getCount();
tileUnified.setCount(smTileCount + WarplyManagerHelper.getSmCouponsList().size());
}
mSortTileList.add(tileUnified);
SortTileModel tileCoupons = new SortTileModel();
......@@ -683,31 +687,35 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
// }
/** Deals Badge */
if (WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() > 0)
if (WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() > 0) {
mTvDealsCountBadge.setText(String.valueOf(WarplyManagerHelper.getActiveDFYCoupons().size()));
else
} else {
mTvDealsCountBadge.setText("0");
}
/** Deals Badge */
/** Unified Coupons List */
// if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() > 0)
mTvUnifiedCountBadge.setText(String.valueOf(WarplyManagerHelper.getMarketCouponsList().size() + WarplyManagerHelper.getSmCouponsList().size()));
// else
// if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() > 0){
mTvUnifiedCountBadge.setText(String.valueOf(WarplyManagerHelper.getMarketCouponsList().size() + WarplyManagerHelper.getSmCouponsList().size()));
// }else{
// mTvUnifiedCountBadge.setText("0");
// }
/** Unified Coupons List */
/** Coupon List */
if (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() > 0)
if (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() > 0) {
mTvGiftsCountBadge.setText(String.valueOf(WarplyManagerHelper.getCouponList().size()));
else
} else {
mTvGiftsCountBadge.setText("0");
}
/** Coupon List */
/** Box Badge */
if (WarplyManagerHelper.getActiveBoxCoupons() != null && WarplyManagerHelper.getActiveBoxCoupons().size() > 0)
if (WarplyManagerHelper.getActiveBoxCoupons() != null && WarplyManagerHelper.getActiveBoxCoupons().size() > 0) {
mTvBoxCountBadge.setText(String.valueOf(WarplyManagerHelper.getActiveBoxCoupons().size()));
else
} else {
mTvBoxCountBadge.setText("0");
}
/** Deals Badge */
/** Empty View */
......@@ -796,6 +804,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
mLlVouchersSpinner.setVisibility(View.GONE);
if ((WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() == 0)
&& (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() == 0)
&& (WarplyManagerHelper.getSmCouponsList() != null && WarplyManagerHelper.getSmCouponsList().size() > 0)
&& (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() == 0)
&& checkHistoryEmpty()) {
/** Hide all and show empty view */
......@@ -827,6 +836,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
mLlVouchersDisabled.setVisibility(View.GONE);
if ((WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() == 0)
&& (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() == 0)
&& (WarplyManagerHelper.getSmCouponsList() != null && WarplyManagerHelper.getSmCouponsList().size() > 0)
&& (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() == 0)
&& checkHistoryEmpty()) {
/** Hide loyalty banners and hide separator */
......@@ -852,6 +862,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
mLlVouchersDisabled.setVisibility(View.VISIBLE);
if ((WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() == 0)
&& (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() == 0)
&& (WarplyManagerHelper.getSmCouponsList() != null && WarplyManagerHelper.getSmCouponsList().size() > 0)
&& (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() == 0)
&& checkHistoryEmpty()) {
/** Hide loyalty banners and hide empty view and hide disabled separator */
......
package ly.warp.sdk.services;
import android.content.Context;
import androidx.annotation.NonNull;
import androidx.work.Worker;
import androidx.work.WorkerParameters;
import org.greenrobot.eventbus.EventBus;
import ly.warp.sdk.io.models.RefreshVouchersEventModel;
import ly.warp.sdk.utils.managers.WarplyEventBusManager;
/**
* Created by Panagiotis Triantafyllou on 18/Sept/2023.
*/
public class EventUnifiedCouponsRefreshService extends Worker {
public EventUnifiedCouponsRefreshService(@NonNull Context context, @NonNull WorkerParameters workerParams) {
super(context, workerParams);
}
@NonNull
@Override
public Result doWork() {
RefreshVouchersEventModel vouchersRefreshed = new RefreshVouchersEventModel();
EventBus.getDefault().post(new WarplyEventBusManager(vouchersRefreshed));
return Result.success();
}
}
......@@ -157,7 +157,6 @@ import ly.warp.sdk.io.request.WarplyVerifyOTPRequest;
import ly.warp.sdk.io.request.WarplyVerifyTicketRequest;
import ly.warp.sdk.io.volley.ApiClient;
import ly.warp.sdk.io.volley.ApiService;
import ly.warp.sdk.services.EventCampaignService;
import ly.warp.sdk.services.EventRewardsCouponsService;
import ly.warp.sdk.services.EventUnifiedCouponsService;
import ly.warp.sdk.utils.WarpJSONParser;
......@@ -3243,7 +3242,7 @@ public class WarplyManager {
});
}
public static void createUnifiedCoupon(JSONArray couponCodes, final CallbackReceiver<ArrayList<UnifiedCoupon>> receiver) {
public static void createUnifiedCoupon(JSONArray couponCodes, final CallbackReceiver<JSONObject> receiver) {
WarpUtils.log("************* WARPLY Create Unified Coupons Request ********************");
WarpUtils.log("[WARP Trace] WARPLY Create Unified Coupons Request is active");
WarpUtils.log("**************************************************");
......@@ -3266,6 +3265,8 @@ public class WarplyManager {
RefreshUnifiedCouponsEventModel couponsRefreshed = new RefreshUnifiedCouponsEventModel();
EventBus.getDefault().post(new WarplyEventBusManager(couponsRefreshed));
receiver.onSuccess(jobjUnifiedResponse);
} else {
LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
dynatraceEvent.setEventName("custom_error_create_unified_loyalty");
......@@ -3426,6 +3427,9 @@ public class WarplyManager {
ArrayList<Coupon> mfinalActiveSMCoupons = new ArrayList<>(allItems);
WarplyManagerHelper.setSmCouponsList(mfinalActiveSMCoupons);
OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventUnifiedCouponsService.class).build();
WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(couponList));
executorService.shutdownNow();
}
......@@ -3435,9 +3439,9 @@ public class WarplyManager {
}
}, executorService);
OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventUnifiedCouponsService.class).build();
WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(couponList));
// OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventUnifiedCouponsService.class).build();
// WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
// new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(couponList));
executor.shutdownNow();
});
} else {
......
......@@ -98,13 +98,12 @@ import ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel;
import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
import ly.warp.sdk.io.models.QuestionnaireEventModel;
import ly.warp.sdk.io.models.RefreshUnifiedCouponsEventModel;
import ly.warp.sdk.io.models.RefreshVouchersEventModel;
import ly.warp.sdk.io.models.UnifiedCoupon;
import ly.warp.sdk.io.models.WarplyCCMSEnabledModel;
import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
import ly.warp.sdk.io.models.WarplyPacingCardEventModel;
import ly.warp.sdk.io.models.WarplyUnifiedActivatedEventModel;
import ly.warp.sdk.services.EventCampaignService;
import ly.warp.sdk.services.EventUnifiedCouponsRefreshService;
import ly.warp.sdk.utils.WarpUtils;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.WarplyProperty;
......@@ -550,11 +549,10 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
Intent intent = new Intent((WarpActivity != null && !WarpActivity.isFinishing()) ? WarpActivity : getContext(), ActiveUnifiedCouponsActivity.class);
getContext().startActivity(intent);
/* New Addition end */
RefreshVouchersEventModel vouchersRefreshed = new RefreshVouchersEventModel();
vouchersRefreshed.setRefreshed(true);
EventBus.getDefault().post(new WarplyEventBusManager(vouchersRefreshed));
OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventUnifiedCouponsRefreshService.class).build();
WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
/* New Addition end */
} else if (parts[1].equals("activeCoupons")) {
WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
WarplyManager.getCampaigns(mCampaignsCallback);
......
......@@ -300,4 +300,25 @@
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<RelativeLayout
android:id="@+id/pb_loading"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:visibility="gone"
tools:visibility="visible"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<ProgressBar
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_centerInParent="true"
android:indeterminate="true"
android:indeterminateTint="@color/cos_green5"
android:indeterminateTintMode="src_atop" />
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......
......@@ -320,4 +320,25 @@
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
<RelativeLayout
android:id="@+id/pb_loading"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:visibility="gone"
tools:visibility="visible"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<ProgressBar
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_centerInParent="true"
android:indeterminate="true"
android:indeterminateTint="@color/cos_green5"
android:indeterminateTintMode="src_atop" />
</RelativeLayout>
</RelativeLayout>
......
......@@ -128,6 +128,17 @@
android:visibility="gone"
tools:visibility="visible"/>
<TextView
android:id="@+id/tv_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_marginStart="16dp"
android:textColor="@color/blue_dark"
android:textSize="20sp"
android:visibility="gone"/>
<LinearLayout
android:id="@+id/ll_auth_login"
android:layout_width="140dp"
......