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