Panagiotis Triantafyllou

more fixes and additions

......@@ -191,6 +191,8 @@ public class ActiveUnifiedCouponsActivity extends Activity implements View.OnCli
mPbLoading.setVisibility(View.VISIBLE);
WarplyManager.createUnifiedCoupon(tempArray, mCreateUnifiedCallback);
} else {
mIsActivatePressed = false;
}
}
}
......
......@@ -2,6 +2,7 @@ package ly.warp.sdk.activities;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
......@@ -190,13 +191,20 @@ public class ContextualActivity extends Activity implements View.OnClickListener
final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this, R.style.BottomSheetDialog);
bottomSheetDialog.setContentView(R.layout.dl_share);
bottomSheetDialog.setOnDismissListener(dialog -> {
mIsActivatePressed = false;
bottomSheetDialog.dismiss();
});
TextView tvHeader = bottomSheetDialog.findViewById(R.id.tv_sender_value);
WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, tvHeader);
tvHeader.setText(R.string.cos_coupon_share_telco);
LinearLayout parent = bottomSheetDialog.findViewById(R.id.ll_share_dialog_view_inner);
ImageView dialogClose = (ImageView) bottomSheetDialog.findViewById(R.id.iv_sender_list_close);
dialogClose.setOnClickListener(view -> bottomSheetDialog.dismiss());
dialogClose.setOnClickListener(view -> {
mIsActivatePressed = false;
bottomSheetDialog.dismiss();
});
if (mCCMS.getEligibleAssets() != null && mCCMS.getEligibleAssets().size() > 0) {
for (int i = 0; i < mCCMS.getEligibleAssets().size(); i++) {
......
......@@ -325,8 +325,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this, R.style.BottomSheetDialog);
bottomSheetDialog.setContentView(R.layout.dl_bottom_sheet_merchants);
bottomSheetDialog.setOnDismissListener(dialog -> {
bottomSheetDialog.dismiss();
mIsFindItPressed = false;
bottomSheetDialog.dismiss();
});
TextView sheetTitle = bottomSheetDialog.findViewById(R.id.tv_sm_sheet_title);
TextView sheetSubtitle = bottomSheetDialog.findViewById(R.id.tv_sm_sheet_subtitle);
......@@ -336,8 +336,8 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
ImageView dialogClose = (ImageView) bottomSheetDialog.findViewById(R.id.iv_sm_sheet_close);
dialogClose.setOnClickListener(view -> {
bottomSheetDialog.dismiss();
mIsFindItPressed = false;
bottomSheetDialog.dismiss();
});
for (int i = 0; i < shopAvailability.length(); i++) {
......@@ -374,6 +374,7 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
.into(merchantLogo);
ConstraintLayout buyButton = (ConstraintLayout) v.findViewById(R.id.cl_button_sm_buy_it);
buyButton.setOnClickListener(view -> {
mIsFindItPressed = false;
bottomSheetDialog.dismiss();
if (!TextUtils.isEmpty(finalProductUrl)) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(finalProductUrl));
......
......@@ -64,7 +64,7 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
private EditText mEdtReceiver;
private AlertDialog mAlertDialogSuccessSharing, mAlertDialogErrorSharing,
mAlertDialogCouponAskSharing, mAlertDialogWrongNumberSharing, mAlertDialogNoAssets;
private boolean mIsFromWallet = false, mIsActiveUnified = false;
private boolean mIsFromWallet = false, mIsActiveUnified = false, mIsSharePressed = false;
private RelativeLayout mPbLoading;
// ===========================================================
......@@ -118,6 +118,7 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
@Override
public void onResume() {
super.onResume();
mIsSharePressed = false;
WarplyAnalyticsManager.logTrackersEvent(this, "screen", "CouponShareScreen");
WarplyManager.getConsumer(new WarplyConsumerRequest()
......@@ -162,7 +163,10 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
}
if (view.getId() == R.id.ll_share_button) {
if (!TextUtils.isEmpty(mSender) && !mTvPhoneHeader.getText().toString().equals(R.string.cos_coupon_share_sender) && !TextUtils.isEmpty(mEdtReceiver.getText().toString())) {
askSharingDialog();
if (!mIsSharePressed) {
mIsSharePressed = true;
askSharingDialog();
}
} else {
errorSharingDialog2();
}
......@@ -200,6 +204,9 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
private void showSharingDialog() {
final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this, R.style.BottomSheetDialog);
bottomSheetDialog.setContentView(R.layout.dl_share);
bottomSheetDialog.setOnDismissListener(dialog -> {
bottomSheetDialog.dismiss();
});
LinearLayout parent = bottomSheetDialog.findViewById(R.id.ll_share_dialog_view_inner);
ImageView dialogClose = (ImageView) bottomSheetDialog.findViewById(R.id.iv_sender_list_close);
......@@ -326,6 +333,7 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
}).start();
})
.setNegativeButton(R.string.cos_dlg_negative_button2, (dialogNegative, whichNegative) -> {
mIsSharePressed = false;
dialogNegative.dismiss();
})
.show();
......@@ -347,6 +355,7 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
private final CallbackReceiver<JSONObject> mCouponSharingCallback = new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
mIsSharePressed = false;
int status = result.optInt("status", 2);
String message = result.optString("msg", "");
if (status == 1) {
......@@ -373,6 +382,7 @@ public class CouponShareActivity extends Activity implements View.OnClickListene
@Override
public void onFailure(int errorCode) {
mIsSharePressed = false;
Log.v("COUPON_SHARE", String.valueOf(errorCode));
runOnUiThread(() -> {
mPbLoading.setVisibility(View.GONE);
......
......@@ -228,6 +228,7 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
private final CallbackReceiver<JSONObject> mRedeemCouponCallback = new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
mIsGiftPressed = false;
mPbLoading.setVisibility(View.GONE);
int status = result.optInt("status");
if (status == 1) {
......@@ -283,6 +284,7 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
@Override
public void onFailure(int errorCode) {
mIsGiftPressed = false;
mPbLoading.setVisibility(View.GONE);
showDialog(false, errorCode);
mLlRedeem.setEnabled(true);
......
......@@ -2,6 +2,7 @@ package ly.warp.sdk.activities;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
......@@ -10,6 +11,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;
......@@ -59,7 +61,8 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
private String mSender = "";
private AlertDialog mAlertDialogAskActivate, mAlertDialogErrorActivating, mAlertDialogSuccessActivating;
private LinearLayout mLlSeeMore;
private boolean mIsSeeMoreShown = false;
private boolean mIsSeeMoreShown = false, mIsActivatePressed = false;
private RelativeLayout mPbLoading;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -92,6 +95,8 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
mTvSeeMoreValue = findViewById(R.id.tv_see_more_value);
mFontButtonGetIt = findViewById(R.id.button_get_it);
mFontButtonSeeMore = findViewById(R.id.tv_see_more);
mPbLoading = findViewById(R.id.pb_loading);
mPbLoading.setOnTouchListener((v, event) -> true);
WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mTvTelcoHeaderTitle);
WarpUtils.renderCustomFont(this, R.font.peridot_semi_bold, mTvTelcoGiftValue, mFontButtonGetIt);
WarpUtils.renderCustomFont(this, R.font.peridot_regular, mTvTelcoGiftType, mTvTelcoGiftDuration,
......@@ -104,6 +109,7 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
@Override
public void onResume() {
super.onResume();
mIsActivatePressed = false;
WarplyAnalyticsManager.logTrackersEvent(this, "screen", "TelcoScreen");
// new Thread(() -> {
......@@ -122,7 +128,10 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
return;
}
if (view.getId() == R.id.ll_activate_button) {
showActivationDialog();
if (!mIsActivatePressed) {
mIsActivatePressed = true;
showActivationDialog();
}
return;
}
if (view.getId() == R.id.ll_see_more) {
......@@ -174,13 +183,20 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
private void showActivationDialog() {
final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this, R.style.BottomSheetDialog);
bottomSheetDialog.setContentView(R.layout.dl_share);
bottomSheetDialog.setOnDismissListener(dialog -> {
mIsActivatePressed = false;
bottomSheetDialog.dismiss();
});
TextView tvHeader = bottomSheetDialog.findViewById(R.id.tv_sender_value);
WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, tvHeader);
tvHeader.setText(R.string.cos_coupon_share_telco);
LinearLayout parent = bottomSheetDialog.findViewById(R.id.ll_share_dialog_view_inner);
ImageView dialogClose = (ImageView) bottomSheetDialog.findViewById(R.id.iv_sender_list_close);
dialogClose.setOnClickListener(view -> bottomSheetDialog.dismiss());
dialogClose.setOnClickListener(view -> {
mIsActivatePressed = false;
bottomSheetDialog.dismiss();
});
if (mCCMS.getEligibleAssets() != null && mCCMS.getEligibleAssets().size() > 0) {
for (int i = 0; i < mCCMS.getEligibleAssets().size(); i++) {
......@@ -245,9 +261,11 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
.setTitle(R.string.cos_dlg_activate_telco_title)
.setMessage(R.string.cos_dlg_activate_telco_subtitle)
.setPositiveButton(R.string.cos_dlg_positive_button, (dialogPositive, whichPositive) -> {
mPbLoading.setVisibility(View.VISIBLE);
activateGift();
})
.setNegativeButton(R.string.cos_dlg_negative_button2, (dialogNegative, whichNegative) -> {
mIsActivatePressed = false;
dialogNegative.dismiss();
})
.show();
......@@ -315,8 +333,10 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
private CallbackReceiver<JSONObject> mSubmitCallback = new CallbackReceiver<JSONObject>() {
@Override
public void onSuccess(JSONObject result) {
mIsActivatePressed = false;
int status = result.optInt("status", 2);
runOnUiThread(() -> {
mPbLoading.setVisibility(View.GONE);
if (status == 1)
successActivatingDialog();
else
......@@ -346,7 +366,11 @@ public class TelcoActivity extends Activity implements View.OnClickListener {
@Override
public void onFailure(int errorCode) {
runOnUiThread(() -> errorActivatingDialog());
mIsActivatePressed = false;
runOnUiThread(() -> {
mPbLoading.setVisibility(View.GONE);
errorActivatingDialog();
});
}
};
......
......@@ -72,7 +72,7 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
mLlCancelUnified;
private UnifiedCoupon mCoupon;
private boolean mIsBarcodeShown = false, mIsTermsShown = false, mIsFromWallet = false,
mIsMarketExpand = true, mShopsPressed = false, mCouponPressed = false;
mIsMarketExpand = true, mShopsPressed = false, mCouponPressed = false, mCancelPressed = false;
private RecyclerView mRecyclerCoupons;
private ActiveCouponAdapter mAdapterCoupons;
private AlertDialog mErrorAlertDialog, mSuccessAlertDialog, mAskCancelUnifiedAlertDialog;
......@@ -144,6 +144,7 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
WarplyAnalyticsManager.logTrackersEvent(this, "screen", "UnifiedCouponScreen");
mShopsPressed = false;
mCouponPressed = false;
mCancelPressed = false;
}
@Override
......@@ -184,7 +185,10 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
return;
}
if (view.getId() == R.id.ll_cancel_coupon) {
askCancelUnifiedDialog();
if(!mCancelPressed) {
mCancelPressed = true;
askCancelUnifiedDialog();
}
}
}
......@@ -438,6 +442,7 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
cancelUnified();
})
.setNegativeButton(R.string.cos_dlg_negative_button4, (dialogNegative, whichNegative) -> {
mCancelPressed = false;
dialogNegative.dismiss();
})
.show();
......@@ -476,12 +481,14 @@ public class UnifiedCouponInfoActivity extends Activity implements View.OnClickL
private final CallbackReceiver<Integer> mCancelUnifiedCallback = new CallbackReceiver<Integer>() {
@Override
public void onSuccess(Integer result) {
mCancelPressed = false;
mPbLoading.setVisibility(View.GONE);
successDialog();
}
@Override
public void onFailure(int errorCode) {
mCancelPressed = false;
mPbLoading.setVisibility(View.GONE);
errorDialog();
}
......
......@@ -1349,6 +1349,34 @@ public class WarplyManagerHelper {
}
}
public static void updateCampaignItem(String sessionUuid) {
Campaign tempCampaign;
for (Campaign cmp : WarplyManagerHelper.getCampaignListAll()) {
if (cmp.getSessionUUID().equals(sessionUuid)) {
if (mCampaignListAll != null && !mCampaignListAll.isEmpty()) {
mCampaignListAll.remove(cmp);
tempCampaign = cmp;
tempCampaign.setNew(false);
mCampaignListAll.add(tempCampaign);
}
break;
}
}
Campaign tempCarouselCampaign;
for (Campaign cmp : WarplyManagerHelper.getCarouselList()) {
if (cmp.getSessionUUID().equals(sessionUuid)) {
if (mCarouselList != null && !mCarouselList.isEmpty()) {
mCarouselList.remove(cmp);
tempCarouselCampaign = cmp;
tempCarouselCampaign.setNew(false);
mCarouselList.add(tempCarouselCampaign);
}
break;
}
}
}
public static void setCouponList(CouponList couponList) {
LoyaltyBadgeModel badge = new LoyaltyBadgeModel();
CouponList cpnlist = new CouponList();
......
......@@ -5418,6 +5418,10 @@ public class WarplyManager {
dynatraceEvent.setEventName("custom_success_read_campaign_loyalty");
EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
/* New Addition start */
WarplyManagerHelper.updateCampaignItem(sessionUuid);
/* New Addition end */
// getCampaigns(new CallbackReceiver<ArrayList<Campaign>>() {
// @Override
// public void onSuccess(ArrayList<Campaign> result) {
......@@ -5439,6 +5443,10 @@ public class WarplyManager {
dynatraceEvent.setEventName("custom_success_read_campaign_loyalty");
EventBus.getDefault().post(new WarplyEventBusManager(dynatraceEvent));
/* New Addition start */
WarplyManagerHelper.updateCampaignItem(sessionUuid);
/* New Addition end */
// getCampaigns(new CallbackReceiver<ArrayList<Campaign>>() {
// @Override
// public void onSuccess(ArrayList<Campaign> result) {
......
......@@ -216,4 +216,22 @@
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<RelativeLayout
android:id="@+id/pb_loading"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="@android:color/transparent"
android:visibility="gone"
tools:visibility="visible">
<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>
......