Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Doin authored and Leonardo Doin committed Feb 19, 2020
1 parent 53a43dd commit 27f4953
Showing 1 changed file with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.sourcepoint.gdpr_cmplibrary;

import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Build;
import android.os.CountDownTimer;
import android.text.TextUtils;
Expand Down Expand Up @@ -150,9 +153,9 @@ public static ConsentLibBuilder newBuilder(Integer accountId, String property, I
sourcePoint = b.sourcePointClient;

storeClient = b.storeClient;

setConsentData(b.authId);


setSubjectToGDPR();

}
Expand Down Expand Up @@ -185,6 +188,17 @@ private boolean didAuthIdChange(String newAuthId){
return true;
}

private boolean hasLostInternetConnection() {
ConnectivityManager manager = (ConnectivityManager) activity
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (manager == null) {
return true;
}

NetworkInfo activeNetwork = manager.getActiveNetworkInfo();
return activeNetwork == null || !activeNetwork.isConnectedOrConnecting();
}

private ConsentWebView buildWebView() {
return new ConsentWebView(activity, defaultMessageTimeOut) {

Expand Down Expand Up @@ -311,6 +325,10 @@ public void run() {
* @throws ConsentLibException.NoInternetConnectionException - thrown if the device has lost connection either prior or while interacting with GDPRConsentLib
*/
public void run() {
if(hasLostInternetConnection()){
onErrorTask(new ConsentLibException("No internet connection"));
return;
}
try {
onMessageReadyCalled = false;
renderMsgAndSaveConsent();
Expand Down Expand Up @@ -386,7 +404,7 @@ private void closeCurrentMessageView(){
}

private void closeView(View v){
runOnLiveActivityUIThread(() -> GDPRConsentLib.this.onConsentUIFinished.run(v));
if(v != null) runOnLiveActivityUIThread(() -> GDPRConsentLib.this.onConsentUIFinished.run(v));
}

private JSONObject paramsToSendConsent(int actionType, Integer choiceId) throws ConsentLibException {
Expand Down

0 comments on commit 27f4953

Please sign in to comment.