use of org.prebid.mobile.rendering.utils.helpers.VisibilityChecker in project prebid-mobile-android by prebid.
the class AdMobBannerMediationUtils method canPerformRefresh.
@Override
public boolean canPerformRefresh() {
AdView view = adView.get();
if (view == null) {
LogUtil.e(TAG, "AdView is null, it can be destroyed as WeakReference");
return false;
}
final VisibilityTrackerOption visibilityTrackerOption = new VisibilityTrackerOption(NativeEventTracker.EventType.IMPRESSION);
final VisibilityChecker checker = new VisibilityChecker(visibilityTrackerOption);
boolean isVisible = checker.isVisibleForRefresh(view);
if (isVisible) {
Log.d(TAG, "Visibility checker result: " + true);
} else {
Log.e(TAG, "Can't perform refresh. Ad view is not visible.");
}
return isVisible;
}
use of org.prebid.mobile.rendering.utils.helpers.VisibilityChecker in project prebid-mobile-android by prebid.
the class MoPubBannerMediationUtils method canPerformRefresh.
@Override
public boolean canPerformRefresh() {
MoPubView adView = adViewReference.get();
if (isAdViewNull(adView)) {
return false;
}
final VisibilityTrackerOption visibilityTrackerOption = new VisibilityTrackerOption(NativeEventTracker.EventType.IMPRESSION);
final VisibilityChecker checker = new VisibilityChecker(visibilityTrackerOption);
boolean isVisible = checker.isVisibleForRefresh(adView);
if (isVisible) {
Log.d(TAG, "Visibility checker result: " + true);
} else {
Log.e(TAG, "Can't perform refresh. Ad view is not visible.");
}
return isVisible;
}
use of org.prebid.mobile.rendering.utils.helpers.VisibilityChecker 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.utils.helpers.VisibilityChecker 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.utils.helpers.VisibilityChecker 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