Search in sources :

Example 6 with InterstitialAdUnit

use of org.prebid.mobile.InterstitialAdUnit in project prebid-mobile-android by prebid.

the class SdkTest method setupPrebid.

private void setupPrebid() {
    GeneralSettings generalSettings = SettingsManager.getInstance(mContext).getGeneralSettings();
    PrebidServerSettings prebidServerSettings = SettingsManager.getInstance(mContext).getPrebidServerSettings();
    setPrebidTargetingParams();
    if (generalSettings.getAdFormat() == AdFormat.BANNER) {
        AdSize adSize = generalSettings.getAdSize();
        mAdUnit = new BannerAdUnit(prebidServerSettings.getConfigId(), adSize.getWidth(), adSize.getHeight());
    } else if (generalSettings.getAdFormat() == AdFormat.INTERSTITIAL) {
        mAdUnit = new InterstitialAdUnit(prebidServerSettings.getConfigId());
    }
    PrebidMobile.setPrebidServerAccountId(prebidServerSettings.getAccountId());
    switch(prebidServerSettings.getPrebidServer()) {
        case APPNEXUS:
            PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
            break;
        case RUBICON:
            PrebidMobile.setPrebidServerHost(Host.RUBICON);
            break;
        case CUSTOM:
            PrebidMobile.setPrebidServerHost(Host.CUSTOM);
            Host.CUSTOM.setHostUrl(buildCustomServerEndpoint(prebidServerSettings.getCustomPrebidServerUrl()));
            break;
    }
    if (mListener != null) {
        mListener.onAdUnitRegistered();
    }
}
Also used : PrebidServerSettings(org.prebid.mobile.drprebid.model.PrebidServerSettings) AdSize(org.prebid.mobile.drprebid.model.AdSize) GeneralSettings(org.prebid.mobile.drprebid.model.GeneralSettings) BannerAdUnit(org.prebid.mobile.BannerAdUnit) InterstitialAdUnit(org.prebid.mobile.InterstitialAdUnit)

Example 7 with InterstitialAdUnit

use of org.prebid.mobile.InterstitialAdUnit in project prebid-mobile-android by prebid.

the class XandrInterstitialMoPubDemoActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    PrebidMobile.setPrebidServerHost(Host.APPNEXUS);
    PrebidMobile.setPrebidServerAccountId(Constants.PBS_ACCOUNT_ID_APPNEXUS);
    adUnit = new InterstitialAdUnit(Constants.PBS_CONFIG_ID_INTERSTITIAL_APPNEXUS);
    final MoPubInterstitial mpInterstitial = new MoPubInterstitial(this, Constants.MOPUB_INTERSTITIAL_ADUNIT_ID_APPNEXUS);
    mpInterstitial.setInterstitialAdListener(new MoPubInterstitial.InterstitialAdListener() {

        @Override
        public void onInterstitialLoaded(MoPubInterstitial interstitial) {
            interstitial.show();
        }

        @Override
        public void onInterstitialFailed(MoPubInterstitial interstitial, MoPubErrorCode errorCode) {
            AlertDialog.Builder builder;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                builder = new AlertDialog.Builder(XandrInterstitialMoPubDemoActivity.this, android.R.style.Theme_Material_Dialog_Alert);
            } else {
                builder = new AlertDialog.Builder(XandrInterstitialMoPubDemoActivity.this);
            }
            builder.setTitle("Failed to load MoPub interstitial ad").setMessage("Error code: " + errorCode.toString()).setIcon(android.R.drawable.ic_dialog_alert).show();
        }

        @Override
        public void onInterstitialShown(MoPubInterstitial interstitial) {
        }

        @Override
        public void onInterstitialClicked(MoPubInterstitial interstitial) {
        }

        @Override
        public void onInterstitialDismissed(MoPubInterstitial interstitial) {
        }
    });
    int millis = getIntent().getIntExtra(Constants.AUTO_REFRESH_NAME, 0);
    adUnit.setAutoRefreshPeriodMillis(millis);
    adUnit.fetchDemand(mpInterstitial, new OnCompleteListener() {

        @Override
        public void onComplete(ResultCode resultCode) {
            mpInterstitial.load();
        }
    });
}
Also used : MoPubErrorCode(com.mopub.mobileads.MoPubErrorCode) OnCompleteListener(org.prebid.mobile.OnCompleteListener) MoPubInterstitial(com.mopub.mobileads.MoPubInterstitial) ResultCode(org.prebid.mobile.ResultCode) InterstitialAdUnit(org.prebid.mobile.InterstitialAdUnit)

Example 8 with InterstitialAdUnit

use of org.prebid.mobile.InterstitialAdUnit in project prebid-mobile-android by prebid.

the class RubiconInterstitialMoPubDemoActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_demo);
    PrebidMobile.setPrebidServerHost(Host.RUBICON);
    PrebidMobile.setPrebidServerAccountId(Constants.PBS_ACCOUNT_ID_RUBICON);
    PrebidMobile.setStoredAuctionResponse(Constants.PBS_STORED_RESPONSE_300x250_RUBICON);
    adUnit = new InterstitialAdUnit(Constants.PBS_CONFIG_ID_INTERSTITIAL_RUBICON);
    final MoPubInterstitial mpInterstitial = new MoPubInterstitial(this, Constants.MOPUB_INTERSTITIAL_ADUNIT_ID_RUBICON);
    mpInterstitial.setInterstitialAdListener(new MoPubInterstitial.InterstitialAdListener() {

        @Override
        public void onInterstitialLoaded(MoPubInterstitial interstitial) {
            interstitial.show();
        }

        @Override
        public void onInterstitialFailed(MoPubInterstitial interstitial, MoPubErrorCode errorCode) {
            AlertDialog.Builder builder;
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                builder = new AlertDialog.Builder(RubiconInterstitialMoPubDemoActivity.this, android.R.style.Theme_Material_Dialog_Alert);
            } else {
                builder = new AlertDialog.Builder(RubiconInterstitialMoPubDemoActivity.this);
            }
            builder.setTitle("Failed to load MoPub interstitial ad").setMessage("Error code: " + errorCode.toString()).setIcon(android.R.drawable.ic_dialog_alert).show();
        }

        @Override
        public void onInterstitialShown(MoPubInterstitial interstitial) {
        }

        @Override
        public void onInterstitialClicked(MoPubInterstitial interstitial) {
        }

        @Override
        public void onInterstitialDismissed(MoPubInterstitial interstitial) {
        }
    });
    int millis = getIntent().getIntExtra(Constants.AUTO_REFRESH_NAME, 0);
    adUnit.setAutoRefreshPeriodMillis(millis);
    adUnit.fetchDemand(mpInterstitial, new OnCompleteListener() {

        @Override
        public void onComplete(ResultCode resultCode) {
            mpInterstitial.load();
            refreshCount++;
            RubiconInterstitialMoPubDemoActivity.this.resultCode = resultCode;
        }
    });
}
Also used : MoPubErrorCode(com.mopub.mobileads.MoPubErrorCode) OnCompleteListener(org.prebid.mobile.OnCompleteListener) MoPubInterstitial(com.mopub.mobileads.MoPubInterstitial) ResultCode(org.prebid.mobile.ResultCode) InterstitialAdUnit(org.prebid.mobile.InterstitialAdUnit)

Aggregations

InterstitialAdUnit (org.prebid.mobile.InterstitialAdUnit)8 OnCompleteListener (org.prebid.mobile.OnCompleteListener)5 ResultCode (org.prebid.mobile.ResultCode)5 MoPubInterstitial (com.mopub.mobileads.MoPubInterstitial)3 AdUnit (org.prebid.mobile.AdUnit)3 BannerAdUnit (org.prebid.mobile.BannerAdUnit)3 AdSize (org.prebid.mobile.drprebid.model.AdSize)3 NonNull (androidx.annotation.NonNull)2 AlertDialog (androidx.appcompat.app.AlertDialog)2 LoadAdError (com.google.android.gms.ads.LoadAdError)2 AdManagerAdRequest (com.google.android.gms.ads.admanager.AdManagerAdRequest)2 AdManagerInterstitialAd (com.google.android.gms.ads.admanager.AdManagerInterstitialAd)2 AdManagerInterstitialAdLoadCallback (com.google.android.gms.ads.admanager.AdManagerInterstitialAdLoadCallback)2 MoPubErrorCode (com.mopub.mobileads.MoPubErrorCode)2 GeneralSettings (org.prebid.mobile.drprebid.model.GeneralSettings)2 PrebidServerSettings (org.prebid.mobile.drprebid.model.PrebidServerSettings)2 Point (android.graphics.Point)1 Display (android.view.Display)1 FrameLayout (android.widget.FrameLayout)1 MoPubView (com.mopub.mobileads.MoPubView)1