use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class DisplayViewTest method whenAdViewManagerListenerFailedToLoad_NotifyListenerOnAdFailed.
@Test
public void whenAdViewManagerListenerFailedToLoad_NotifyListenerOnAdFailed() throws IllegalAccessException {
AdViewManagerListener adViewManagerListener = getAdViewManagerListener();
adViewManagerListener.failedToLoad(new AdException(AdException.INTERNAL_ERROR, "Test"));
verify(mMockDisplayViewListener).onAdFailed(any(AdException.class));
}
use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class TransactionTest method onSuccessWithCreativeTimeout_TransactionListenerSuccessNotCalled.
@Test
public void onSuccessWithCreativeTimeout_TransactionListenerSuccessNotCalled() throws Exception {
List<CreativeModel> creativeModels = Arrays.asList(mock(CreativeModel.class), mock(CreativeModel.class));
Transaction.Listener mockListener = mock(Transaction.Listener.class);
InterstitialManager mockInterstitialManager = mock(InterstitialManager.class);
Transaction transaction = Transaction.createTransaction(mMockContext, createModelResult(creativeModels, ""), mockInterstitialManager, mockListener);
Transaction.CreativeFactoryListener creativeFactoryListener = new Transaction.CreativeFactoryListener(transaction);
Iterator<CreativeFactory> mockIterator = mock(Iterator.class);
when(mockIterator.hasNext()).thenReturn(true);
when(mockIterator.next()).thenReturn(mock(CreativeFactory.class));
WhiteBox.setInternalState(transaction, "mCreativeFactoryIterator", mockIterator);
creativeFactoryListener.onSuccess();
verify(mockListener, never()).onTransactionSuccess(transaction);
AdException adException = new AdException(AdException.INTERNAL_ERROR, "CreativeFactory Timeout");
creativeFactoryListener.onFailure(adException);
verify(mockListener).onTransactionFailure(eq(adException), anyString());
}
use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class PrebidWebViewBanner method preloaded.
@Override
public void preloaded(WebViewBase adBaseView) {
if (adBaseView == null) {
// This should never happen.
LogUtil.error(TAG, "Failed to preload a banner ad. Webview is null.");
if (mWebViewDelegate != null) {
mWebViewDelegate.webViewFailedToLoad(new AdException(AdException.INTERNAL_ERROR, "Preloaded adview is null!"));
}
return;
}
mCurrentWebViewBase = adBaseView;
if (mCurrentWebViewBase.mMRAIDBridgeName.equals("twopart")) {
// SHould have expanded url here, as last param
mInterstitialManager.displayPrebidWebViewForMraid(mMraidWebView, true);
} else {
if (adBaseView.getParent() == null) {
if (getChildCount() >= 1) {
LogUtil.debug(TAG, "Adding second view");
// safe removal from parent before adding
Views.removeFromParent(adBaseView);
addView(adBaseView, 1);
adBaseView.bringToFront();
swapWebViews();
} else {
LogUtil.debug(TAG, "Adding first view");
// safe removal from parent before adding
Views.removeFromParent(adBaseView);
addView(adBaseView, 0);
renderAdView(adBaseView);
}
} else {
LogUtil.debug(TAG, "Adding the only view");
adBaseView.bringToFront();
swapWebViews();
}
}
/*
* This postInvalidate fixes the cosmetic issue that KitKat created with the white banner
* fragment/remnant showing up at the bottom of the screen.
*/
if (mContext instanceof Activity) {
((Activity) mContext).getWindow().getDecorView().findViewById(android.R.id.content).postInvalidate();
((Activity) mContext).getWindow().getDecorView().findViewById(android.R.id.content).postInvalidateDelayed(100);
}
if (mWebViewDelegate != null) {
mWebViewDelegate.webViewReadyToDisplay();
}
}
use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class PrebidInterstitialAdapter method getListener.
private InterstitialControllerListener getListener(CustomEventInterstitialListener adMobListener) {
return new InterstitialControllerListener() {
@Override
public void onInterstitialReadyForDisplay() {
adMobListener.onAdLoaded();
}
@Override
public void onInterstitialDisplayed() {
adMobListener.onAdOpened();
}
@Override
public void onInterstitialClicked() {
adMobListener.onAdClicked();
}
@Override
public void onInterstitialClosed() {
adMobListener.onAdClosed();
}
@Override
public void onInterstitialFailedToLoad(AdException exception) {
String error = "Failed to load ad: " + exception.getMessage();
Log.e(TAG, error);
adMobListener.onAdFailedToLoad(new AdError(1005, error, "prebid"));
}
};
}
use of org.prebid.mobile.rendering.errors.AdException in project prebid-mobile-android by prebid.
the class PrebidInterstitialAdapter method requestInterstitialAd.
@Override
public void requestInterstitialAd(@NonNull Context context, @NonNull CustomEventInterstitialListener adMobListener, @Nullable String serverParameter, @NonNull MediationAdRequest mediationAdRequest, @Nullable Bundle extras) {
if (extras == null) {
String error = "Extras are empty! Check if you add custom event extras bundle to " + TAG;
Log.e(TAG, error);
adMobListener.onAdFailedToLoad(new AdError(1001, error, "prebid"));
return;
}
String responseId = extras.getString(EXTRA_RESPONSE_ID);
if (responseId == null) {
String error = "Response id is null";
adMobListener.onAdFailedToLoad(new AdError(1002, error, "prebid"));
return;
}
HashMap<String, String> prebidParameters = BidResponseCache.getInstance().getKeywords(responseId);
if (!ParametersMatcher.doParametersMatch(serverParameter, prebidParameters)) {
String error = "Parameters are different";
adMobListener.onAdFailedToLoad(new AdError(1003, error, "prebid"));
return;
}
LogUtil.v(TAG, "Parameters are matched! (" + serverParameter + ")");
try {
InterstitialControllerListener listener = getListener(adMobListener);
interstitialController = new InterstitialController(context, listener);
interstitialController.loadAd(responseId, false);
} catch (AdException e) {
String error = "Exception in Prebid interstitial controller (" + e.getMessage() + ")";
Log.e(TAG, error);
adMobListener.onAdFailedToLoad(new AdError(1004, error, "prebid"));
}
}
Aggregations