Panagiotis Triantafyllou

minor addition and fix

...@@ -10,6 +10,7 @@ import android.view.View; ...@@ -10,6 +10,7 @@ import android.view.View;
10 import android.view.ViewGroup; 10 import android.view.ViewGroup;
11 import android.widget.ImageView; 11 import android.widget.ImageView;
12 import android.widget.LinearLayout; 12 import android.widget.LinearLayout;
13 +import android.widget.RelativeLayout;
13 import android.widget.TextView; 14 import android.widget.TextView;
14 15
15 import androidx.appcompat.app.AlertDialog; 16 import androidx.appcompat.app.AlertDialog;
...@@ -61,11 +62,12 @@ public class ContextualActivity extends Activity implements View.OnClickListener ...@@ -61,11 +62,12 @@ public class ContextualActivity extends Activity implements View.OnClickListener
61 private LoyaltyContextualOfferModel mCCMS = new LoyaltyContextualOfferModel(); 62 private LoyaltyContextualOfferModel mCCMS = new LoyaltyContextualOfferModel();
62 private LinearLayout mLlActivateOffer, mLlTerms; 63 private LinearLayout mLlActivateOffer, mLlTerms;
63 private Consumer mConsumer; 64 private Consumer mConsumer;
64 - private boolean mIsTermsPressed = false; 65 + private boolean mIsTermsPressed = false, mIsActivatePressed = false;
65 private String mSender = ""; 66 private String mSender = "";
66 private AlertDialog mAlertDialogAskActivate, mAlertDialogErrorActivating, 67 private AlertDialog mAlertDialogAskActivate, mAlertDialogErrorActivating,
67 mAlertDialogSuccessActivating; 68 mAlertDialogSuccessActivating;
68 private Campaign mLoyalty; 69 private Campaign mLoyalty;
70 + private RelativeLayout mPbLoading;
69 71
70 // =========================================================== 72 // ===========================================================
71 // Methods for/from SuperClass/Interfaces 73 // Methods for/from SuperClass/Interfaces
...@@ -98,6 +100,8 @@ public class ContextualActivity extends Activity implements View.OnClickListener ...@@ -98,6 +100,8 @@ public class ContextualActivity extends Activity implements View.OnClickListener
98 mTvTermsValue = findViewById(R.id.tv_terms_value); 100 mTvTermsValue = findViewById(R.id.tv_terms_value);
99 mFontHeader = findViewById(R.id.textView3); 101 mFontHeader = findViewById(R.id.textView3);
100 mFontActivateButton = findViewById(R.id.tv_activate_button); 102 mFontActivateButton = findViewById(R.id.tv_activate_button);
103 + mPbLoading = findViewById(R.id.pb_loading);
104 + mPbLoading.setOnTouchListener((v, event) -> true);
101 WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader, mTvCampaignTitle); 105 WarpUtils.renderCustomFont(this, R.font.bt_cosmo_bold, mFontHeader, mTvCampaignTitle);
102 WarpUtils.renderCustomFont(this, R.font.peridot_regular, mTvCampaignSubtitle, mTvTermsValue); 106 WarpUtils.renderCustomFont(this, R.font.peridot_regular, mTvCampaignSubtitle, mTvTermsValue);
103 WarpUtils.renderCustomFont(this, R.font.peridot_semi_bold, mFontActivateButton); 107 WarpUtils.renderCustomFont(this, R.font.peridot_semi_bold, mFontActivateButton);
...@@ -109,6 +113,7 @@ public class ContextualActivity extends Activity implements View.OnClickListener ...@@ -109,6 +113,7 @@ public class ContextualActivity extends Activity implements View.OnClickListener
109 @Override 113 @Override
110 public void onResume() { 114 public void onResume() {
111 super.onResume(); 115 super.onResume();
116 + mIsActivatePressed = false;
112 WarplyAnalyticsManager.logTrackersEvent(this, "screen", "ContextualScreen"); 117 WarplyAnalyticsManager.logTrackersEvent(this, "screen", "ContextualScreen");
113 118
114 // new Thread(() -> { 119 // new Thread(() -> {
...@@ -127,7 +132,11 @@ public class ContextualActivity extends Activity implements View.OnClickListener ...@@ -127,7 +132,11 @@ public class ContextualActivity extends Activity implements View.OnClickListener
127 return; 132 return;
128 } 133 }
129 if (view.getId() == R.id.ll_activate_button) { 134 if (view.getId() == R.id.ll_activate_button) {
130 - showActivationDialog(); 135 + if (!mIsActivatePressed) {
136 + mIsActivatePressed = true;
137 +
138 + showActivationDialog();
139 + }
131 return; 140 return;
132 } 141 }
133 if (view.getId() == R.id.ll_terms_inner) { 142 if (view.getId() == R.id.ll_terms_inner) {
...@@ -255,9 +264,11 @@ public class ContextualActivity extends Activity implements View.OnClickListener ...@@ -255,9 +264,11 @@ public class ContextualActivity extends Activity implements View.OnClickListener
255 .setTitle(R.string.cos_dlg_activate_telco_title) 264 .setTitle(R.string.cos_dlg_activate_telco_title)
256 .setMessage(String.format(getString(R.string.cos_dlg_activate_telco_subtitle2), msisdn)) 265 .setMessage(String.format(getString(R.string.cos_dlg_activate_telco_subtitle2), msisdn))
257 .setPositiveButton(R.string.cos_dlg_positive_button, (dialogPositive, whichPositive) -> { 266 .setPositiveButton(R.string.cos_dlg_positive_button, (dialogPositive, whichPositive) -> {
267 + mPbLoading.setVisibility(View.VISIBLE);
258 activateGift(); 268 activateGift();
259 }) 269 })
260 .setNegativeButton(R.string.cos_dlg_negative_button2, (dialogNegative, whichNegative) -> { 270 .setNegativeButton(R.string.cos_dlg_negative_button2, (dialogNegative, whichNegative) -> {
271 + mIsActivatePressed = false;
261 dialogNegative.dismiss(); 272 dialogNegative.dismiss();
262 }) 273 })
263 .show(); 274 .show();
...@@ -277,6 +288,7 @@ public class ContextualActivity extends Activity implements View.OnClickListener ...@@ -277,6 +288,7 @@ public class ContextualActivity extends Activity implements View.OnClickListener
277 .setTitle(R.string.cos_dlg_error_title) 288 .setTitle(R.string.cos_dlg_error_title)
278 .setMessage(R.string.cos_dlg_error_subtitle) 289 .setMessage(R.string.cos_dlg_error_subtitle)
279 .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> { 290 .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
291 + mIsActivatePressed = false;
280 dialogPositive.dismiss(); 292 dialogPositive.dismiss();
281 }) 293 })
282 .show(); 294 .show();
...@@ -301,6 +313,7 @@ public class ContextualActivity extends Activity implements View.OnClickListener ...@@ -301,6 +313,7 @@ public class ContextualActivity extends Activity implements View.OnClickListener
301 .setMessage(R.string.cos_dlg_activate_success_subtitle) 313 .setMessage(R.string.cos_dlg_activate_success_subtitle)
302 .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> { 314 .setPositiveButton(R.string.cos_dlg_positive_button2, (dialogPositive, whichPositive) -> {
303 if (!isFinishing()) { 315 if (!isFinishing()) {
316 + mIsActivatePressed = false;
304 dialogPositive.dismiss(); 317 dialogPositive.dismiss();
305 onBackPressed(); 318 onBackPressed();
306 } 319 }
...@@ -335,16 +348,22 @@ public class ContextualActivity extends Activity implements View.OnClickListener ...@@ -335,16 +348,22 @@ public class ContextualActivity extends Activity implements View.OnClickListener
335 348
336 int status = result.optInt("status", 2); 349 int status = result.optInt("status", 2);
337 runOnUiThread(() -> { 350 runOnUiThread(() -> {
351 + mPbLoading.setVisibility(View.GONE);
338 if (status == 1) { 352 if (status == 1) {
339 successActivatingDialog(); 353 successActivatingDialog();
340 - } else 354 + } else {
341 errorActivatingDialog(); 355 errorActivatingDialog();
356 + }
342 }); 357 });
343 } 358 }
344 359
345 @Override 360 @Override
346 public void onFailure(int errorCode) { 361 public void onFailure(int errorCode) {
347 - runOnUiThread(() -> errorActivatingDialog()); 362 + mIsActivatePressed = false;
363 + runOnUiThread(() -> {
364 + mPbLoading.setVisibility(View.GONE);
365 + errorActivatingDialog();
366 + });
348 // errorActivatingDialog(); 367 // errorActivatingDialog();
349 } 368 }
350 }; 369 };
......
...@@ -169,4 +169,25 @@ ...@@ -169,4 +169,25 @@
169 </androidx.constraintlayout.widget.ConstraintLayout> 169 </androidx.constraintlayout.widget.ConstraintLayout>
170 </androidx.constraintlayout.widget.ConstraintLayout> 170 </androidx.constraintlayout.widget.ConstraintLayout>
171 </ScrollView> 171 </ScrollView>
172 +
173 + <RelativeLayout
174 + android:id="@+id/pb_loading"
175 + android:layout_width="match_parent"
176 + android:layout_height="match_parent"
177 + android:background="@android:color/transparent"
178 + android:visibility="gone"
179 + tools:visibility="visible"
180 + app:layout_constraintTop_toTopOf="parent"
181 + app:layout_constraintBottom_toBottomOf="parent"
182 + app:layout_constraintStart_toStartOf="parent"
183 + app:layout_constraintEnd_toEndOf="parent">
184 +
185 + <ProgressBar
186 + android:layout_width="48dp"
187 + android:layout_height="48dp"
188 + android:layout_centerInParent="true"
189 + android:indeterminate="true"
190 + android:indeterminateTint="@color/cos_green5"
191 + android:indeterminateTintMode="src_atop" />
192 + </RelativeLayout>
172 </RelativeLayout> 193 </RelativeLayout>
......