-
Notifications
You must be signed in to change notification settings - Fork 21
Writing Custom Events
Itamar Nabriski edited this page May 30, 2016
·
4 revisions
You must implement the following interface:
package com.mobfox.sdk.customevents;
import android.content.Context;
import java.util.Map;
public interface CustomEventBanner {
void loadAd(Context context, CustomEventBannerListener listener, String networkID, Map<String, Object> params);
}If the name of the network you are writing the custom event to is XXX your custom event class must be named com.mobfox.sdk.customevents.XXX.
You must also call the methods of the supplied CustomEventBannerListener when appropriate:
package com.mobfox.sdk.customevents;
import android.view.View;
public interface CustomEventBannerListener {
void onBannerError(View banner, Exception e);
void onBannerLoaded(View banner);
void onBannerClosed(View banner);
void onBannerFinished();
void onBannerClicked(View banner);
}package com.mobfox.sdk.customevents;
import android.content.Context;
import android.util.Log;
import com.mopub.mobileads.MoPubErrorCode;
import com.mopub.mobileads.MoPubView;
import java.util.Map;
public class MoPub implements CustomEventBanner {
String tag = "MobFoxAdapter";
public MoPub() {
Log.d(tag, "MobFox AdMob Custom >> constructor");
}
@Override
public void loadAd(Context context, final CustomEventBannerListener listener, String networkID, Map<String, Object> params) {
Log.d(tag, "MobFox AdMob Custom >> loadAd");
MoPubView moPubView = new MoPubView(context);
int width;
int height;
try {
height = (int) params.get("height");
width = (int) params.get("width");
} catch (Exception e) {
Log.e(tag, "MobFox AdMob Custom >> error", e);
listener.onBannerError(null, e);
}
moPubView.setAdUnitId(networkID);
moPubView.setBannerAdListener(new MoPubView.BannerAdListener() {
@Override
public void onBannerLoaded(MoPubView banner) {
Log.d(tag, "MobFox AdMob Custom >> loaded");
listener.onBannerLoaded(banner);
}
@Override
public void onBannerFailed(MoPubView banner, MoPubErrorCode errorCode) {
Log.e(tag, "MobFox AdMob Custom >> error");
listener.onBannerError(banner, new Exception("errorCode: " + errorCode));
}
@Override
public void onBannerClicked(MoPubView banner) {
Log.d(tag, "MobFox AdMob Custom >> clicked");
listener.onBannerClicked(banner);
}
@Override
public void onBannerExpanded(MoPubView banner) {
Log.d(tag, "MobFox AdMob Custom >> expanded");
}
@Override
public void onBannerCollapsed(MoPubView banner) {
Log.d(tag, "MobFox AdMob Custom >> collapsed");
listener.onBannerClosed(banner);
}
});
moPubView.loadAd();
}
}You must implement the following interface:
package com.mobfox.sdk.customevents;
import android.content.Context;
import java.util.Map;
public interface CustomEventInterstitial {
void loadInterstitial(Context context, CustomEventInterstitialListener listener, String networkID, Map<String, Object> params);
void showInterstitial();
}If the name of the network you are writing the custom event to is XXX your custom event class must be named com.mobfox.sdk.customevents.XXXInterstitial.
You must also call the methods of the supplied CustomEventInterstitialListener when appropriate:
package com.mobfox.sdk.customevents;
public interface CustomEventInterstitialListener {
void onInterstitialLoaded(CustomEventInterstitial interstitial);
void onInterstitialFailed(CustomEventInterstitial interstitial, Exception e);
void onInterstitialClosed(CustomEventInterstitial interstitial);
void onInterstitialFinished();
void onInterstitialClicked(CustomEventInterstitial interstitial);
void onInterstitialShown(CustomEventInterstitial interstitial);
}package com.mobfox.sdk.customevents;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import com.mopub.mobileads.MoPubErrorCode;
import java.util.Map;
public class MoPubInterstitial implements CustomEventInterstitial {
String tag = "MobFoxAdapter";
com.mopub.mobileads.MoPubInterstitial mInterstitial;
MoPubInterstitial self;
public MoPubInterstitial() {
Log.d(tag, "MobFox AdMob Custom >> constructor");
}
@Override
public void loadInterstitial(Context context, final CustomEventInterstitialListener listener, String networkID, Map<String, Object> params) {
Log.d(tag, "MobFox AdMob Custom >> loadInterstitial");
self = this;
mInterstitial = new com.mopub.mobileads.MoPubInterstitial((Activity)context, networkID);
mInterstitial.setInterstitialAdListener(new com.mopub.mobileads.MoPubInterstitial.InterstitialAdListener() {
@Override
public void onInterstitialLoaded(com.mopub.mobileads.MoPubInterstitial interstitial) {
Log.d(tag, "MobFox AdMob Custom >> loaded");
listener.onInterstitialLoaded(self);
}
@Override
public void onInterstitialFailed(com.mopub.mobileads.MoPubInterstitial interstitial, MoPubErrorCode errorCode) {
Log.d(tag, "MobFox AdMob Custom >> failed");
listener.onInterstitialFailed(self, new Exception("errorCode: " + errorCode));
}
@Override
public void onInterstitialShown(com.mopub.mobileads.MoPubInterstitial interstitial) {
Log.d(tag, "MobFox AdMob Custom >> shown");
listener.onInterstitialShown(self);
}
@Override
public void onInterstitialClicked(com.mopub.mobileads.MoPubInterstitial interstitial) {
Log.d(tag, "MobFox AdMob Custom >> clicked");
listener.onInterstitialClicked(self);
}
@Override
public void onInterstitialDismissed(com.mopub.mobileads.MoPubInterstitial interstitial) {
Log.d(tag, "MobFox AdMob Custom >> dismissed");
listener.onInterstitialClosed(self);
}
});
mInterstitial.load();
}
@Override
public void showInterstitial() {
if (mInterstitial == null)
return;
mInterstitial.show();
}
}Check: www.nofisa1.com vuyo1959 affiliates EU