Search in sources :

Example 1 with MoPubErrorCode

use of com.mopub.mobileads.MoPubErrorCode in project frostwire by frostwire.

the class PreviewPlayerActivity method initMopubView.

private void initMopubView() {
    if (Offers.disabledAds()) {
        hideHorizontalAdContainer();
        return;
    }
    if (!UIUtils.diceRollPassesThreshold(ConfigurationManager.instance(), Constants.PREF_KEY_GUI_MOPUB_PREVIEW_BANNER_THRESHOLD)) {
        return;
    }
    mopubView = findViewById(R.id.activity_preview_player_mopubview);
    advertisementHeaderLayout = findViewById(R.id.activity_preview_advertisement_header_layout);
    fallbackImageView = findView(R.id.activity_preview_fallback_imageview);
    final ImageButton dismissButton = findViewById(R.id.audio_player_dismiss_mopubview_button);
    if (mopubView == null || advertisementHeaderLayout == null || dismissButton == null) {
        return;
    }
    fallbackImageView.setVisibility(View.GONE);
    dismissButton.setOnClickListener(view -> {
        destroyMopubView();
        fallbackImageView.setVisibility(View.GONE);
    });
    mopubView.setTesting(false);
    mopubView.setAutorefreshEnabled(true);
    isVertical = getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
    mopubView.setAdUnitId(isVertical ? "a8be0cad4ad0419dbb19601aef3a18d2" : "2fd0fafe3d3c4d668385a620caaa694e");
    mopubView.setKeywords("music,audio,ringtone,video,music video");
    mopubView.setBannerAdListener(new MoPubView.BannerAdListener() {

        @Override
        public void onBannerLoaded(MoPubView banner) {
            mopubLoaded = true;
            if (!isFullScreen) {
                setViewsVisibility(View.VISIBLE, advertisementHeaderLayout, mopubView);
                fallbackImageView.setVisibility(View.GONE);
                PrebidManager.getInstance(getApplicationContext()).onBannerLoaded(PreviewPlayerActivity.this, banner, isVertical ? PrebidManager.Placement.PREVIEW_BANNER_PORTRAIT_320_50 : PrebidManager.Placement.PREVIEW_BANNER_LANDSCAPE_300_250);
            }
        }

        @Override
        public void onBannerFailed(MoPubView banner, MoPubErrorCode errorCode) {
            PrebidManager.getInstance(getApplicationContext()).onBannerFailed(PreviewPlayerActivity.this, banner, isVertical ? PrebidManager.Placement.PREVIEW_BANNER_PORTRAIT_320_50 : PrebidManager.Placement.PREVIEW_BANNER_LANDSCAPE_300_250, errorCode);
            // mopubLoaded = false, also hides the ad-header view ("advertisement")
            destroyMopubView();
            if (!Offers.disabledAds()) {
                loadFallbackBanner();
            } else {
                hideHorizontalAdContainer();
            }
        }

        @Override
        public void onBannerClicked(MoPubView banner) {
        }

        @Override
        public void onBannerExpanded(MoPubView banner) {
        }

        @Override
        public void onBannerCollapsed(MoPubView banner) {
        }
    });
    try {
        mopubView.loadAd();
    } catch (Throwable e) {
        LOG.warn("AudioPlayer Mopub banner could not be loaded", e);
        mopubLoaded = false;
        loadFallbackBanner();
    }
}
Also used : MoPubErrorCode(com.mopub.mobileads.MoPubErrorCode) ImageButton(android.widget.ImageButton) MoPubView(com.mopub.mobileads.MoPubView)

Example 2 with MoPubErrorCode

use of com.mopub.mobileads.MoPubErrorCode in project mytarget-android by myTargetSDK.

the class MyTargetMopubCustomEventBanner method onNoAd.

@Override
public void onNoAd(@NonNull String reason, @NonNull MyTargetView myTargetView) {
    MoPubLog.log(getAdNetworkId(), CUSTOM, ADAPTER_NAME, "myTarget banner ad failed to load.");
    MoPubErrorCode code = NETWORK_NO_FILL;
    MoPubLog.log(getAdNetworkId(), LOAD_FAILED, ADAPTER_NAME, code.getIntCode(), code);
    InteractionListener interactionListener = mInteractionListener;
    LoadListener loadListener = mLoadListener;
    if (interactionListener == null && loadListener != null) {
        loadListener.onAdLoadFailed(code);
    } else if (interactionListener != null) {
        interactionListener.onAdFailed(code);
    }
}
Also used : MoPubErrorCode(com.mopub.mobileads.MoPubErrorCode) InteractionListener(com.mopub.mobileads.AdLifecycleListener.InteractionListener) LoadListener(com.mopub.mobileads.AdLifecycleListener.LoadListener)

Example 3 with MoPubErrorCode

use of com.mopub.mobileads.MoPubErrorCode 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 4 with MoPubErrorCode

use of com.mopub.mobileads.MoPubErrorCode 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)

Example 5 with MoPubErrorCode

use of com.mopub.mobileads.MoPubErrorCode in project prebid-mobile-android by prebid.

the class RubiconInterstitialVideoMoPubDemoActivity 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_VAST_RUBICON);
    VideoBaseAdUnit.Parameters parameters = new VideoBaseAdUnit.Parameters();
    parameters.setMimes(Arrays.asList("video/mp4"));
    parameters.setProtocols(Arrays.asList(Signals.Protocols.VAST_2_0));
    // parameters.setProtocols(Arrays.asList(new Signals.Protocols(2)));
    parameters.setPlaybackMethod(Arrays.asList(Signals.PlaybackMethod.AutoPlaySoundOff));
    // parameters.setPlaybackMethod(Arrays.asList(new Signals.PlaybackMethod(2)));
    VideoInterstitialAdUnit adUnit = new VideoInterstitialAdUnit("1001-1");
    adUnit.setParameters(parameters);
    this.adUnit = adUnit;
    final MoPubInterstitial mpInterstitial = new MoPubInterstitial(this, Constants.MOPUB_INTERSTITIAL_VIDEO_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(RubiconInterstitialVideoMoPubDemoActivity.this, android.R.style.Theme_Material_Dialog_Alert);
            } else {
                builder = new AlertDialog.Builder(RubiconInterstitialVideoMoPubDemoActivity.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) VideoInterstitialAdUnit(org.prebid.mobile.VideoInterstitialAdUnit) VideoBaseAdUnit(org.prebid.mobile.VideoBaseAdUnit) ResultCode(org.prebid.mobile.ResultCode)

Aggregations

MoPubErrorCode (com.mopub.mobileads.MoPubErrorCode)6 OnCompleteListener (org.prebid.mobile.OnCompleteListener)4 ResultCode (org.prebid.mobile.ResultCode)4 MoPubInterstitial (com.mopub.mobileads.MoPubInterstitial)3 MoPubView (com.mopub.mobileads.MoPubView)2 InterstitialAdUnit (org.prebid.mobile.InterstitialAdUnit)2 FrameLayout (android.widget.FrameLayout)1 ImageButton (android.widget.ImageButton)1 InteractionListener (com.mopub.mobileads.AdLifecycleListener.InteractionListener)1 LoadListener (com.mopub.mobileads.AdLifecycleListener.LoadListener)1 ArrayList (java.util.ArrayList)1 NativeAdUnit (org.prebid.mobile.NativeAdUnit)1 NativeDataAsset (org.prebid.mobile.NativeDataAsset)1 NativeEventTracker (org.prebid.mobile.NativeEventTracker)1 NativeImageAsset (org.prebid.mobile.NativeImageAsset)1 NativeTitleAsset (org.prebid.mobile.NativeTitleAsset)1 VideoBaseAdUnit (org.prebid.mobile.VideoBaseAdUnit)1 VideoInterstitialAdUnit (org.prebid.mobile.VideoInterstitialAdUnit)1