Search in sources :

Example 1 with WebViewBanner

use of org.prebid.mobile.rendering.views.webview.WebViewBanner in project prebid-mobile-android by prebid.

the class InterstitialManagerTest method displayPrebidWebViewForMraid_CallDelegateDisplayPrebidWebViewForMRAID.

@Test
public void displayPrebidWebViewForMraid_CallDelegateDisplayPrebidWebViewForMRAID() throws Exception {
    WebViewBanner mockWebView = mock(WebViewBanner.class);
    MraidEvent mockEvent = mock(MraidEvent.class);
    mockEvent.mraidAction = JSInterface.ACTION_EXPAND;
    mockEvent.mraidActionHelper = "test";
    when(mockWebView.getMraidEvent()).thenReturn(mockEvent);
    mSpyInterstitialManager.displayPrebidWebViewForMraid(mockWebView, true);
    verify(mMockMraidDelegate).displayPrebidWebViewForMraid(mockWebView, true, mockEvent);
}
Also used : WebViewBanner(org.prebid.mobile.rendering.views.webview.WebViewBanner) MraidEvent(org.prebid.mobile.rendering.models.internal.MraidEvent) Test(org.junit.Test)

Example 2 with WebViewBanner

use of org.prebid.mobile.rendering.views.webview.WebViewBanner in project prebid-mobile-android by prebid.

the class MraidControllerTest method expandWhenHelperNotEmpty_NewWebViewSetEvent.

@Test
public void expandWhenHelperNotEmpty_NewWebViewSetEvent() {
    WebViewBase mockOldWebView = mock(WebViewBase.class);
    PrebidWebViewBase mockNewWebView = mock(PrebidWebViewBase.class);
    MraidEvent event = createMraidEvent(JSInterface.ACTION_EXPAND, "twoPart");
    WebViewBanner mockBanner = mock(WebViewBanner.class);
    when(mockNewWebView.getMraidWebView()).thenReturn(mockBanner);
    when(mockOldWebView.getMraidListener()).thenReturn(mock(MraidEventsManager.MraidListener.class));
    mMraidController.expand(mockOldWebView, mockNewWebView, event);
    verify(mockNewWebView, times(1)).getMraidWebView();
    verify(mockBanner).setMraidEvent(eq(event));
}
Also used : PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) MraidEvent(org.prebid.mobile.rendering.models.internal.MraidEvent) WebViewBanner(org.prebid.mobile.rendering.views.webview.WebViewBanner) Test(org.junit.Test)

Example 3 with WebViewBanner

use of org.prebid.mobile.rendering.views.webview.WebViewBanner in project prebid-mobile-android by prebid.

the class InterstitialManager method interstitialClosed.

@Override
public void interstitialClosed(View viewToClose) {
    LogUtil.debug(TAG, "interstitialClosed");
    try {
        if (!mViewStack.isEmpty() && mMraidDelegate != null) {
            View poppedViewState = mViewStack.pop();
            // take the old one  & display(ex: close of a video inside of an expanded ad
            // should take it back to the defaultview of the ad.
            mMraidDelegate.displayViewInInterstitial(poppedViewState, false, null, null);
            return;
        }
        // IMPORTANT: HAS to be there inspite of calling close above.
        if ((mMraidDelegate == null || !mMraidDelegate.collapseMraid()) && mInterstitialDialog != null) {
            mInterstitialDialog.nullifyDialog();
            mInterstitialDialog = null;
        }
        if (mMraidDelegate != null) {
            mMraidDelegate.closeThroughJs((WebViewBase) viewToClose);
        }
        // resize->click->expandedview->click on playvideo->pressback->goes back to the expanded state. We should not send clickthrough event to pub, for this case.
        if (mInterstitialDisplayDelegate != null && !(viewToClose instanceof WebViewBanner)) {
            mInterstitialDisplayDelegate.interstitialAdClosed();
        }
    } catch (Exception e) {
        LogUtil.error(TAG, "InterstitialClosed failed: " + Log.getStackTraceString(e));
    }
}
Also used : WebViewBanner(org.prebid.mobile.rendering.views.webview.WebViewBanner) InterstitialView(org.prebid.mobile.rendering.bidding.display.InterstitialView) VideoView(org.prebid.mobile.rendering.bidding.display.VideoView) View(android.view.View)

Example 4 with WebViewBanner

use of org.prebid.mobile.rendering.views.webview.WebViewBanner in project prebid-mobile-android by prebid.

the class MraidClose method closeThroughJS.

public void closeThroughJS() {
    final Context context = mContext;
    if (context == null) {
        LogUtil.error(TAG, "Context is null");
        return;
    }
    Handler uiHandler = new Handler(Looper.getMainLooper());
    uiHandler.post(() -> {
        try {
            String state = mJsi.getMraidVariableContainer().getCurrentState();
            WebViewBase webViewBase = mWebViewBase;
            if (isContainerStateInvalid(state)) {
                LogUtil.debug(TAG, "closeThroughJS: Skipping. Wrong container state: " + state);
                return;
            }
            changeState(state);
            if (webViewBase instanceof WebViewBanner && webViewBase.getMRAIDInterface().getDefaultLayoutParams() != null) {
                webViewBase.setLayoutParams(webViewBase.getMRAIDInterface().getDefaultLayoutParams());
            }
        } catch (Exception e) {
            LogUtil.error(TAG, "closeThroughJS failed: " + Log.getStackTraceString(e));
        }
    });
}
Also used : Context(android.content.Context) WebViewBase(org.prebid.mobile.rendering.views.webview.WebViewBase) PrebidWebViewBase(org.prebid.mobile.rendering.views.webview.PrebidWebViewBase) Handler(android.os.Handler) WebViewBanner(org.prebid.mobile.rendering.views.webview.WebViewBanner)

Aggregations

WebViewBanner (org.prebid.mobile.rendering.views.webview.WebViewBanner)4 Test (org.junit.Test)2 MraidEvent (org.prebid.mobile.rendering.models.internal.MraidEvent)2 PrebidWebViewBase (org.prebid.mobile.rendering.views.webview.PrebidWebViewBase)2 WebViewBase (org.prebid.mobile.rendering.views.webview.WebViewBase)2 Context (android.content.Context)1 Handler (android.os.Handler)1 View (android.view.View)1 InterstitialView (org.prebid.mobile.rendering.bidding.display.InterstitialView)1 VideoView (org.prebid.mobile.rendering.bidding.display.VideoView)1