Panagiotis Triantafyllou

crash fixes

...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library' ...@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2 2
3 ext { 3 ext {
4 PUBLISH_GROUP_ID = 'ly.warp' 4 PUBLISH_GROUP_ID = 'ly.warp'
5 - PUBLISH_VERSION = '4.5.5.4r22' 5 + PUBLISH_VERSION = '4.5.5.4r23'
6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk' 6 PUBLISH_ARTIFACT_ID = 'warply-android-sdk'
7 } 7 }
8 8
......
...@@ -155,10 +155,10 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -155,10 +155,10 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
155 mGiftPressed = true; 155 mGiftPressed = true;
156 WarplyAnalyticsManager.logTrackersEvent(this, "click", ("ShareCoupon") 156 WarplyAnalyticsManager.logTrackersEvent(this, "click", ("ShareCoupon")
157 .concat(":") 157 .concat(":")
158 - .concat(mCoupon.getName())); 158 + .concat(mCoupon != null ? mCoupon.getName() : ""));
159 159
160 Intent intent = new Intent(CouponInfoActivity.this, CouponShareActivity.class); 160 Intent intent = new Intent(CouponInfoActivity.this, CouponShareActivity.class);
161 - intent.putExtra("coupon", mCoupon.getCoupon()); 161 + intent.putExtra("coupon", mCoupon != null ? mCoupon.getCoupon() : "");
162 intent.putExtra("isFromWallet", mIsFromWallet); 162 intent.putExtra("isFromWallet", mIsFromWallet);
163 if (!mIsFromWallet) 163 if (!mIsFromWallet)
164 startActivity(intent); 164 startActivity(intent);
...@@ -174,12 +174,12 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -174,12 +174,12 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
174 174
175 if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(CouponInfoActivity.this) == ConnectionResult.SUCCESS) { 175 if (GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(CouponInfoActivity.this) == ConnectionResult.SUCCESS) {
176 Intent intent = new Intent(CouponInfoActivity.this, ShopsActivity.class); 176 Intent intent = new Intent(CouponInfoActivity.this, ShopsActivity.class);
177 - intent.putExtra("coupon", mCoupon.getCoupon()); 177 + intent.putExtra("coupon", mCoupon != null ? mCoupon.getCoupon() : "");
178 startActivity(intent); 178 startActivity(intent);
179 return; 179 return;
180 } else { 180 } else {
181 Intent intent = new Intent(CouponInfoActivity.this, ShopsHuaweiActivity.class); 181 Intent intent = new Intent(CouponInfoActivity.this, ShopsHuaweiActivity.class);
182 - intent.putExtra("coupon", mCoupon.getCoupon()); 182 + intent.putExtra("coupon", mCoupon != null ? mCoupon.getCoupon() : "");
183 startActivity(intent); 183 startActivity(intent);
184 return; 184 return;
185 } 185 }
...@@ -250,11 +250,13 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -250,11 +250,13 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
250 mLlBarcodeContainer.setVisibility(View.GONE); 250 mLlBarcodeContainer.setVisibility(View.GONE);
251 mIvBarcode.setVisibility(View.GONE); 251 mIvBarcode.setVisibility(View.GONE);
252 252
253 - if (mIsUnified) { 253 + if (mCoupon != null) {
254 - mTvCouponTitle.setText(HtmlCompat.fromHtml(mCoupon.getName(), HtmlCompat.FROM_HTML_MODE_COMPACT)); 254 + if (mIsUnified) {
255 - } else { 255 + mTvCouponTitle.setText(HtmlCompat.fromHtml(mCoupon.getName(), HtmlCompat.FROM_HTML_MODE_COMPACT));
256 - mTvCouponCode.setText(mCoupon.getCoupon()); 256 + } else {
257 - mTvCouponTitle.setText(mCoupon.getCouponsetDetails().getName()); 257 + mTvCouponCode.setText(mCoupon.getCoupon());
258 + mTvCouponTitle.setText(mCoupon.getCouponsetDetails().getName());
259 + }
258 } 260 }
259 261
260 if (mCoupon != null) { 262 if (mCoupon != null) {
...@@ -302,15 +304,21 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -302,15 +304,21 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
302 if (mIsUnified) { 304 if (mIsUnified) {
303 mIvCouponPhoto.setScaleType(ImageView.ScaleType.CENTER_INSIDE); 305 mIvCouponPhoto.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
304 306
305 - if (!TextUtils.isEmpty(mCoupon.getImage())) { 307 + if (mCoupon != null) {
306 - Glide.with(this) 308 + if (!TextUtils.isEmpty(mCoupon.getImage())) {
309 + Glide.with(this)
307 // .setDefaultRequestOptions( 310 // .setDefaultRequestOptions(
308 // RequestOptions 311 // RequestOptions
309 // .placeholderOf(R.drawable.ic_default_contact_photo) 312 // .placeholderOf(R.drawable.ic_default_contact_photo)
310 // .error(R.drawable.ic_default_contact_photo)) 313 // .error(R.drawable.ic_default_contact_photo))
311 - .load(mCoupon.getImage()) 314 + .load(mCoupon.getImage())
312 - .diskCacheStrategy(DiskCacheStrategy.DATA) 315 + .diskCacheStrategy(DiskCacheStrategy.DATA)
313 - .into(mIvCouponPhoto); 316 + .into(mIvCouponPhoto);
317 + } else {
318 + Glide.with(this)
319 + .load(R.drawable.ic_cosmote_logo_horizontal_grey)
320 + .into(mIvCouponPhoto);
321 + }
314 } else { 322 } else {
315 Glide.with(this) 323 Glide.with(this)
316 .load(R.drawable.ic_cosmote_logo_horizontal_grey) 324 .load(R.drawable.ic_cosmote_logo_horizontal_grey)
...@@ -319,15 +327,21 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener ...@@ -319,15 +327,21 @@ public class CouponInfoActivity extends Activity implements View.OnClickListener
319 } else { 327 } else {
320 mIvCouponPhoto.setScaleType(ImageView.ScaleType.CENTER_CROP); 328 mIvCouponPhoto.setScaleType(ImageView.ScaleType.CENTER_CROP);
321 329
322 - if (!TextUtils.isEmpty(mCoupon.getCouponsetDetails().getImgPreview())) { 330 + if (mCoupon != null) {
323 - Glide.with(this) 331 + if (!TextUtils.isEmpty(mCoupon.getCouponsetDetails().getImgPreview())) {
332 + Glide.with(this)
324 // .setDefaultRequestOptions( 333 // .setDefaultRequestOptions(
325 // RequestOptions 334 // RequestOptions
326 // .placeholderOf(R.drawable.ic_default_contact_photo) 335 // .placeholderOf(R.drawable.ic_default_contact_photo)
327 // .error(R.drawable.ic_default_contact_photo)) 336 // .error(R.drawable.ic_default_contact_photo))
328 - .load(mCoupon.getCouponsetDetails().getImgPreview()) 337 + .load(mCoupon.getCouponsetDetails().getImgPreview())
329 - .diskCacheStrategy(DiskCacheStrategy.DATA) 338 + .diskCacheStrategy(DiskCacheStrategy.DATA)
330 - .into(mIvCouponPhoto); 339 + .into(mIvCouponPhoto);
340 + } else {
341 + Glide.with(this)
342 + .load(R.drawable.ic_cosmote_logo_horizontal_grey)
343 + .into(mIvCouponPhoto);
344 + }
331 } else { 345 } else {
332 Glide.with(this) 346 Glide.with(this)
333 .load(R.drawable.ic_cosmote_logo_horizontal_grey) 347 .load(R.drawable.ic_cosmote_logo_horizontal_grey)
......
...@@ -128,14 +128,14 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe ...@@ -128,14 +128,14 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
128 mPbLoading.setVisibility(View.VISIBLE); 128 mPbLoading.setVisibility(View.VISIBLE);
129 WarplyAnalyticsManager.logTrackersEvent(this, "click", ("RetrieveCoupon") 129 WarplyAnalyticsManager.logTrackersEvent(this, "click", ("RetrieveCoupon")
130 .concat(":") 130 .concat(":")
131 - .concat(mCouponset.getUuid())); 131 + .concat(mCouponset != null ? mCouponset.getUuid() : ""));
132 if (mCcms == null) { 132 if (mCcms == null) {
133 WarplyManager.redeemCoupon(new WarplyRedeemCouponRequest() 133 WarplyManager.redeemCoupon(new WarplyRedeemCouponRequest()
134 - .setCouponsetUuid(mCouponset.getUuid()) 134 + .setCouponsetUuid(mCouponset != null ? mCouponset.getUuid() : "")
135 .setCommunicationUuid(mLoyalty.getSessionUUID()), mRedeemCouponCallback); 135 .setCommunicationUuid(mLoyalty.getSessionUUID()), mRedeemCouponCallback);
136 } else { 136 } else {
137 WarplyManager.redeemCoupon(new WarplyRedeemCouponRequest() 137 WarplyManager.redeemCoupon(new WarplyRedeemCouponRequest()
138 - .setCouponsetUuid(mCouponset.getUuid()) 138 + .setCouponsetUuid(mCouponset != null ? mCouponset.getUuid() : "")
139 .setCommunicationUuid(mLoyalty.getSessionUUID()) 139 .setCommunicationUuid(mLoyalty.getSessionUUID())
140 .setHasContextualOffer(true) 140 .setHasContextualOffer(true)
141 .setSessionId(mCcms.getSessionId()) 141 .setSessionId(mCcms.getSessionId())
...@@ -191,28 +191,34 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe ...@@ -191,28 +191,34 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
191 nonTelcoDialog(); 191 nonTelcoDialog();
192 } 192 }
193 193
194 - mTvCouponsetTitle.setText(mCouponset.getName()); 194 + if (mCouponset != null) {
195 - mTvCouponsetSubtitle.setText(HtmlCompat.fromHtml(mCouponset.getDescription(), HtmlCompat.FROM_HTML_MODE_COMPACT)); 195 + mTvCouponsetTitle.setText(mCouponset.getName());
196 - mTvCouponsetSubtitle.setMovementMethod(LinkMovementMethod.getInstance()); 196 + mTvCouponsetSubtitle.setText(HtmlCompat.fromHtml(mCouponset.getDescription(), HtmlCompat.FROM_HTML_MODE_COMPACT));
197 - mLlTerms.setOnClickListener(this); 197 + mTvCouponsetSubtitle.setMovementMethod(LinkMovementMethod.getInstance());
198 - mTvTermsValue.setText(HtmlCompat.fromHtml(mCouponset.getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT)); 198 + mTvTermsValue.setText(HtmlCompat.fromHtml(mCouponset.getTerms(), HtmlCompat.FROM_HTML_MODE_COMPACT));
199 - mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance()); 199 + mTvTermsValue.setMovementMethod(LinkMovementMethod.getInstance());
200 200
201 - if (!TextUtils.isEmpty(mCouponset.getImgPreview())) { 201 + if (!TextUtils.isEmpty(mCouponset.getImgPreview())) {
202 - Glide.with(this) 202 + Glide.with(this)
203 // .setDefaultRequestOptions( 203 // .setDefaultRequestOptions(
204 // RequestOptions 204 // RequestOptions
205 // .placeholderOf(R.drawable.ic_default_contact_photo) 205 // .placeholderOf(R.drawable.ic_default_contact_photo)
206 // .error(R.drawable.ic_default_contact_photo)) 206 // .error(R.drawable.ic_default_contact_photo))
207 - .load(mCouponset.getImgPreview()) 207 + .load(mCouponset.getImgPreview())
208 - .diskCacheStrategy(DiskCacheStrategy.DATA) 208 + .diskCacheStrategy(DiskCacheStrategy.DATA)
209 - .into(mIvCouponsetPhoto); 209 + .into(mIvCouponsetPhoto);
210 + } else {
211 + Glide.with(this)
212 + .load(R.drawable.ic_cosmote_logo_horizontal_grey)
213 + .into(mIvCouponsetPhoto);
214 + }
210 } else { 215 } else {
211 Glide.with(this) 216 Glide.with(this)
212 .load(R.drawable.ic_cosmote_logo_horizontal_grey) 217 .load(R.drawable.ic_cosmote_logo_horizontal_grey)
213 .into(mIvCouponsetPhoto); 218 .into(mIvCouponsetPhoto);
214 } 219 }
215 220
221 + mLlTerms.setOnClickListener(this);
216 mIvBack.setOnClickListener(this); 222 mIvBack.setOnClickListener(this);
217 mLlRedeem.setOnClickListener(this); 223 mLlRedeem.setOnClickListener(this);
218 // mTvTerms.setPaintFlags(mTvTerms.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG); 224 // mTvTerms.setPaintFlags(mTvTerms.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
...@@ -231,9 +237,11 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe ...@@ -231,9 +237,11 @@ public class CouponsetInfoActivity extends Activity implements View.OnClickListe
231 } 237 }
232 238
233 mCoupon = new Coupon(result.optJSONObject("result")); 239 mCoupon = new Coupon(result.optJSONObject("result"));
234 - mCoupon.setDescription(mCouponset.getShortDescription()); 240 + if (mCouponset != null) {
235 - mCoupon.setImage(mCouponset.getImgPreview()); 241 + mCoupon.setDescription(mCouponset.getShortDescription());
236 - mCoupon.setName(mCouponset.getName()); 242 + mCoupon.setImage(mCouponset.getImgPreview());
243 + mCoupon.setName(mCouponset.getName());
244 + }
237 showDialog(true, 1); 245 showDialog(true, 1);
238 WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver); 246 WarplyManager.getUserCouponsWithCouponsets(mUserCouponsReceiver);
239 WarplyManager.getCampaigns(mCampaignsCallback); 247 WarplyManager.getCampaigns(mCampaignsCallback);
......
...@@ -579,12 +579,14 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener ...@@ -579,12 +579,14 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
579 /** Hide spinner and hide empty view and show vouchers and hide disabled vouchers */ 579 /** Hide spinner and hide empty view and show vouchers and hide disabled vouchers */
580 mLlVouchersSpinner.setVisibility(View.GONE); 580 mLlVouchersSpinner.setVisibility(View.GONE);
581 mLlEmptyWallet.setVisibility(View.GONE); 581 mLlEmptyWallet.setVisibility(View.GONE);
582 - if (TextUtils.isEmpty(WarpUtils.getLanguage(getContext())) || WarpUtils.getLanguage(getContext()).equals("el")) { 582 + if (getContext() != null || (getActivity() != null && !getActivity().isFinishing())) {
583 - mTvVouchersTitle.setText(getString(R.string.cos_vouchers_title)); 583 + if (TextUtils.isEmpty(WarpUtils.getLanguage(getContext())) || WarpUtils.getLanguage(getContext()).equals("el")) {
584 - mTvVouchersSubtitle.setText(getString(R.string.cos_vouchers_info_title)); 584 + mTvVouchersTitle.setText(getContext().getString(R.string.cos_vouchers_title));
585 - } else { 585 + mTvVouchersSubtitle.setText(getContext().getString(R.string.cos_vouchers_info_title));
586 - mTvVouchersTitle.setText(getString(R.string.cos_vouchers_title_en)); 586 + } else {
587 - mTvVouchersSubtitle.setText(getString(R.string.cos_vouchers_info_title_en)); 587 + mTvVouchersTitle.setText(getContext().getString(R.string.cos_vouchers_title_en));
588 + mTvVouchersSubtitle.setText(getContext().getString(R.string.cos_vouchers_info_title_en));
589 + }
588 } 590 }
589 mLlVouchers.setVisibility(View.VISIBLE); 591 mLlVouchers.setVisibility(View.VISIBLE);
590 mLlVouchersDisabled.setVisibility(View.GONE); 592 mLlVouchersDisabled.setVisibility(View.GONE);
...@@ -603,12 +605,14 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener ...@@ -603,12 +605,14 @@ public class MyRewardsFragment extends Fragment implements View.OnClickListener
603 mLlVouchersSpinner.setVisibility(View.GONE); 605 mLlVouchersSpinner.setVisibility(View.GONE);
604 mLlEmptyWallet.setVisibility(View.GONE); 606 mLlEmptyWallet.setVisibility(View.GONE);
605 mLlVouchers.setVisibility(View.GONE); 607 mLlVouchers.setVisibility(View.GONE);
606 - if (TextUtils.isEmpty(WarpUtils.getLanguage(getContext())) || WarpUtils.getLanguage(getContext()).equals("el")) { 608 + if (getContext() != null || (getActivity() != null && !getActivity().isFinishing())) {
607 - mTvVouchersDisabledTitle.setText(getString(R.string.cos_vouchers_title)); 609 + if (TextUtils.isEmpty(WarpUtils.getLanguage(getContext())) || WarpUtils.getLanguage(getContext()).equals("el")) {
608 - mTvVouchersDisabledSubtitle.setText(getString(R.string.cos_vouchers_info_title_disabled)); 610 + mTvVouchersDisabledTitle.setText(getContext().getString(R.string.cos_vouchers_title));
609 - } else { 611 + mTvVouchersDisabledSubtitle.setText(getContext().getString(R.string.cos_vouchers_info_title_disabled));
610 - mTvVouchersDisabledTitle.setText(getString(R.string.cos_vouchers_title_en)); 612 + } else {
611 - mTvVouchersDisabledSubtitle.setText(getString(R.string.cos_vouchers_info_title_disabled_en)); 613 + mTvVouchersDisabledTitle.setText(getContext().getString(R.string.cos_vouchers_title_en));
614 + mTvVouchersDisabledSubtitle.setText(getContext().getString(R.string.cos_vouchers_info_title_disabled_en));
615 + }
612 } 616 }
613 mLlVouchersDisabled.setVisibility(View.VISIBLE); 617 mLlVouchersDisabled.setVisibility(View.VISIBLE);
614 if ((WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() == 0) 618 if ((WarplyManagerHelper.getActiveDFYCoupons() != null && WarplyManagerHelper.getActiveDFYCoupons().size() == 0)
......
...@@ -187,7 +187,8 @@ public class WarplyAnalyticsManager { ...@@ -187,7 +187,8 @@ public class WarplyAnalyticsManager {
187 if (metadata != null) { 187 if (metadata != null) {
188 jObj.putOpt("action_metadata", metadata); 188 jObj.putOpt("action_metadata", metadata);
189 } 189 }
190 - Warply.postMicroappData(context, WarpConstants.MICROAPP_INAPP_ANALYTICS, jObj, force); 190 + if (context != null)
191 + Warply.postMicroappData(context, WarpConstants.MICROAPP_INAPP_ANALYTICS, jObj, force);
191 } catch (JSONException e) { 192 } catch (JSONException e) {
192 if (WarpConstants.DEBUG) { 193 if (WarpConstants.DEBUG) {
193 e.printStackTrace(); 194 e.printStackTrace();
......
...@@ -791,23 +791,25 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { ...@@ -791,23 +791,25 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
791 791
792 @Override 792 @Override
793 public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) { 793 public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) {
794 - final AlertDialog.Builder builder = new AlertDialog.Builder(getContext()); 794 + if (WarpActivity != null && !WarpActivity.isFinishing()) {
795 - builder.setTitle("Ειδοποίηση"); 795 + final AlertDialog.Builder builder = new AlertDialog.Builder(WarpActivity);
796 - builder.setMessage("Θα ανακατευθυνθείς σε σελίδα χωρίς έγκυρο πιστοποιητικό"); 796 + builder.setTitle("Ειδοποίηση");
797 - builder.setPositiveButton("Συμφωνώ", new DialogInterface.OnClickListener() { 797 + builder.setMessage("Θα ανακατευθυνθείς σε σελίδα χωρίς έγκυρο πιστοποιητικό");
798 - @Override 798 + builder.setPositiveButton("Συμφωνώ", new DialogInterface.OnClickListener() {
799 - public void onClick(DialogInterface dialog, int which) { 799 + @Override
800 - handler.proceed(); 800 + public void onClick(DialogInterface dialog, int which) {
801 - } 801 + handler.proceed();
802 - }); 802 + }
803 - builder.setNegativeButton("Άκυρο", new DialogInterface.OnClickListener() { 803 + });
804 - @Override 804 + builder.setNegativeButton("Άκυρο", new DialogInterface.OnClickListener() {
805 - public void onClick(DialogInterface dialog, int which) { 805 + @Override
806 - handler.cancel(); 806 + public void onClick(DialogInterface dialog, int which) {
807 - } 807 + handler.cancel();
808 - }); 808 + }
809 - final AlertDialog dialog = builder.create(); 809 + });
810 - dialog.show(); 810 + final AlertDialog dialog = builder.create();
811 + dialog.show();
812 + }
811 } 813 }
812 814
813 @Override 815 @Override
......