/** * Set the auto-refresh interval. This is the interval, in * milliseconds, at which the BannerAdView will request new ads, * if auto-refresh is enabled. The default period is 30 seconds; * the minimum is 15. You can enable or disable auto-refresh * using the setAutoRefresh method. * * @param period The auto-refresh interval, in milliseconds. */ public void setAutoRefreshInterval(int period) { if (period > 0) { this.period = Math.max(Settings.MIN_REFRESH_MILLISECONDS, period); } else { this.period = period; } Clog.d(Clog.publicFunctionsLogTag, Clog.getString(R.string.set_period, this.period)); if (mAdFetcher != null) mAdFetcher.setPeriod(this.period); }
@Test public void testSetPeriod() { int period = 30000; adFetcher.setPeriod(period); assertEquals(period, adFetcher.getPeriod()); }
@Override protected void setup(Context context, AttributeSet attrs) { super.setup(context, attrs); mAdFetcher.setPeriod(-1); requestParameters.setMediaType(MediaType.INTERSTITIAL);
public NativeAdRequest(Context context, String placementID) { AdvertisingIDUtil.retrieveAndSetAAID(context); requestParameters = new UTRequestParameters(context); requestParameters.setPlacementID(placementID); requestParameters.setMediaType(MediaType.NATIVE); this.setAllowedSizes(); mAdFetcher = new AdFetcher(this); mAdFetcher.setPeriod(-1); dispatcher = new NativeAdDispatcher(); Clog.setErrorContext(context.getApplicationContext()); }
public NativeAdRequest(Context context, String inventoryCode, int memberID) { AdvertisingIDUtil.retrieveAndSetAAID(context); requestParameters = new UTRequestParameters(context); requestParameters.setInventoryCodeAndMemberID(memberID, inventoryCode); requestParameters.setMediaType(MediaType.NATIVE); this.setAllowedSizes(); mAdFetcher = new AdFetcher(this); mAdFetcher.setPeriod(-1); dispatcher = new NativeAdDispatcher(); Clog.setErrorContext(context.getApplicationContext()); }
@Override protected void setup(Context context, AttributeSet attrs) { period = Settings.DEFAULT_REFRESH; shouldResetContainer = false; expandsToFitScreenWidth = false; resizeToFitContainer = false; measured = false; animator = new Animator(getContext(), TransitionType.NONE, TransitionDirection.UP, 1000); super.setup(context, attrs); onFirstLayout(); requestParameters.setMediaType(MediaType.BANNER); mAdFetcher.setPeriod(period); if (autoRefreshOffInXML) { mAdFetcher.start(); } }
@Test public void testStartWithRefreshOn() { // default state was stopped adFetcher.setPeriod(30000); adFetcher.start(); Lock.pause(1000); // added this so jenkins can have enough time to process // assert 3 here because a AAID async task assertExpectedBGTasksAfterOneAdRequest(2); assertEquals(AdFetcher.STATE.AUTO_REFRESH, adFetcher.getState()); // reset background scheduler, clear tasks for the refresh Lock.pause(30000 + 1000); // We wait for till autorefresh is triggered // in the following method, wait until next ad request is enqueued assertExpectedBGTasksAfterOneAdRequest(3); assertEquals(AdFetcher.STATE.AUTO_REFRESH, adFetcher.getState()); }