Showing
3 changed files
with
33 additions
and
12 deletions
| ... | @@ -1586,8 +1586,8 @@ public enum Warply { | ... | @@ -1586,8 +1586,8 @@ public enum Warply { |
| 1586 | } | 1586 | } |
| 1587 | } | 1587 | } |
| 1588 | 1588 | ||
| 1589 | - if (INSTANCE.mRequestQueue == null) | 1589 | + if (INSTANCE.mRequestQueue == null && INSTANCE.mContext != null) |
| 1590 | - INSTANCE.mRequestQueue = Volley.newRequestQueue(mContext); | 1590 | + INSTANCE.mRequestQueue = Volley.newRequestQueue(INSTANCE.mContext); |
| 1591 | 1591 | ||
| 1592 | if (tempAnalytics != null && tempAnalytics.length() > 0) { | 1592 | if (tempAnalytics != null && tempAnalytics.length() > 0) { |
| 1593 | String urlAnalytics = WarplyProperty.getBaseUrl(mContext) + WarpConstants.WARPLY_ASYNC + WarpConstants.WARPLY_ANALYTICS + WarplyProperty.getAppUuid(mContext) + "/"; | 1593 | String urlAnalytics = WarplyProperty.getBaseUrl(mContext) + WarpConstants.WARPLY_ASYNC + WarpConstants.WARPLY_ANALYTICS + WarplyProperty.getAppUuid(mContext) + "/"; | ... | ... |
| ... | @@ -247,7 +247,7 @@ public class WarplyManagerHelper { | ... | @@ -247,7 +247,7 @@ public class WarplyManagerHelper { |
| 247 | /** | 247 | /** |
| 248 | * Handle sharing flow | 248 | * Handle sharing flow |
| 249 | */ | 249 | */ |
| 250 | - public static void handleSharing(Context context, String sharingId) { | 250 | + public static void handleSharing(Activity context, String sharingId) { |
| 251 | WarpUtils.log("SHARING_ID: " + sharingId); | 251 | WarpUtils.log("SHARING_ID: " + sharingId); |
| 252 | WarplyManager.cosmoteSharing(new CosmoteSharingRequest().setSharingId(sharingId), new CallbackReceiver<JSONObject>() { | 252 | WarplyManager.cosmoteSharing(new CosmoteSharingRequest().setSharingId(sharingId), new CallbackReceiver<JSONObject>() { |
| 253 | @Override | 253 | @Override |
| ... | @@ -292,7 +292,8 @@ public class WarplyManagerHelper { | ... | @@ -292,7 +292,8 @@ public class WarplyManagerHelper { |
| 292 | /** | 292 | /** |
| 293 | * First dialog when we handle the deeplink | 293 | * First dialog when we handle the deeplink |
| 294 | */ | 294 | */ |
| 295 | - private static void initialSharingDialog(Context context, String alertTitle, String sharingId, boolean isSupermarket) { | 295 | + private static void initialSharingDialog(Activity context, String alertTitle, String sharingId, boolean isSupermarket) { |
| 296 | + if (!context.isFinishing()) { | ||
| 296 | mAlertDialogSharing = new AlertDialog.Builder(context) | 297 | mAlertDialogSharing = new AlertDialog.Builder(context) |
| 297 | .setTitle(R.string.cos_dlg_success_title) | 298 | .setTitle(R.string.cos_dlg_success_title) |
| 298 | .setMessage(alertTitle) | 299 | .setMessage(alertTitle) |
| ... | @@ -334,11 +335,13 @@ public class WarplyManagerHelper { | ... | @@ -334,11 +335,13 @@ public class WarplyManagerHelper { |
| 334 | }) | 335 | }) |
| 335 | .show(); | 336 | .show(); |
| 336 | } | 337 | } |
| 338 | + } | ||
| 337 | 339 | ||
| 338 | /** | 340 | /** |
| 339 | * Dialog when we success get the sharing gift | 341 | * Dialog when we success get the sharing gift |
| 340 | */ | 342 | */ |
| 341 | - private static void acceptSharingDialog(Context context, boolean isSupermarket) { | 343 | + private static void acceptSharingDialog(Activity context, boolean isSupermarket) { |
| 344 | + if (!context.isFinishing()) { | ||
| 342 | mAlertDialogAcceptSharing = new AlertDialog.Builder(context) | 345 | mAlertDialogAcceptSharing = new AlertDialog.Builder(context) |
| 343 | .setTitle(R.string.cos_dlg_success_title) | 346 | .setTitle(R.string.cos_dlg_success_title) |
| 344 | .setMessage(isSupermarket ? R.string.cos_dlg_positive_button_text2 : R.string.cos_dlg_positive_button_text) | 347 | .setMessage(isSupermarket ? R.string.cos_dlg_positive_button_text2 : R.string.cos_dlg_positive_button_text) |
| ... | @@ -347,11 +350,13 @@ public class WarplyManagerHelper { | ... | @@ -347,11 +350,13 @@ public class WarplyManagerHelper { |
| 347 | }) | 350 | }) |
| 348 | .show(); | 351 | .show(); |
| 349 | } | 352 | } |
| 353 | + } | ||
| 350 | 354 | ||
| 351 | /** | 355 | /** |
| 352 | * Dialog when we reject the sharing gift | 356 | * Dialog when we reject the sharing gift |
| 353 | */ | 357 | */ |
| 354 | - private static void rejectSharingDialog(Context context, String sharingId) { | 358 | + private static void rejectSharingDialog(Activity context, String sharingId) { |
| 359 | + if (!context.isFinishing()) { | ||
| 355 | mAlertDialogRejectSharing = new AlertDialog.Builder(context) | 360 | mAlertDialogRejectSharing = new AlertDialog.Builder(context) |
| 356 | .setTitle(R.string.cos_dlg_reject_title) | 361 | .setTitle(R.string.cos_dlg_reject_title) |
| 357 | .setMessage(R.string.cos_dlg_reject_text) | 362 | .setMessage(R.string.cos_dlg_reject_text) |
| ... | @@ -380,11 +385,13 @@ public class WarplyManagerHelper { | ... | @@ -380,11 +385,13 @@ public class WarplyManagerHelper { |
| 380 | }) | 385 | }) |
| 381 | .show(); | 386 | .show(); |
| 382 | } | 387 | } |
| 388 | + } | ||
| 383 | 389 | ||
| 384 | /** | 390 | /** |
| 385 | * Dialog when the gift gets returned | 391 | * Dialog when the gift gets returned |
| 386 | */ | 392 | */ |
| 387 | - private static void returnSharingDialog(Context context, String alertTitle) { | 393 | + private static void returnSharingDialog(Activity context, String alertTitle) { |
| 394 | + if (!context.isFinishing()) { | ||
| 388 | mAlertDialogReturnSharing = new AlertDialog.Builder(context) | 395 | mAlertDialogReturnSharing = new AlertDialog.Builder(context) |
| 389 | .setTitle(R.string.cod_dlg_return_title) | 396 | .setTitle(R.string.cod_dlg_return_title) |
| 390 | .setMessage(alertTitle) | 397 | .setMessage(alertTitle) |
| ... | @@ -393,11 +400,13 @@ public class WarplyManagerHelper { | ... | @@ -393,11 +400,13 @@ public class WarplyManagerHelper { |
| 393 | }) | 400 | }) |
| 394 | .show(); | 401 | .show(); |
| 395 | } | 402 | } |
| 403 | + } | ||
| 396 | 404 | ||
| 397 | /** | 405 | /** |
| 398 | * Dialog when the gift gets successfully returned | 406 | * Dialog when the gift gets successfully returned |
| 399 | */ | 407 | */ |
| 400 | - private static void returnSharingSuccessDialog(Context context) { | 408 | + private static void returnSharingSuccessDialog(Activity context) { |
| 409 | + if (!context.isFinishing()) { | ||
| 401 | mAlertDialogReturnSharing = new AlertDialog.Builder(context) | 410 | mAlertDialogReturnSharing = new AlertDialog.Builder(context) |
| 402 | .setTitle(R.string.cod_dlg_reject_title) | 411 | .setTitle(R.string.cod_dlg_reject_title) |
| 403 | .setMessage(R.string.cod_dlg_reject_subtitle) | 412 | .setMessage(R.string.cod_dlg_reject_subtitle) |
| ... | @@ -406,11 +415,13 @@ public class WarplyManagerHelper { | ... | @@ -406,11 +415,13 @@ public class WarplyManagerHelper { |
| 406 | }) | 415 | }) |
| 407 | .show(); | 416 | .show(); |
| 408 | } | 417 | } |
| 418 | + } | ||
| 409 | 419 | ||
| 410 | /** | 420 | /** |
| 411 | * Error dialog | 421 | * Error dialog |
| 412 | */ | 422 | */ |
| 413 | - private static void errorSharingDialog(Context context) { | 423 | + private static void errorSharingDialog(Activity context) { |
| 424 | + if (!context.isFinishing()) { | ||
| 414 | mAlertDialogErrorSharing = new AlertDialog.Builder(context) | 425 | mAlertDialogErrorSharing = new AlertDialog.Builder(context) |
| 415 | .setTitle(R.string.cos_dlg_error_title) | 426 | .setTitle(R.string.cos_dlg_error_title) |
| 416 | .setMessage(R.string.cos_dlg_error_subtitle) | 427 | .setMessage(R.string.cos_dlg_error_subtitle) |
| ... | @@ -419,11 +430,13 @@ public class WarplyManagerHelper { | ... | @@ -419,11 +430,13 @@ public class WarplyManagerHelper { |
| 419 | }) | 430 | }) |
| 420 | .show(); | 431 | .show(); |
| 421 | } | 432 | } |
| 433 | + } | ||
| 422 | 434 | ||
| 423 | /** | 435 | /** |
| 424 | * Return dialog | 436 | * Return dialog |
| 425 | */ | 437 | */ |
| 426 | - private static void returnDialog(Context context, String message, String sharingId) { | 438 | + private static void returnDialog(Activity context, String message, String sharingId) { |
| 439 | + if (!context.isFinishing()) { | ||
| 427 | mAlertDialogErrorSharing = new AlertDialog.Builder(context) | 440 | mAlertDialogErrorSharing = new AlertDialog.Builder(context) |
| 428 | .setTitle(R.string.cos_dlg_return_title) | 441 | .setTitle(R.string.cos_dlg_return_title) |
| 429 | .setMessage(message) | 442 | .setMessage(message) |
| ... | @@ -466,11 +479,13 @@ public class WarplyManagerHelper { | ... | @@ -466,11 +479,13 @@ public class WarplyManagerHelper { |
| 466 | }) | 479 | }) |
| 467 | .show(); | 480 | .show(); |
| 468 | } | 481 | } |
| 482 | + } | ||
| 469 | 483 | ||
| 470 | /** | 484 | /** |
| 471 | * Expired dialog | 485 | * Expired dialog |
| 472 | */ | 486 | */ |
| 473 | - private static void errorExpiredDialog(Context context, String message) { | 487 | + private static void errorExpiredDialog(Activity context, String message) { |
| 488 | + if (!context.isFinishing()) { | ||
| 474 | mAlertDialogErrorExpiredSharing = new AlertDialog.Builder(context) | 489 | mAlertDialogErrorExpiredSharing = new AlertDialog.Builder(context) |
| 475 | .setTitle(R.string.cos_dlg_error_title) | 490 | .setTitle(R.string.cos_dlg_error_title) |
| 476 | .setMessage(message) | 491 | .setMessage(message) |
| ... | @@ -479,11 +494,13 @@ public class WarplyManagerHelper { | ... | @@ -479,11 +494,13 @@ public class WarplyManagerHelper { |
| 479 | }) | 494 | }) |
| 480 | .show(); | 495 | .show(); |
| 481 | } | 496 | } |
| 497 | + } | ||
| 482 | 498 | ||
| 483 | /** | 499 | /** |
| 484 | * Used dialog | 500 | * Used dialog |
| 485 | */ | 501 | */ |
| 486 | - private static void errorUsedDialog(Context context, String message) { | 502 | + private static void errorUsedDialog(Activity context, String message) { |
| 503 | + if (!context.isFinishing()) { | ||
| 487 | mAlertDialogErrorUsedSharing = new AlertDialog.Builder(context) | 504 | mAlertDialogErrorUsedSharing = new AlertDialog.Builder(context) |
| 488 | .setTitle(R.string.cos_dlg_error_title) | 505 | .setTitle(R.string.cos_dlg_error_title) |
| 489 | .setMessage(message) | 506 | .setMessage(message) |
| ... | @@ -492,6 +509,7 @@ public class WarplyManagerHelper { | ... | @@ -492,6 +509,7 @@ public class WarplyManagerHelper { |
| 492 | }) | 509 | }) |
| 493 | .show(); | 510 | .show(); |
| 494 | } | 511 | } |
| 512 | + } | ||
| 495 | 513 | ||
| 496 | /** | 514 | /** |
| 497 | * No Internet Connection Dialog | 515 | * No Internet Connection Dialog | ... | ... |
| ... | @@ -659,6 +659,7 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { | ... | @@ -659,6 +659,7 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { |
| 659 | private void checkForPermissions(String origin, Callback callback) { | 659 | private void checkForPermissions(String origin, Callback callback) { |
| 660 | String perm = Manifest.permission.ACCESS_FINE_LOCATION; | 660 | String perm = Manifest.permission.ACCESS_FINE_LOCATION; |
| 661 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || getContext().checkSelfPermission(perm) == PackageManager.PERMISSION_GRANTED) { | 661 | if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || getContext().checkSelfPermission(perm) == PackageManager.PERMISSION_GRANTED) { |
| 662 | + geolocationCallback = callback; | ||
| 662 | if (isGPSEnabled()) { | 663 | if (isGPSEnabled()) { |
| 663 | callback.invoke(origin, true, false); | 664 | callback.invoke(origin, true, false); |
| 664 | } else { | 665 | } else { |
| ... | @@ -678,6 +679,8 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { | ... | @@ -678,6 +679,8 @@ public class WarpView extends WebView implements DefaultLifecycleObserver { |
| 678 | } | 679 | } |
| 679 | 680 | ||
| 680 | private void enableLocationSettings() { | 681 | private void enableLocationSettings() { |
| 682 | + if (geolocationCallback == null) return; | ||
| 683 | + | ||
| 681 | GoogleApiClient googleApiClient = new GoogleApiClient.Builder(WarpActivity) | 684 | GoogleApiClient googleApiClient = new GoogleApiClient.Builder(WarpActivity) |
| 682 | .addApi(LocationServices.API) | 685 | .addApi(LocationServices.API) |
| 683 | .build(); | 686 | .build(); | ... | ... |
-
Please register or login to post a comment