use of com.my.target.ads.InterstitialAd in project mytarget-android by myTargetSDK.
the class InterstitialAdActivity method reloadAd.
@Override
void reloadAd() {
for (InterstitialAd interstitialAd : interstitialAds) {
interstitialAd.setListener(null);
}
interstitialAds.clear();
typeList.clear();
adapter.notifyDataSetChanged();
initAds();
}
use of com.my.target.ads.InterstitialAd in project mytarget-android by myTargetSDK.
the class InterstitialAdActivity method initAds.
private void initAds() {
typeList = new ArrayList<>();
AdvertisingType promoAd = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, DefaultSlots.SLOT_PROMO_AD);
promoAd.setName(getResources().getString(R.string.interstitial_promo));
promoAd.setImageResource(R.drawable.img_fullscreen_promo);
promoAd.setDescription(getString(R.string.interstitial_promo_desc));
InterstitialAd interstitialAd = new InterstitialAd(DefaultSlots.SLOT_PROMO_AD, this);
Tools.fillCustomParamsUserData(interstitialAd.getCustomParams());
interstitialAds.add(PROMO_AD, interstitialAd);
AdvertisingType videoAd = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, DefaultSlots.SLOT_PROMO_VIDEO_AD);
videoAd.setName(getResources().getString(R.string.interstitial_video));
videoAd.setImageResource(R.drawable.img_fullscreen_video);
videoAd.setDescription(getString(R.string.interstitial_video_desc));
InterstitialAd interstitialVideoAd = new InterstitialAd(DefaultSlots.SLOT_PROMO_VIDEO_AD, this);
Tools.fillCustomParamsUserData(interstitialVideoAd.getCustomParams());
interstitialAds.add(VIDEO_AD, interstitialVideoAd);
AdvertisingType imageAd = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, DefaultSlots.SLOT_IMAGE_AD);
imageAd.setName(getResources().getString(R.string.interstitial_image));
imageAd.setImageResource(R.drawable.img_fullscreen_image);
imageAd.setDescription(getString(R.string.interstitial_image_desc));
InterstitialAd interstitialImageAd = new InterstitialAd(DefaultSlots.SLOT_IMAGE_AD, this);
Tools.fillCustomParamsUserData(interstitialImageAd.getCustomParams());
interstitialAds.add(IMAGE_AD, interstitialImageAd);
AdvertisingType videoStyleAd = new AdvertisingType(AdTypes.AD_TYPE_NATIVE, DefaultSlots.SLOT_PROMO_VIDEO_STYLE_AD);
videoStyleAd.setName(getResources().getString(R.string.interstitial_video_style));
videoStyleAd.setImageResource(R.drawable.img_fullscreen_promo_style);
videoStyleAd.setDescription(getString(R.string.interstitial_video_style_desc));
InterstitialAd interstitialVideoStyleAd = new InterstitialAd(DefaultSlots.SLOT_PROMO_VIDEO_STYLE_AD, this);
Tools.fillCustomParamsUserData(interstitialVideoStyleAd.getCustomParams());
interstitialAds.add(VIDEO_AD_STYLE, interstitialVideoStyleAd);
typeList.add(PROMO_AD, promoAd);
typeList.add(VIDEO_AD, videoAd);
typeList.add(IMAGE_AD, imageAd);
typeList.add(VIDEO_AD_STYLE, videoStyleAd);
adapter = new InterstitialListAdapter(typeList);
GridLayoutManager gridLayoutManager = new GridLayoutManager(getApplicationContext(), getResources().getInteger(R.integer.grid_coloumns));
recyclerView.setLayoutManager(gridLayoutManager);
recyclerView.setAdapter(adapter);
for (InterstitialAd ad : interstitialAds) {
ad.setListener(adListener);
ad.load();
}
}
use of com.my.target.ads.InterstitialAd in project mytarget-android by myTargetSDK.
the class MyTargetMopubCustomEventInterstitial method loadInterstitial.
@Override
protected void loadInterstitial(Context context, CustomEventInterstitialListener customEventInterstitialListener, Map<String, Object> stringObjectMap, Map<String, String> stringStringMap) {
this.mopubInterstitialListener = customEventInterstitialListener;
Log.d(TAG, "Loading mopub mediation interstitial");
if (context == null) {
return;
}
int slotId;
if (stringStringMap != null && (stringStringMap.size() == 0 || !stringStringMap.containsKey(SLOT_ID_KEY))) {
Log.d(TAG, "Unable to get slotId from parameter json. Probably MoPub mediation misconfiguration.");
if (customEventInterstitialListener != null) {
customEventInterstitialListener.onInterstitialFailed(MoPubErrorCode.UNSPECIFIED);
}
return;
}
if (stringStringMap != null) {
slotId = Integer.parseInt(stringStringMap.get(SLOT_ID_KEY));
} else {
Log.d(TAG, "Unable to get myTarget slotId");
return;
}
ad = new InterstitialAd(slotId, context);
if (stringObjectMap != null) {
MopubCustomParamsUtils.fillCustomParams(ad.getCustomParams(), stringObjectMap);
}
ad.setListener(new MyTargetInterstitialAdListener());
ad.load();
}
use of com.my.target.ads.InterstitialAd in project mytarget-android by myTargetSDK.
the class MyTargetMopubCustomEventInterstitial method load.
@Override
protected void load(@NonNull final Context context, @NonNull final AdData adData) {
setAutomaticImpressionAndClickTracking(false);
final Map<String, String> extras = adData.getExtras();
String sslotId = extras.get(MyTargetAdapterConfiguration.SLOT_ID_KEY);
int slotId = MyTargetAdapterUtils.parseSlot(sslotId);
if (slotId < 0) {
LoadListener loadListener = mLoadListener;
if (loadListener != null) {
loadListener.onAdLoadFailed(MoPubErrorCode.NETWORK_NO_FILL);
MoPubLog.log(getAdNetworkId(), LOAD_FAILED, ADAPTER_NAME, MoPubErrorCode.NETWORK_NO_FILL.getIntCode(), MoPubErrorCode.NETWORK_NO_FILL);
}
return;
}
adNetworkId = sslotId != null ? sslotId : "";
MyTargetAdapterUtils.handleConsent();
interstitialAd = new InterstitialAd(slotId, context);
final String adMarkup = extras.get(DataKeys.ADM_KEY);
MopubCustomParamsUtils.fillCustomParams(interstitialAd.getCustomParams(), extras);
interstitialAd.setListener(this);
if (adMarkup == null || adMarkup.length() == 0) {
interstitialAd.load();
} else {
interstitialAd.loadFromBid(adMarkup);
}
MoPubLog.log(getAdNetworkId(), LOAD_ATTEMPTED, ADAPTER_NAME);
}
use of com.my.target.ads.InterstitialAd in project mytarget-android by myTargetSDK.
the class MainActivity method loadAndShowCustomInterstitial.
private void loadAndShowCustomInterstitial(final AdvertisingType advertisingType) {
if (loadingView != null) {
loadingView.setVisibility(View.VISIBLE);
}
final InterstitialAd interstitialAd = new InterstitialAd(advertisingType.getSlotId(), this);
Tools.fillCustomParamsUserData(interstitialAd.getCustomParams());
interstitialAd.setListener(new InterstitialAdListener() {
@Override
public void onLoad(final InterstitialAd ad) {
if (loadingView != null) {
loadingView.setVisibility(View.GONE);
}
interstitialAd.show();
}
@Override
public void onNoAd(final String s, final InterstitialAd ad) {
if (loadingView != null) {
loadingView.setVisibility(View.GONE);
}
Snackbar.make(recyclerView, getString(R.string.no_ad), Snackbar.LENGTH_LONG).show();
}
@Override
public void onClick(final InterstitialAd ad) {
}
@Override
public void onDismiss(final InterstitialAd ad) {
}
@Override
public void onVideoCompleted(final InterstitialAd ad) {
}
@Override
public void onDisplay(final InterstitialAd ad) {
}
});
interstitialAd.load();
}
Aggregations