Panagiotis Triantafyllou

minor addition and fix

......@@ -10,6 +10,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;
......@@ -61,11 +62,12 @@ public class ContextualActivity extends Activity implements View.OnClickListener
private LoyaltyContextualOfferModel mCCMS = new LoyaltyContextualOfferModel();
private LinearLayout mLlActivateOffer, mLlTerms;
private Consumer mConsumer;
private boolean mIsTermsPressed = false;
private boolean mIsTermsPressed = false, mIsActivatePressed = false;
private String mSender = "";
private AlertDialog mAlertDialogAskActivate, mAlertDialogErrorActivating,
mAlertDialogSuccessActivating;
private Campaign mLoyalty;
private RelativeLayout mPbLoading;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -98,6 +100,8 @@ public class ContextualActivity extends Activity implements View.OnClickListener
mTvTermsValue = findViewById(R.id.tv_terms_value);
mFontHeader = findViewById(R.id.textView3);
mFontActivateButton = findViewById(R.id.tv_activate_button);
mPbLoading = findViewById(R.id.pb_loading);
mPbLoading.setOnTouchListener((v, event) -> true);
WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader, mTvCampaignTitle);
WarpUtils.renderCustomFont(this, R.font.peridot_regular, mTvCampaignSubtitle, mTvTermsValue);
WarpUtils.renderCustomFont(this, R.font.peridot_semi_bold, mFontActivateButton);
......@@ -109,6 +113,7 @@ public class ContextualActivity extends Activity implements View.OnClickListener
@Override
public void onResume() {
super.onResume();
mIsActivatePressed = false;
WarplyAnalyticsManager.logTrackersEvent(this, "screen", "ContextualScreen");
// new Thread(() -> {
......@@ -127,7 +132,11 @@ public class ContextualActivity extends Activity implements View.OnClickListener
return;
}
if (view.getId() == R.id.ll_activate_button) {
if (!mIsActivatePressed) {
mIsActivatePressed = true;
showActivationDialog();
}
return;
}
if (view.getId() == R.id.ll_terms_inner) {
......@@ -255,9 +264,11 @@ public class ContextualActivity extends Activity implements View.OnClickListener
.setTitle(R.string.cos_dlg_activate_telco_title)
.setMessage(String.format(getString(R.string.cos_dlg_activate_telco_subtitle2), msisdn))
.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();
......@@ -277,6 +288,7 @@ public class ContextualActivity extends Activity implements View.OnClickListener
.setTitle(R.string.cos_dlg_error_title)
.setMessage(R.string.cos_dlg_error_subtitle)
.setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
mIsActivatePressed = false;
dialogPositive.dismiss();
})
.show();
......@@ -301,6 +313,7 @@ public class ContextualActivity extends Activity implements View.OnClickListener
.setMessage(R.string.cos_dlg_activate_success_subtitle)
.setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
if (!isFinishing()) {
mIsActivatePressed = false;
dialogPositive.dismiss();
onBackPressed();
}
......@@ -335,16 +348,22 @@ public class ContextualActivity extends Activity implements View.OnClickListener
int status = result.optInt("status", 2);
runOnUiThread(() -> {
mPbLoading.setVisibility(View.GONE);
if (status == 1) {
successActivatingDialog();
} else
} else {
errorActivatingDialog();
}
});
}
@Override
public void onFailure(int errorCode) {
runOnUiThread(() -> errorActivatingDialog());
mIsActivatePressed = false;
runOnUiThread(() -> {
mPbLoading.setVisibility(View.GONE);
errorActivatingDialog();
});
// errorActivatingDialog();
}
};
......
......@@ -169,4 +169,25 @@
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
<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>
......