Panagiotis Triantafyllou

crash fixes

......@@ -1586,8 +1586,8 @@ public enum Warply {
}
}
if (INSTANCE.mRequestQueue == null)
INSTANCE.mRequestQueue = Volley.newRequestQueue(mContext);
if (INSTANCE.mRequestQueue == null && INSTANCE.mContext != null)
INSTANCE.mRequestQueue = Volley.newRequestQueue(INSTANCE.mContext);
if (tempAnalytics != null && tempAnalytics.length() > 0) {
String urlAnalytics = WarplyProperty.getBaseUrl(mContext) + WarpConstants.WARPLY_ASYNC + WarpConstants.WARPLY_ANALYTICS + WarplyProperty.getAppUuid(mContext) + "/";
......
......@@ -247,7 +247,7 @@ public class WarplyManagerHelper {
/**
* Handle sharing flow
*/
public static void handleSharing(Context context, String sharingId) {
public static void handleSharing(Activity context, String sharingId) {
WarpUtils.log("SHARING_ID: " + sharingId);
WarplyManager.cosmoteSharing(new CosmoteSharingRequest().setSharingId(sharingId), new CallbackReceiver<JSONObject>() {
@Override
......@@ -292,7 +292,8 @@ public class WarplyManagerHelper {
/**
* First dialog when we handle the deeplink
*/
private static void initialSharingDialog(Context context, String alertTitle, String sharingId, boolean isSupermarket) {
private static void initialSharingDialog(Activity context, String alertTitle, String sharingId, boolean isSupermarket) {
if (!context.isFinishing()) {
mAlertDialogSharing = new AlertDialog.Builder(context)
.setTitle(R.string.cos_dlg_success_title)
.setMessage(alertTitle)
......@@ -334,11 +335,13 @@ public class WarplyManagerHelper {
})
.show();
}
}
/**
* Dialog when we success get the sharing gift
*/
private static void acceptSharingDialog(Context context, boolean isSupermarket) {
private static void acceptSharingDialog(Activity context, boolean isSupermarket) {
if (!context.isFinishing()) {
mAlertDialogAcceptSharing = new AlertDialog.Builder(context)
.setTitle(R.string.cos_dlg_success_title)
.setMessage(isSupermarket ? R.string.cos_dlg_positive_button_text2 : R.string.cos_dlg_positive_button_text)
......@@ -347,11 +350,13 @@ public class WarplyManagerHelper {
})
.show();
}
}
/**
* Dialog when we reject the sharing gift
*/
private static void rejectSharingDialog(Context context, String sharingId) {
private static void rejectSharingDialog(Activity context, String sharingId) {
if (!context.isFinishing()) {
mAlertDialogRejectSharing = new AlertDialog.Builder(context)
.setTitle(R.string.cos_dlg_reject_title)
.setMessage(R.string.cos_dlg_reject_text)
......@@ -380,11 +385,13 @@ public class WarplyManagerHelper {
})
.show();
}
}
/**
* Dialog when the gift gets returned
*/
private static void returnSharingDialog(Context context, String alertTitle) {
private static void returnSharingDialog(Activity context, String alertTitle) {
if (!context.isFinishing()) {
mAlertDialogReturnSharing = new AlertDialog.Builder(context)
.setTitle(R.string.cod_dlg_return_title)
.setMessage(alertTitle)
......@@ -393,11 +400,13 @@ public class WarplyManagerHelper {
})
.show();
}
}
/**
* Dialog when the gift gets successfully returned
*/
private static void returnSharingSuccessDialog(Context context) {
private static void returnSharingSuccessDialog(Activity context) {
if (!context.isFinishing()) {
mAlertDialogReturnSharing = new AlertDialog.Builder(context)
.setTitle(R.string.cod_dlg_reject_title)
.setMessage(R.string.cod_dlg_reject_subtitle)
......@@ -406,11 +415,13 @@ public class WarplyManagerHelper {
})
.show();
}
}
/**
* Error dialog
*/
private static void errorSharingDialog(Context context) {
private static void errorSharingDialog(Activity context) {
if (!context.isFinishing()) {
mAlertDialogErrorSharing = new AlertDialog.Builder(context)
.setTitle(R.string.cos_dlg_error_title)
.setMessage(R.string.cos_dlg_error_subtitle)
......@@ -419,11 +430,13 @@ public class WarplyManagerHelper {
})
.show();
}
}
/**
* Return dialog
*/
private static void returnDialog(Context context, String message, String sharingId) {
private static void returnDialog(Activity context, String message, String sharingId) {
if (!context.isFinishing()) {
mAlertDialogErrorSharing = new AlertDialog.Builder(context)
.setTitle(R.string.cos_dlg_return_title)
.setMessage(message)
......@@ -466,11 +479,13 @@ public class WarplyManagerHelper {
})
.show();
}
}
/**
* Expired dialog
*/
private static void errorExpiredDialog(Context context, String message) {
private static void errorExpiredDialog(Activity context, String message) {
if (!context.isFinishing()) {
mAlertDialogErrorExpiredSharing = new AlertDialog.Builder(context)
.setTitle(R.string.cos_dlg_error_title)
.setMessage(message)
......@@ -479,11 +494,13 @@ public class WarplyManagerHelper {
})
.show();
}
}
/**
* Used dialog
*/
private static void errorUsedDialog(Context context, String message) {
private static void errorUsedDialog(Activity context, String message) {
if (!context.isFinishing()) {
mAlertDialogErrorUsedSharing = new AlertDialog.Builder(context)
.setTitle(R.string.cos_dlg_error_title)
.setMessage(message)
......@@ -492,6 +509,7 @@ public class WarplyManagerHelper {
})
.show();
}
}
/**
* No Internet Connection Dialog
......
......@@ -659,6 +659,7 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
private void checkForPermissions(String origin, Callback callback) {
String perm = Manifest.permission.ACCESS_FINE_LOCATION;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M || getContext().checkSelfPermission(perm) == PackageManager.PERMISSION_GRANTED) {
geolocationCallback = callback;
if (isGPSEnabled()) {
callback.invoke(origin, true, false);
} else {
......@@ -678,6 +679,8 @@ public class WarpView extends WebView implements DefaultLifecycleObserver {
}
private void enableLocationSettings() {
if (geolocationCallback == null) return;
GoogleApiClient googleApiClient = new GoogleApiClient.Builder(WarpActivity)
.addApi(LocationServices.API)
.build();
......