Search in sources :

Example 6 with VisibilityTrackerOption

use of org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption in project prebid-mobile-android by prebid.

the class CreativeVisibilityTrackerTest method hasRequiredTimeElapsedWithStartTimeSet_And_ElapsedTimeLessThanMinTimeViewed_ReturnFalse.

@Test
public void hasRequiredTimeElapsedWithStartTimeSet_And_ElapsedTimeLessThanMinTimeViewed_ReturnFalse() {
    mSpyVisibilityChecker = new VisibilityChecker(new VisibilityTrackerOption(NativeEventTracker.EventType.VIEWABLE_MRC50));
    mSpyVisibilityChecker.setStartTimeMillis();
    // minVisibleMillis is 1 sec, should return false since we are checking immediately before 1 sec elapses
    assertFalse(mSpyVisibilityChecker.hasRequiredTimeElapsed());
}
Also used : VisibilityChecker(org.prebid.mobile.rendering.utils.helpers.VisibilityChecker) VisibilityTrackerOption(org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption) Test(org.junit.Test)

Example 7 with VisibilityTrackerOption

use of org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption in project prebid-mobile-android by prebid.

the class CreativeVisibilityTrackerTest method mockVisibilityChecker.

private void mockVisibilityChecker(CreativeVisibilityTracker visibilityTracker, ViewExposure desiredViewExposure, Set<VisibilityTrackerOption> optionSet) {
    List<VisibilityChecker> visibilityCheckerList = new ArrayList<>();
    for (VisibilityTrackerOption trackerOption : optionSet) {
        VisibilityChecker visibilityChecker = spy(new VisibilityChecker(trackerOption));
        when(visibilityChecker.checkViewExposure(any(View.class))).thenReturn(desiredViewExposure);
        visibilityCheckerList.add(visibilityChecker);
    }
    WhiteBox.setInternalState(visibilityTracker, "mVisibilityCheckerList", visibilityCheckerList);
}
Also used : VisibilityChecker(org.prebid.mobile.rendering.utils.helpers.VisibilityChecker) ArrayList(java.util.ArrayList) VisibilityTrackerOption(org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption) View(android.view.View)

Example 8 with VisibilityTrackerOption

use of org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption in project prebid-mobile-android by prebid.

the class VideoCreative method startViewabilityTracker.

@Override
public void startViewabilityTracker() {
    VisibilityTrackerOption visibilityTrackerOption = new VisibilityTrackerOption(NativeEventTracker.EventType.IMPRESSION);
    mCreativeVisibilityTracker = new CreativeVisibilityTracker(getCreativeView(), visibilityTrackerOption);
    mCreativeVisibilityTracker.setVisibilityTrackerListener((result) -> {
        if (result.isVisible() && result.shouldFireImpression()) {
            mModel.trackVideoEvent(VideoAdEvent.Event.AD_IMPRESSION);
            mCreativeVisibilityTracker.stopVisibilityCheck();
            mCreativeVisibilityTracker = null;
        }
    });
    mCreativeVisibilityTracker.startVisibilityCheck(mContextReference.get());
}
Also used : CreativeVisibilityTracker(org.prebid.mobile.rendering.models.CreativeVisibilityTracker) VisibilityTrackerOption(org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption)

Example 9 with VisibilityTrackerOption

use of org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption in project prebid-mobile-android by prebid.

the class VideoView method startVisibilityTracking.

private void startVisibilityTracking() {
    stopVisibilityTracking();
    final VisibilityTrackerOption visibilityTrackerOption = new VisibilityTrackerOption(NativeEventTracker.EventType.IMPRESSION);
    mVisibilityTracker = new CreativeVisibilityTracker(this, visibilityTrackerOption, true);
    mVisibilityTracker.setVisibilityTrackerListener(mVisibilityTrackerListener);
    mVisibilityTracker.startVisibilityCheck(getContext());
}
Also used : CreativeVisibilityTracker(org.prebid.mobile.rendering.models.CreativeVisibilityTracker) VisibilityTrackerOption(org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption)

Example 10 with VisibilityTrackerOption

use of org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption in project prebid-mobile-android by prebid.

the class BannerView method initBidLoader.

private void initBidLoader() {
    mBidLoader = new BidLoader(getContext(), mAdUnitConfig, mBidRequesterListener);
    final VisibilityTrackerOption visibilityTrackerOption = new VisibilityTrackerOption(NativeEventTracker.EventType.IMPRESSION);
    final VisibilityChecker visibilityChecker = new VisibilityChecker(visibilityTrackerOption);
    mBidLoader.setBidRefreshListener(() -> {
        if (mAdFailed) {
            mAdFailed = false;
            return true;
        }
        final boolean isWindowVisibleToUser = mScreenStateReceiver.isScreenOn();
        return visibilityChecker.isVisibleForRefresh(this) && isWindowVisibleToUser;
    });
}
Also used : VisibilityChecker(org.prebid.mobile.rendering.utils.helpers.VisibilityChecker) BidLoader(org.prebid.mobile.rendering.bidding.loader.BidLoader) VisibilityTrackerOption(org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption)

Aggregations

VisibilityTrackerOption (org.prebid.mobile.rendering.models.internal.VisibilityTrackerOption)12 Test (org.junit.Test)5 VisibilityChecker (org.prebid.mobile.rendering.utils.helpers.VisibilityChecker)5 View (android.view.View)4 VisibilityTrackerResult (org.prebid.mobile.rendering.models.internal.VisibilityTrackerResult)4 ViewExposure (org.prebid.mobile.rendering.utils.exposure.ViewExposure)3 Rect (android.graphics.Rect)2 CreativeVisibilityTracker (org.prebid.mobile.rendering.models.CreativeVisibilityTracker)2 AdView (com.google.android.gms.ads.AdView)1 MoPubView (com.mopub.mobileads.MoPubView)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 BidLoader (org.prebid.mobile.rendering.bidding.loader.BidLoader)1