Panagiotis Triantafyllou

unified coupons basket fixes

...@@ -2,15 +2,26 @@ package warp.ly.android_sdk.activities; ...@@ -2,15 +2,26 @@ package warp.ly.android_sdk.activities;
2 2
3 import android.content.Intent; 3 import android.content.Intent;
4 import android.os.Bundle; 4 import android.os.Bundle;
5 +import android.widget.Toast;
6 +
7 +import org.json.JSONObject;
5 8
6 import java.util.Timer; 9 import java.util.Timer;
7 import java.util.TimerTask; 10 import java.util.TimerTask;
8 11
9 import ly.warp.sdk.Warply; 12 import ly.warp.sdk.Warply;
10 import ly.warp.sdk.activities.BaseFragmentActivity; 13 import ly.warp.sdk.activities.BaseFragmentActivity;
14 +import ly.warp.sdk.db.WarplyDBHelper;
15 +import ly.warp.sdk.io.callbacks.CallbackReceiver;
11 import ly.warp.sdk.io.callbacks.SimpleCallbackReceiver; 16 import ly.warp.sdk.io.callbacks.SimpleCallbackReceiver;
12 import ly.warp.sdk.io.callbacks.WarplyReadyCallback; 17 import ly.warp.sdk.io.callbacks.WarplyReadyCallback;
18 +import ly.warp.sdk.io.models.Consumer;
19 +import ly.warp.sdk.io.request.WarplyConsumerRequest;
20 +import ly.warp.sdk.utils.WarpJSONParser;
21 +import ly.warp.sdk.utils.WarpUtils;
13 import ly.warp.sdk.utils.WarplyInitializer; 22 import ly.warp.sdk.utils.WarplyInitializer;
23 +import ly.warp.sdk.utils.WarplyManagerHelper;
24 +import ly.warp.sdk.utils.managers.WarplyManager;
14 import warp.ly.android_sdk.R; 25 import warp.ly.android_sdk.R;
15 26
16 public class SplashActivity extends BaseActivity { 27 public class SplashActivity extends BaseActivity {
...@@ -25,8 +36,12 @@ public class SplashActivity extends BaseActivity { ...@@ -25,8 +36,12 @@ public class SplashActivity extends BaseActivity {
25 mWarplyInitializer = Warply.getInitializer(this, new WarplyReadyCallback() { 36 mWarplyInitializer = Warply.getInitializer(this, new WarplyReadyCallback() {
26 @Override 37 @Override
27 public void onWarplyReady() { 38 public void onWarplyReady() {
39 + if (WarplyDBHelper.getInstance(SplashActivity.this).isTableNotEmpty("auth")) {
40 + WarplyManager.getConsumer(new WarplyConsumerRequest(), mConsumerCallback);
41 + } else {
28 startNextActivity(); 42 startNextActivity();
29 } 43 }
44 + }
30 45
31 @Override 46 @Override
32 public void onWarplyInitTimeOut() { 47 public void onWarplyInitTimeOut() {
...@@ -76,4 +91,34 @@ public class SplashActivity extends BaseActivity { ...@@ -76,4 +91,34 @@ public class SplashActivity extends BaseActivity {
76 }, MIN_SPLASH_TIME); 91 }, MIN_SPLASH_TIME);
77 } 92 }
78 } 93 }
94 +
95 + private CallbackReceiver<Consumer> mConsumerCallback = new CallbackReceiver<Consumer>() {
96 + @Override
97 + public void onSuccess(Consumer result) {
98 + WarplyManagerHelper.setConsumerInternal(result);
99 +
100 + if (result != null) {
101 + JSONObject profMetadata = WarpJSONParser.getJSONFromString(result.getProfileMetadata());
102 + if (profMetadata != null && profMetadata.has("nonTelco")) {
103 + WarpUtils.setUserNonTelco(Warply.getWarplyContext(), profMetadata.optBoolean("nonTelco"));
104 + } else {
105 + WarpUtils.setUserNonTelco(Warply.getWarplyContext(), false);
106 + }
107 +
108 + if (profMetadata != null) {
109 + if (profMetadata.has("badge")) {
110 + WarpUtils.setUserTag(Warply.getWarplyContext(), profMetadata.optString("badge"));
111 + }
112 + }
113 + }
114 +
115 + startNextActivity();
116 + }
117 +
118 + @Override
119 + public void onFailure(int errorCode) {
120 + startNextActivity();
121 + Toast.makeText(SplashActivity.this, "GET PROFILE ERROR", Toast.LENGTH_SHORT).show();
122 + }
123 + };
79 } 124 }
......
...@@ -19,6 +19,7 @@ import androidx.recyclerview.widget.RecyclerView; ...@@ -19,6 +19,7 @@ import androidx.recyclerview.widget.RecyclerView;
19 import org.greenrobot.eventbus.EventBus; 19 import org.greenrobot.eventbus.EventBus;
20 import org.greenrobot.eventbus.Subscribe; 20 import org.greenrobot.eventbus.Subscribe;
21 import org.json.JSONArray; 21 import org.json.JSONArray;
22 +import org.json.JSONObject;
22 23
23 import java.io.Serializable; 24 import java.io.Serializable;
24 import java.text.ParseException; 25 import java.text.ParseException;
...@@ -63,8 +64,9 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -63,8 +64,9 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
63 private RelativeLayout mRlUnifiedCoupons, mRlActiveUnifiedCoupons; 64 private RelativeLayout mRlUnifiedCoupons, mRlActiveUnifiedCoupons;
64 private ActiveCouponAdapter mAdapterCoupons; 65 private ActiveCouponAdapter mAdapterCoupons;
65 private Set<Coupon> mSelectedItems = new HashSet<>(); 66 private Set<Coupon> mSelectedItems = new HashSet<>();
66 - private LinearLayout mLlActivateunified; 67 + private LinearLayout mLlActivateUnified;
67 private AlertDialog mAlertDialog; 68 private AlertDialog mAlertDialog;
69 + private RelativeLayout mPbLoading;
68 70
69 // =========================================================== 71 // ===========================================================
70 // Methods for/from SuperClass/Interfaces 72 // Methods for/from SuperClass/Interfaces
...@@ -95,8 +97,10 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -95,8 +97,10 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
95 mTvActiveUnifiedCouponsTitle = mClActiveCouponsHeader.findViewById(R.id.tv_active_sm_coupons_title); 97 mTvActiveUnifiedCouponsTitle = mClActiveCouponsHeader.findViewById(R.id.tv_active_sm_coupons_title);
96 mTvChooseAll = mClActiveCouponsHeader.findViewById(R.id.tv_choose_all); 98 mTvChooseAll = mClActiveCouponsHeader.findViewById(R.id.tv_choose_all);
97 mIvChooseAll = mClActiveCouponsHeader.findViewById(R.id.iv_choose_all); 99 mIvChooseAll = mClActiveCouponsHeader.findViewById(R.id.iv_choose_all);
98 - mLlActivateunified = findViewById(R.id.ll_activate_unified); 100 + mLlActivateUnified = findViewById(R.id.ll_activate_unified);
99 - mTvActivate = mLlActivateunified.findViewById(R.id.button_activate); 101 + mTvActivate = mLlActivateUnified.findViewById(R.id.button_activate);
102 + mPbLoading = findViewById(R.id.pb_loading);
103 + mPbLoading.setOnTouchListener((v, event) -> true);
100 WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader, mTvInnerTitle, 104 WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader, mTvInnerTitle,
101 mTvUnifieCouponsTitle, mTvActiveUnifiedCouponsTitle); 105 mTvUnifieCouponsTitle, mTvActiveUnifiedCouponsTitle);
102 WarpUtils.renderCustomFont(this, R.font.peridot_regular, mTvEmptyUnifiedCoupons, mTvInnerSubtitle); 106 WarpUtils.renderCustomFont(this, R.font.peridot_regular, mTvEmptyUnifiedCoupons, mTvInnerSubtitle);
...@@ -113,7 +117,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -113,7 +117,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
113 mUnifiedPressed = false; 117 mUnifiedPressed = false;
114 mActiveUnifiedPressed = false; 118 mActiveUnifiedPressed = false;
115 mIsActivatePressed = false; 119 mIsActivatePressed = false;
116 - filterItems(); 120 + filterItems(false);
117 } 121 }
118 122
119 @Override 123 @Override
...@@ -138,6 +142,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -138,6 +142,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
138 @Subscribe() 142 @Subscribe()
139 public void onMessageEvent(WarplyEventBusManager event) { 143 public void onMessageEvent(WarplyEventBusManager event) {
140 if (event.getRefreshUnifiedCouponsAdded() != null || event.getRefreshVouchersEventModel() != null) { 144 if (event.getRefreshUnifiedCouponsAdded() != null || event.getRefreshVouchersEventModel() != null) {
145 + mPbLoading.setVisibility(View.VISIBLE);
141 WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback); 146 WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
142 } 147 }
143 } 148 }
...@@ -161,12 +166,12 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -161,12 +166,12 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
161 mSelectedItems.clear(); 166 mSelectedItems.clear();
162 mSelectedItems.addAll(mAdapterCoupons.getItems()); 167 mSelectedItems.addAll(mAdapterCoupons.getItems());
163 mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_checked_skyblue); 168 mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_checked_skyblue);
164 - mLlActivateunified.setBackgroundResource(R.drawable.selector_button_green); 169 + mLlActivateUnified.setBackgroundResource(R.drawable.selector_button_green);
165 mAdapterCoupons.updateChecked(mSelectedItems); 170 mAdapterCoupons.updateChecked(mSelectedItems);
166 } else if (mSelectedItems.size() == mAdapterCoupons.getItemCount()) { 171 } else if (mSelectedItems.size() == mAdapterCoupons.getItemCount()) {
167 mSelectedItems.clear(); 172 mSelectedItems.clear();
168 mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_gray); 173 mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_gray);
169 - mLlActivateunified.setBackgroundResource(R.drawable.selector_button_grey_dark); 174 + mLlActivateUnified.setBackgroundResource(R.drawable.selector_button_grey_dark);
170 mAdapterCoupons.updateChecked(mSelectedItems); 175 mAdapterCoupons.updateChecked(mSelectedItems);
171 } 176 }
172 return; 177 return;
...@@ -181,6 +186,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -181,6 +186,7 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
181 tempArray.put(selectedCoupon.getCoupon()); 186 tempArray.put(selectedCoupon.getCoupon());
182 } 187 }
183 188
189 + mPbLoading.setVisibility(View.VISIBLE);
184 WarplyManager.createUnifiedCoupon(tempArray, mCreateUnifiedCallback); 190 WarplyManager.createUnifiedCoupon(tempArray, mCreateUnifiedCallback);
185 } 191 }
186 } 192 }
...@@ -197,19 +203,22 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -197,19 +203,22 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
197 mIvInfoClose.setOnClickListener(this); 203 mIvInfoClose.setOnClickListener(this);
198 mTvInnerClose.setOnClickListener(this); 204 mTvInnerClose.setOnClickListener(this);
199 mIvChooseAll.setOnClickListener(this); 205 mIvChooseAll.setOnClickListener(this);
200 - mLlActivateunified.setOnClickListener(this); 206 + mLlActivateUnified.setOnClickListener(this);
201 } 207 }
202 208
203 - private void filterItems() { 209 + private void filterItems(boolean isFromEvent) {
204 mClInfoView.setVisibility(View.GONE); 210 mClInfoView.setVisibility(View.GONE);
205 mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_gray); 211 mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_gray);
206 - mLlActivateunified.setBackgroundResource(R.drawable.selector_button_grey_dark); 212 + mLlActivateUnified.setBackgroundResource(R.drawable.selector_button_grey_dark);
207 mSelectedItems.clear(); 213 mSelectedItems.clear();
208 214
209 if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().isEmpty() 215 if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().isEmpty()
210 && WarplyManagerHelper.getSmCouponsList() != null && WarplyManagerHelper.getSmCouponsList().isEmpty()) { 216 && WarplyManagerHelper.getSmCouponsList() != null && WarplyManagerHelper.getSmCouponsList().isEmpty()) {
217 + mLlActivateUnified.setVisibility(View.GONE);
211 mTvEmptyUnifiedCoupons.setVisibility(View.VISIBLE); 218 mTvEmptyUnifiedCoupons.setVisibility(View.VISIBLE);
212 - mLlActivateunified.setVisibility(View.GONE); 219 + } else {
220 + mTvEmptyUnifiedCoupons.setVisibility(View.GONE);
221 + mLlActivateUnified.setVisibility(View.VISIBLE);
213 } 222 }
214 223
215 224
...@@ -291,15 +300,19 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -291,15 +300,19 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
291 } 300 }
292 301
293 if (mSelectedItems.isEmpty()) { 302 if (mSelectedItems.isEmpty()) {
294 - mLlActivateunified.setBackgroundResource(R.drawable.selector_button_grey_dark); 303 + mLlActivateUnified.setBackgroundResource(R.drawable.selector_button_grey_dark);
295 } else { 304 } else {
296 - mLlActivateunified.setBackgroundResource(R.drawable.selector_button_green); 305 + mLlActivateUnified.setBackgroundResource(R.drawable.selector_button_green);
297 } 306 }
298 }) 307 })
299 .doOnError(error -> { 308 .doOnError(error -> {
300 }) 309 })
301 .subscribe(); 310 .subscribe();
302 311
312 + if (isFromEvent) {
313 + mAdapterCoupons.notifyDataSetChanged();
314 + }
315 +
303 mRlActiveUnifiedCoupons.setVisibility(View.VISIBLE); 316 mRlActiveUnifiedCoupons.setVisibility(View.VISIBLE);
304 } else { 317 } else {
305 mRlActiveUnifiedCoupons.setVisibility(View.GONE); 318 mRlActiveUnifiedCoupons.setVisibility(View.GONE);
...@@ -314,20 +327,26 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -314,20 +327,26 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
314 @Override 327 @Override
315 public void onSuccess(ArrayList<UnifiedCoupon> result) { 328 public void onSuccess(ArrayList<UnifiedCoupon> result) {
316 Handler mUIHandler = new Handler(Looper.getMainLooper()); 329 Handler mUIHandler = new Handler(Looper.getMainLooper());
317 - mUIHandler.post(ActiveUnifiedCouponsActivity.this::filterItems); 330 + mUIHandler.post(() -> {
331 + mPbLoading.setVisibility(View.GONE);
332 + filterItems(true);
333 + });
318 } 334 }
319 335
320 @Override 336 @Override
321 public void onFailure(int errorCode) { 337 public void onFailure(int errorCode) {
322 - 338 + Handler mUIHandler = new Handler(Looper.getMainLooper());
339 + mUIHandler.post(() -> mPbLoading.setVisibility(View.GONE));
323 } 340 }
324 }; 341 };
325 342
326 - private final CallbackReceiver<ArrayList<UnifiedCoupon>> mCreateUnifiedCallback = new CallbackReceiver<ArrayList<UnifiedCoupon>>() { 343 + private final CallbackReceiver<JSONObject> mCreateUnifiedCallback = new CallbackReceiver<JSONObject>() {
327 @Override 344 @Override
328 - public void onSuccess(ArrayList<UnifiedCoupon> result) { 345 + public void onSuccess(JSONObject result) {
346 + mIsActivatePressed = false;
347 + mPbLoading.setVisibility(View.GONE);
329 mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_gray); 348 mIvChooseAll.setBackgroundResource(R.drawable.ic_circle_gray);
330 - mLlActivateunified.setBackgroundResource(R.drawable.selector_button_grey_dark); 349 + mLlActivateUnified.setBackgroundResource(R.drawable.selector_button_grey_dark);
331 mSelectedItems.clear(); 350 mSelectedItems.clear();
332 351
333 if (!isFinishing()) { 352 if (!isFinishing()) {
...@@ -343,6 +362,9 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli ...@@ -343,6 +362,9 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
343 362
344 @Override 363 @Override
345 public void onFailure(int errorCode) { 364 public void onFailure(int errorCode) {
365 + mIsActivatePressed = false;
366 + mPbLoading.setVisibility(View.GONE);
367 +
346 if (!isFinishing()) { 368 if (!isFinishing()) {
347 mAlertDialog = new AlertDialog.Builder(ActiveUnifiedCouponsActivity.this) 369 mAlertDialog = new AlertDialog.Builder(ActiveUnifiedCouponsActivity.this)
348 .setTitle(R.string.cos_dlg_error_unified_title) 370 .setTitle(R.string.cos_dlg_error_unified_title)
......
...@@ -12,6 +12,7 @@ import android.view.View; ...@@ -12,6 +12,7 @@ import android.view.View;
12 import android.view.ViewGroup; 12 import android.view.ViewGroup;
13 import android.widget.ImageView; 13 import android.widget.ImageView;
14 import android.widget.LinearLayout; 14 import android.widget.LinearLayout;
15 +import android.widget.RelativeLayout;
15 import android.widget.TextView; 16 import android.widget.TextView;
16 17
17 import androidx.appcompat.app.AlertDialog; 18 import androidx.appcompat.app.AlertDialog;
...@@ -76,6 +77,7 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL ...@@ -76,6 +77,7 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
76 private ActiveCouponAdapter mAdapterCoupons; 77 private ActiveCouponAdapter mAdapterCoupons;
77 private AlertDialog mErrorAlertDialog, mSuccessAlertDialog, mAskCancelUnifiedAlertDialog; 78 private AlertDialog mErrorAlertDialog, mSuccessAlertDialog, mAskCancelUnifiedAlertDialog;
78 private JSONArray mBottomSheetData; 79 private JSONArray mBottomSheetData;
80 + private RelativeLayout mPbLoading;
79 81
80 // =========================================================== 82 // ===========================================================
81 // Methods for/from SuperClass/Interfaces 83 // Methods for/from SuperClass/Interfaces
...@@ -120,6 +122,8 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL ...@@ -120,6 +122,8 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
120 mFontShopsLabel = findViewById(R.id.shops_label); 122 mFontShopsLabel = findViewById(R.id.shops_label);
121 mFontCancelLabel = findViewById(R.id.cancel_label); 123 mFontCancelLabel = findViewById(R.id.cancel_label);
122 mTvBarcodeTitle = findViewById(R.id.tv_barcode_title); 124 mTvBarcodeTitle = findViewById(R.id.tv_barcode_title);
125 + mPbLoading = findViewById(R.id.pb_loading);
126 + mPbLoading.setOnTouchListener((v, event) -> true);
123 WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader, mFontSMLabel); 127 WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader, mFontSMLabel);
124 WarpUtils.renderCustomFont(this, R.font.peridot_regular, mTvActiveValue, 128 WarpUtils.renderCustomFont(this, R.font.peridot_regular, mTvActiveValue,
125 mTvTermsValue); 129 mTvTermsValue);
...@@ -420,6 +424,7 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL ...@@ -420,6 +424,7 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
420 424
421 if (TextUtils.isEmpty(transactionID)) return; 425 if (TextUtils.isEmpty(transactionID)) return;
422 426
427 + mPbLoading.setVisibility(View.VISIBLE);
423 WarplyManager.cancelUnifiedCoupon(transactionID, mCancelUnifiedCallback); 428 WarplyManager.cancelUnifiedCoupon(transactionID, mCancelUnifiedCallback);
424 } 429 }
425 430
...@@ -470,11 +475,13 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL ...@@ -470,11 +475,13 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
470 private final CallbackReceiver<Integer> mCancelUnifiedCallback = new CallbackReceiver<Integer>() { 475 private final CallbackReceiver<Integer> mCancelUnifiedCallback = new CallbackReceiver<Integer>() {
471 @Override 476 @Override
472 public void onSuccess(Integer result) { 477 public void onSuccess(Integer result) {
478 + mPbLoading.setVisibility(View.GONE);
473 successDialog(); 479 successDialog();
474 } 480 }
475 481
476 @Override 482 @Override
477 public void onFailure(int errorCode) { 483 public void onFailure(int errorCode) {
484 + mPbLoading.setVisibility(View.GONE);
478 errorDialog(); 485 errorDialog();
479 } 486 }
480 }; 487 };
......
...@@ -28,6 +28,7 @@ import ly.warp.sdk.io.callbacks.CallbackReceiver; ...@@ -28,6 +28,7 @@ import ly.warp.sdk.io.callbacks.CallbackReceiver;
28 import ly.warp.sdk.io.models.Campaign; 28 import ly.warp.sdk.io.models.Campaign;
29 import ly.warp.sdk.io.models.CouponList; 29 import ly.warp.sdk.io.models.CouponList;
30 import ly.warp.sdk.io.models.UnifiedCoupon; 30 import ly.warp.sdk.io.models.UnifiedCoupon;
31 +import ly.warp.sdk.utils.WarpJSONParser;
31 import ly.warp.sdk.utils.WarplyManagerHelper; 32 import ly.warp.sdk.utils.WarplyManagerHelper;
32 import ly.warp.sdk.utils.managers.WarplyManager; 33 import ly.warp.sdk.utils.managers.WarplyManager;
33 34
...@@ -35,7 +36,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -35,7 +36,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
35 36
36 private RelativeLayout mOptionOne, mOptionTwo, mOptionThree, mRlDriving, 37 private RelativeLayout mOptionOne, mOptionTwo, mOptionThree, mRlDriving,
37 mRlDrivingHistory, mPbLoading; 38 mRlDrivingHistory, mPbLoading;
38 - private TextView mTvUsername; 39 + private TextView mTvUsername, mTvUser;
39 private SwipeRefreshLayout mSwipeRefresh; 40 private SwipeRefreshLayout mSwipeRefresh;
40 private EditText mEtGuid; 41 private EditText mEtGuid;
41 private LinearLayout mLlAuthLogin, mLlAuthLogout; 42 private LinearLayout mLlAuthLogin, mLlAuthLogout;
...@@ -86,8 +87,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -86,8 +87,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
86 mLlAuthLogin.setOnClickListener(this); 87 mLlAuthLogin.setOnClickListener(this);
87 mLlAuthLogout = view.findViewById(R.id.ll_auth_logout); 88 mLlAuthLogout = view.findViewById(R.id.ll_auth_logout);
88 mLlAuthLogout.setOnClickListener(this); 89 mLlAuthLogout.setOnClickListener(this);
90 + mTvUser = view.findViewById(R.id.tv_login);
89 91
90 if (!WarplyDBHelper.getInstance(getActivity()).isTableNotEmpty("auth")) { 92 if (!WarplyDBHelper.getInstance(getActivity()).isTableNotEmpty("auth")) {
93 + mTvUser.setVisibility(View.GONE);
91 mLlAuthLogout.setVisibility(View.GONE); 94 mLlAuthLogout.setVisibility(View.GONE);
92 mLlAuthLogin.setVisibility(View.VISIBLE); 95 mLlAuthLogin.setVisibility(View.VISIBLE);
93 mEtGuid.setVisibility(View.VISIBLE); 96 mEtGuid.setVisibility(View.VISIBLE);
...@@ -95,6 +98,14 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -95,6 +98,14 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
95 mEtGuid.setVisibility(View.GONE); 98 mEtGuid.setVisibility(View.GONE);
96 mLlAuthLogin.setVisibility(View.GONE); 99 mLlAuthLogin.setVisibility(View.GONE);
97 mLlAuthLogout.setVisibility(View.VISIBLE); 100 mLlAuthLogout.setVisibility(View.VISIBLE);
101 + mTvUser.setVisibility(View.VISIBLE);
102 + if (WarplyManagerHelper.getConsumerInternal() != null) {
103 + JSONObject profMetadata = WarpJSONParser.getJSONFromString(WarplyManagerHelper.getConsumerInternal().getProfileMetadata());
104 + if (profMetadata != null && profMetadata.has("guid")) {
105 + String userGuid = profMetadata.optString("guid", "");
106 + mTvUser.setText(userGuid);
107 + }
108 + }
98 } 109 }
99 } 110 }
100 111
...@@ -105,10 +116,22 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -105,10 +116,22 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
105 116
106 @Override 117 @Override
107 public void onRefresh() { 118 public void onRefresh() {
119 + if (WarplyManagerHelper.getConsumerInternal() != null) {
120 + JSONObject profMetadata = WarpJSONParser.getJSONFromString(WarplyManagerHelper.getConsumerInternal().getProfileMetadata());
121 + if (profMetadata != null && profMetadata.has("guid")) {
122 + String userGuid = profMetadata.optString("guid", "");
123 + mTvUser.setText(userGuid);
124 + }
125 + }
126 +
127 + if (WarplyDBHelper.getInstance(getActivity()).isTableNotEmpty("auth")) {
108 WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); 128 WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
109 WarplyManager.getCampaigns(mCampaignsCallback); 129 WarplyManager.getCampaigns(mCampaignsCallback);
110 WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback); 130 WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
111 mSwipeRefresh.setRefreshing(false); 131 mSwipeRefresh.setRefreshing(false);
132 + } else {
133 + mSwipeRefresh.setRefreshing(false);
134 + }
112 } 135 }
113 136
114 @Override 137 @Override
...@@ -181,6 +204,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -181,6 +204,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
181 private final CallbackReceiver<JSONObject> mLogoutReceiver = new CallbackReceiver<JSONObject>() { 204 private final CallbackReceiver<JSONObject> mLogoutReceiver = new CallbackReceiver<JSONObject>() {
182 @Override 205 @Override
183 public void onSuccess(JSONObject result) { 206 public void onSuccess(JSONObject result) {
207 + mTvUser.setVisibility(View.GONE);
184 mPbLoading.setVisibility(View.GONE); 208 mPbLoading.setVisibility(View.GONE);
185 mLlAuthLogout.setVisibility(View.GONE); 209 mLlAuthLogout.setVisibility(View.GONE);
186 mLlAuthLogin.setVisibility(View.VISIBLE); 210 mLlAuthLogin.setVisibility(View.VISIBLE);
...@@ -202,12 +226,19 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip ...@@ -202,12 +226,19 @@ public class HomeFragment extends Fragment implements View.OnClickListener, Swip
202 mLlAuthLogin.setVisibility(View.GONE); 226 mLlAuthLogin.setVisibility(View.GONE);
203 mEtGuid.setVisibility(View.GONE); 227 mEtGuid.setVisibility(View.GONE);
204 mLlAuthLogout.setVisibility(View.VISIBLE); 228 mLlAuthLogout.setVisibility(View.VISIBLE);
205 - if (result != null && result.optInt("status") == 1) { 229 + mTvUser.setVisibility(View.VISIBLE);
230 +// if (WarplyManagerHelper.getConsumerInternal() != null) {
231 +// JSONObject profMetadata = WarpJSONParser.getJSONFromString(WarplyManagerHelper.getConsumerInternal().getProfileMetadata());
232 +// if (profMetadata != null && profMetadata.has("guid")) {
233 +// String userGuid = profMetadata.optString("guid", "");
234 +// mTvUser.setText(userGuid);
235 +// }
236 +// }
237 +
206 WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); 238 WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
207 WarplyManager.getCampaigns(mCampaignsCallback); 239 WarplyManager.getCampaigns(mCampaignsCallback);
208 WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback); 240 WarplyManager.getUnifiedCouponsDeals(mUnifiedCallback);
209 } 241 }
210 - }
211 242
212 @Override 243 @Override
213 public void onFailure(int errorCode) { 244 public void onFailure(int errorCode) {
......
...@@ -528,6 +528,10 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener ...@@ -528,6 +528,10 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
528 tileUnified.setCount(0); 528 tileUnified.setCount(0);
529 tileUnified.setWeight(2); 529 tileUnified.setWeight(2);
530 } 530 }
531 + if (WarplyManagerHelper.getSmCouponsList() != null && WarplyManagerHelper.getSmCouponsList().size() > 0) {
532 + int smTileCount = tileUnified.getCount();
533 + tileUnified.setCount(smTileCount + WarplyManagerHelper.getSmCouponsList().size());
534 + }
531 mSortTileList.add(tileUnified); 535 mSortTileList.add(tileUnified);
532 536
533 SortTileModel tileCoupons = new SortTileModel(); 537 SortTileModel tileCoupons = new SortTileModel();
...@@ -683,31 +687,35 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener ...@@ -683,31 +687,35 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
683 // } 687 // }
684 688
685 /** Deals Badge */ 689 /** Deals Badge */
686 - if (WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() > 0) 690 + if (WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() > 0) {
687 mTvDealsCountBadge.setText(String.valueOf(WarplyManagerHelper.getActiveDFYCoupons().size())); 691 mTvDealsCountBadge.setText(String.valueOf(WarplyManagerHelper.getActiveDFYCoupons().size()));
688 - else 692 + } else {
689 mTvDealsCountBadge.setText("0"); 693 mTvDealsCountBadge.setText("0");
694 + }
690 /** Deals Badge */ 695 /** Deals Badge */
691 696
692 /** Unified Coupons List */ 697 /** Unified Coupons List */
693 -// if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() > 0) 698 +// if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() > 0){
694 mTvUnifiedCountBadge.setText(String.valueOf(WarplyManagerHelper.getMarketCouponsList().size() + WarplyManagerHelper.getSmCouponsList().size())); 699 mTvUnifiedCountBadge.setText(String.valueOf(WarplyManagerHelper.getMarketCouponsList().size() + WarplyManagerHelper.getSmCouponsList().size()));
695 -// else 700 +// }else{
696 // mTvUnifiedCountBadge.setText("0"); 701 // mTvUnifiedCountBadge.setText("0");
702 +// }
697 /** Unified Coupons List */ 703 /** Unified Coupons List */
698 704
699 /** Coupon List */ 705 /** Coupon List */
700 - if (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() > 0) 706 + if (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() > 0) {
701 mTvGiftsCountBadge.setText(String.valueOf(WarplyManagerHelper.getCouponList().size())); 707 mTvGiftsCountBadge.setText(String.valueOf(WarplyManagerHelper.getCouponList().size()));
702 - else 708 + } else {
703 mTvGiftsCountBadge.setText("0"); 709 mTvGiftsCountBadge.setText("0");
710 + }
704 /** Coupon List */ 711 /** Coupon List */
705 712
706 /** Box Badge */ 713 /** Box Badge */
707 - if (WarplyManagerHelper.getActiveBoxCoupons() != null && WarplyManagerHelper.getActiveBoxCoupons().size() > 0) 714 + if (WarplyManagerHelper.getActiveBoxCoupons() != null && WarplyManagerHelper.getActiveBoxCoupons().size() > 0) {
708 mTvBoxCountBadge.setText(String.valueOf(WarplyManagerHelper.getActiveBoxCoupons().size())); 715 mTvBoxCountBadge.setText(String.valueOf(WarplyManagerHelper.getActiveBoxCoupons().size()));
709 - else 716 + } else {
710 mTvBoxCountBadge.setText("0"); 717 mTvBoxCountBadge.setText("0");
718 + }
711 /** Deals Badge */ 719 /** Deals Badge */
712 720
713 /** Empty View */ 721 /** Empty View */
...@@ -796,6 +804,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener ...@@ -796,6 +804,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
796 mLlVouchersSpinner.setVisibility(View.GONE); 804 mLlVouchersSpinner.setVisibility(View.GONE);
797 if ((WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() == 0) 805 if ((WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() == 0)
798 && (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() == 0) 806 && (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() == 0)
807 + && (WarplyManagerHelper.getSmCouponsList() != null && WarplyManagerHelper.getSmCouponsList().size() > 0)
799 && (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() == 0) 808 && (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() == 0)
800 && checkHistoryEmpty()) { 809 && checkHistoryEmpty()) {
801 /** Hide all and show empty view */ 810 /** Hide all and show empty view */
...@@ -827,6 +836,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener ...@@ -827,6 +836,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
827 mLlVouchersDisabled.setVisibility(View.GONE); 836 mLlVouchersDisabled.setVisibility(View.GONE);
828 if ((WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() == 0) 837 if ((WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() == 0)
829 && (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() == 0) 838 && (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() == 0)
839 + && (WarplyManagerHelper.getSmCouponsList() != null && WarplyManagerHelper.getSmCouponsList().size() > 0)
830 && (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() == 0) 840 && (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() == 0)
831 && checkHistoryEmpty()) { 841 && checkHistoryEmpty()) {
832 /** Hide loyalty banners and hide separator */ 842 /** Hide loyalty banners and hide separator */
...@@ -852,6 +862,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener ...@@ -852,6 +862,7 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
852 mLlVouchersDisabled.setVisibility(View.VISIBLE); 862 mLlVouchersDisabled.setVisibility(View.VISIBLE);
853 if ((WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() == 0) 863 if ((WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() == 0)
854 && (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() == 0) 864 && (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() == 0)
865 + && (WarplyManagerHelper.getSmCouponsList() != null && WarplyManagerHelper.getSmCouponsList().size() > 0)
855 && (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() == 0) 866 && (WarplyManagerHelper.getCouponList() != null && WarplyManagerHelper.getCouponList().size() == 0)
856 && checkHistoryEmpty()) { 867 && checkHistoryEmpty()) {
857 /** Hide loyalty banners and hide empty view and hide disabled separator */ 868 /** Hide loyalty banners and hide empty view and hide disabled separator */
......
1 +package ly.warp.sdk.services;
2 +
3 +import android.content.Context;
4 +
5 +import androidx.annotation.NonNull;
6 +import androidx.work.Worker;
7 +import androidx.work.WorkerParameters;
8 +
9 +import org.greenrobot.eventbus.EventBus;
10 +
11 +import ly.warp.sdk.io.models.RefreshVouchersEventModel;
12 +import ly.warp.sdk.utils.managers.WarplyEventBusManager;
13 +
14 +/**
15 + * Created by Panagiotis Triantafyllou on 18/Sept/2023.
16 + */
17 +public class EventUnifiedCouponsRefreshService extends Worker {
18 +
19 + public EventUnifiedCouponsRefreshService(@NonNull Context context, @NonNull WorkerParameters workerParams) {
20 + super(context, workerParams);
21 + }
22 +
23 + @NonNull
24 + @Override
25 + public Result doWork() {
26 + RefreshVouchersEventModel vouchersRefreshed = new RefreshVouchersEventModel();
27 + EventBus.getDefault().post(new WarplyEventBusManager(vouchersRefreshed));
28 +
29 + return Result.success();
30 + }
31 +}
...@@ -157,7 +157,6 @@ import ly.warp.sdk.io.request.WarplyVerifyOTPRequest; ...@@ -157,7 +157,6 @@ import ly.warp.sdk.io.request.WarplyVerifyOTPRequest;
157 import ly.warp.sdk.io.request.WarplyVerifyTicketRequest; 157 import ly.warp.sdk.io.request.WarplyVerifyTicketRequest;
158 import ly.warp.sdk.io.volley.ApiClient; 158 import ly.warp.sdk.io.volley.ApiClient;
159 import ly.warp.sdk.io.volley.ApiService; 159 import ly.warp.sdk.io.volley.ApiService;
160 -import ly.warp.sdk.services.EventCampaignService;
161 import ly.warp.sdk.services.EventRewardsCouponsService; 160 import ly.warp.sdk.services.EventRewardsCouponsService;
162 import ly.warp.sdk.services.EventUnifiedCouponsService; 161 import ly.warp.sdk.services.EventUnifiedCouponsService;
163 import ly.warp.sdk.utils.WarpJSONParser; 162 import ly.warp.sdk.utils.WarpJSONParser;
...@@ -3243,7 +3242,7 @@ public class WarplyManager { ...@@ -3243,7 +3242,7 @@ public class WarplyManager {
3243 }); 3242 });
3244 } 3243 }
3245 3244
3246 - public static void createUnifiedCoupon(JSONArray couponCodes, final CallbackReceiver<ArrayList<UnifiedCoupon>> receiver) { 3245 + public static void createUnifiedCoupon(JSONArray couponCodes, final CallbackReceiver<JSONObject> receiver) {
3247 WarpUtils.log("************* WARPLY Create Unified Coupons Request ********************"); 3246 WarpUtils.log("************* WARPLY Create Unified Coupons Request ********************");
3248 WarpUtils.log("[WARP Trace] WARPLY Create Unified Coupons Request is active"); 3247 WarpUtils.log("[WARP Trace] WARPLY Create Unified Coupons Request is active");
3249 WarpUtils.log("**************************************************"); 3248 WarpUtils.log("**************************************************");
...@@ -3266,6 +3265,8 @@ public class WarplyManager { ...@@ -3266,6 +3265,8 @@ public class WarplyManager {
3266 3265
3267 RefreshUnifiedCouponsEventModel couponsRefreshed = new RefreshUnifiedCouponsEventModel(); 3266 RefreshUnifiedCouponsEventModel couponsRefreshed = new RefreshUnifiedCouponsEventModel();
3268 EventBus.getDefault().post(new WarplyEventBusManager(couponsRefreshed)); 3267 EventBus.getDefault().post(new WarplyEventBusManager(couponsRefreshed));
3268 +
3269 + receiver.onSuccess(jobjUnifiedResponse);
3269 } else { 3270 } else {
3270 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel(); 3271 LoyaltySDKDynatraceEventModel dynatraceEvent = new LoyaltySDKDynatraceEventModel();
3271 dynatraceEvent.setEventName("custom_error_create_unified_loyalty"); 3272 dynatraceEvent.setEventName("custom_error_create_unified_loyalty");
...@@ -3426,6 +3427,9 @@ public class WarplyManager { ...@@ -3426,6 +3427,9 @@ public class WarplyManager {
3426 ArrayList<Coupon> mfinalActiveSMCoupons = new ArrayList<>(allItems); 3427 ArrayList<Coupon> mfinalActiveSMCoupons = new ArrayList<>(allItems);
3427 3428
3428 WarplyManagerHelper.setSmCouponsList(mfinalActiveSMCoupons); 3429 WarplyManagerHelper.setSmCouponsList(mfinalActiveSMCoupons);
3430 + OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventUnifiedCouponsService.class).build();
3431 + WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
3432 + new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(couponList));
3429 executorService.shutdownNow(); 3433 executorService.shutdownNow();
3430 } 3434 }
3431 3435
...@@ -3435,9 +3439,9 @@ public class WarplyManager { ...@@ -3435,9 +3439,9 @@ public class WarplyManager {
3435 } 3439 }
3436 }, executorService); 3440 }, executorService);
3437 3441
3438 - OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventUnifiedCouponsService.class).build(); 3442 +// OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventUnifiedCouponsService.class).build();
3439 - WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork); 3443 +// WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
3440 - new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(couponList)); 3444 +// new Handler(Looper.getMainLooper()).post(() -> receiver.onSuccess(couponList));
3441 executor.shutdownNow(); 3445 executor.shutdownNow();
3442 }); 3446 });
3443 } else { 3447 } else {
......
...@@ -98,13 +98,12 @@ import ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel; ...@@ -98,13 +98,12 @@ import ly.warp.sdk.io.models.LoyaltySDKDynatraceEventModel;
98 import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel; 98 import ly.warp.sdk.io.models.LoyaltySDKFirebaseEventModel;
99 import ly.warp.sdk.io.models.QuestionnaireEventModel; 99 import ly.warp.sdk.io.models.QuestionnaireEventModel;
100 import ly.warp.sdk.io.models.RefreshUnifiedCouponsEventModel; 100 import ly.warp.sdk.io.models.RefreshUnifiedCouponsEventModel;
101 -import ly.warp.sdk.io.models.RefreshVouchersEventModel;
102 -import ly.warp.sdk.io.models.UnifiedCoupon;
103 import ly.warp.sdk.io.models.WarplyCCMSEnabledModel; 101 import ly.warp.sdk.io.models.WarplyCCMSEnabledModel;
104 import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel; 102 import ly.warp.sdk.io.models.WarplyCouponsChangedEventModel;
105 import ly.warp.sdk.io.models.WarplyPacingCardEventModel; 103 import ly.warp.sdk.io.models.WarplyPacingCardEventModel;
106 import ly.warp.sdk.io.models.WarplyUnifiedActivatedEventModel; 104 import ly.warp.sdk.io.models.WarplyUnifiedActivatedEventModel;
107 import ly.warp.sdk.services.EventCampaignService; 105 import ly.warp.sdk.services.EventCampaignService;
106 +import ly.warp.sdk.services.EventUnifiedCouponsRefreshService;
108 import ly.warp.sdk.utils.WarpUtils; 107 import ly.warp.sdk.utils.WarpUtils;
109 import ly.warp.sdk.utils.WarplyManagerHelper; 108 import ly.warp.sdk.utils.WarplyManagerHelper;
110 import ly.warp.sdk.utils.WarplyProperty; 109 import ly.warp.sdk.utils.WarplyProperty;
...@@ -550,11 +549,10 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { ...@@ -550,11 +549,10 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
550 549
551 Intent intent = new Intent((WarpActivity != null && !WarpActivity.isFinishing()) ? WarpActivity : getContext(), ActiveUnifiedCouponsActivity.class); 550 Intent intent = new Intent((WarpActivity != null && !WarpActivity.isFinishing()) ? WarpActivity : getContext(), ActiveUnifiedCouponsActivity.class);
552 getContext().startActivity(intent); 551 getContext().startActivity(intent);
553 - /* New Addition end */
554 552
555 - RefreshVouchersEventModel vouchersRefreshed = new RefreshVouchersEventModel(); 553 + OneTimeWorkRequest mywork = new OneTimeWorkRequest.Builder(EventUnifiedCouponsRefreshService.class).build();
556 - vouchersRefreshed.setRefreshed(true); 554 + WorkManager.getInstance(Warply.getWarplyContext()).enqueue(mywork);
557 - EventBus.getDefault().post(new WarplyEventBusManager(vouchersRefreshed)); 555 + /* New Addition end */
558 } else if (parts[1].equals("activeCoupons")) { 556 } else if (parts[1].equals("activeCoupons")) {
559 WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); 557 WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
560 WarplyManager.getCampaigns(mCampaignsCallback); 558 WarplyManager.getCampaigns(mCampaignsCallback);
......
...@@ -300,4 +300,25 @@ ...@@ -300,4 +300,25 @@
300 android:textColor="@color/white" 300 android:textColor="@color/white"
301 android:textSize="16sp" /> 301 android:textSize="16sp" />
302 </LinearLayout> 302 </LinearLayout>
303 +
304 + <RelativeLayout
305 + android:id="@+id/pb_loading"
306 + android:layout_width="match_parent"
307 + android:layout_height="match_parent"
308 + android:background="@android:color/transparent"
309 + android:visibility="gone"
310 + tools:visibility="visible"
311 + app:layout_constraintTop_toTopOf="parent"
312 + app:layout_constraintBottom_toBottomOf="parent"
313 + app:layout_constraintStart_toStartOf="parent"
314 + app:layout_constraintEnd_toEndOf="parent">
315 +
316 + <ProgressBar
317 + android:layout_width="48dp"
318 + android:layout_height="48dp"
319 + android:layout_centerInParent="true"
320 + android:indeterminate="true"
321 + android:indeterminateTint="@color/cos_green5"
322 + android:indeterminateTintMode="src_atop" />
323 + </RelativeLayout>
303 </androidx.constraintlayout.widget.ConstraintLayout> 324 </androidx.constraintlayout.widget.ConstraintLayout>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -320,4 +320,25 @@ ...@@ -320,4 +320,25 @@
320 </LinearLayout> 320 </LinearLayout>
321 </androidx.core.widget.NestedScrollView> 321 </androidx.core.widget.NestedScrollView>
322 </RelativeLayout> 322 </RelativeLayout>
323 +
324 + <RelativeLayout
325 + android:id="@+id/pb_loading"
326 + android:layout_width="match_parent"
327 + android:layout_height="match_parent"
328 + android:background="@android:color/transparent"
329 + android:visibility="gone"
330 + tools:visibility="visible"
331 + app:layout_constraintTop_toTopOf="parent"
332 + app:layout_constraintBottom_toBottomOf="parent"
333 + app:layout_constraintStart_toStartOf="parent"
334 + app:layout_constraintEnd_toEndOf="parent">
335 +
336 + <ProgressBar
337 + android:layout_width="48dp"
338 + android:layout_height="48dp"
339 + android:layout_centerInParent="true"
340 + android:indeterminate="true"
341 + android:indeterminateTint="@color/cos_green5"
342 + android:indeterminateTintMode="src_atop" />
343 + </RelativeLayout>
323 </RelativeLayout> 344 </RelativeLayout>
......
...@@ -128,6 +128,17 @@ ...@@ -128,6 +128,17 @@
128 android:visibility="gone" 128 android:visibility="gone"
129 tools:visibility="visible"/> 129 tools:visibility="visible"/>
130 130
131 + <TextView
132 + android:id="@+id/tv_login"
133 + android:layout_width="wrap_content"
134 + android:layout_height="wrap_content"
135 + android:layout_alignParentStart="true"
136 + android:layout_centerVertical="true"
137 + android:layout_marginStart="16dp"
138 + android:textColor="@color/blue_dark"
139 + android:textSize="20sp"
140 + android:visibility="gone"/>
141 +
131 <LinearLayout 142 <LinearLayout
132 android:id="@+id/ll_auth_login" 143 android:id="@+id/ll_auth_login"
133 android:layout_width="140dp" 144 android:layout_width="140dp"
......