Skip to content
Permalink
Browse files

Fix for moving Criteo SDK initialization before load ad invocation

  • Loading branch information
Sneha Pathrose
Sneha Pathrose committed Nov 13, 2019
1 parent b1a8a95 commit 6f05a4f1806b02790f8ba845313af7b902a804b3
@@ -15,8 +15,7 @@
import com.mopub.common.logging.MoPubLog;
import com.mopub.mobileads.CustomEventBanner;
import com.mopub.mobileads.MoPubErrorCode;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;
import java.util.Map;

public class CriteoBannerAdapter extends CustomEventBanner {
@@ -56,21 +55,19 @@ protected void loadBanner(Context context, CustomEventBannerListener customEvent
}

try {
Criteo.getInstance();
Criteo.init((Application) (context.getApplicationContext()), criteoPublisherId,
Collections.<AdUnit>emptyList());
} catch (CriteoInitException e1) {
}

try {
BannerAdUnit bannerAdUnit = new BannerAdUnit(adUnitId, adSize);
bannerView = new CriteoBannerView(context, bannerAdUnit);
CriteoBannerEventListener listener = new CriteoBannerEventListener(customEventBannerListener);
bannerView.setCriteoBannerAdListener(listener);
bannerView.loadAd();
MoPubLog.log(LOAD_ATTEMPTED, TAG, "BannerView is loading");
} catch (Exception e) {
List<AdUnit> adUnits = new ArrayList<>();

try {
Criteo.init((Application) (context.getApplicationContext()), criteoPublisherId, adUnits);
} catch (CriteoInitException e1) {

}
MoPubLog.log(LOAD_FAILED, TAG, "Initialization failed");
customEventBannerListener.onBannerFailed(MoPubErrorCode.INTERNAL_ERROR);
}
@@ -16,6 +16,7 @@
import com.mopub.mobileads.CustomEventInterstitial;
import com.mopub.mobileads.MoPubErrorCode;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

@@ -53,7 +54,12 @@ protected void loadInterstitial(Context context, CustomEventInterstitialListener
}

try {
Criteo.getInstance();
Criteo.init((Application) (context.getApplicationContext()), criteoPublisherId,
Collections.<AdUnit>emptyList());
} catch (CriteoInitException e1) {
}

try {
InterstitialAdUnit interstitialAdUnit = new InterstitialAdUnit(adUnitId);
criteoInterstitial = new CriteoInterstitial(context, interstitialAdUnit);
CriteoInterstitialEventListener listener = new CriteoInterstitialEventListener(
@@ -63,12 +69,6 @@ protected void loadInterstitial(Context context, CustomEventInterstitialListener
criteoInterstitial.loadAd();
MoPubLog.log(LOAD_ATTEMPTED, TAG, "Criteo Interstitial is loading");
} catch (Exception e) {
List<AdUnit> adUnits = new ArrayList<>();

try {
Criteo.init((Application) (context.getApplicationContext()), criteoPublisherId, adUnits);
} catch (CriteoInitException e1) {
}
MoPubLog.log(LOAD_FAILED, TAG, "Initialization failed");
customEventInterstitialListener.onInterstitialFailed(MoPubErrorCode.INTERNAL_ERROR);
}

0 comments on commit 6f05a4f

Please sign in to comment.
You can’t perform that action at this time.