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());
}
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);
}
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());
}
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());
}
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;
});
}
Aggregations