Thanks for the Jar - I'll have to try it out.
Here's what I got going yesterday with the Inmobi 2 SDK, but the ads
look wrong (2 different background colors & icon sits under text) when
they finally do
show up (it was giving me admob and others most of the time eventhough
I had it set to 100% inMobi with no backfill.. gotta be a server-side
issue on that..)
Dont know how to post attachments here yet, but maybe this'll be
helpful to someone out there
-------------
package com.adwhirl.adapters;
import java.util.Date;
import android.app.Activity;
import android.location.Location;
import android.text.TextUtils;
import android.util.Log;
import com.adwhirl.AdWhirlLayout;
import com.adwhirl.AdWhirlTargeting;
import com.adwhirl.AdWhirlLayout.ViewAdRunnable;
import com.adwhirl.obj.Ration;
import com.adwhirl.util.AdWhirlUtil;
import com.inmobi.androidsdk.EducationType;
import com.inmobi.androidsdk.EthnicityType;
import com.inmobi.androidsdk.GenderType;
import com.inmobi.androidsdk.InMobiAdDelegate;
import com.inmobi.androidsdk.impl.InMobiAdView;
public class InMobiAdapter extends AdWhirlAdapter implements
InMobiAdDelegate{
public InMobiAdapter(AdWhirlLayout adWhirlLayout, Ration ration) {
super(adWhirlLayout, ration);
}
@Override
public void handle() {
AdWhirlLayout adWhirlLayout = adWhirlLayoutReference.get();
if (adWhirlLayout == null) {
return;
}
try {
Activity activity = adWhirlLayout.activityReference.get();
if (activity == null) {
return;
}
InMobiAdView adView =
InMobiAdView.requestAdUnitWithDelegate((Activity)
adWhirlLayout.getContext(),this,activity,
InMobiAdDelegate.INMOBI_AD_UNIT_320X48);
adView.loadNewAd();
} catch (Exception e) {
Log.d(AdWhirlUtil.ADWHIRL, "InMobi failed to create");
e.printStackTrace();
Log.e("InMobi" , e.getMessage());
adWhirlLayout.rollover();
}
}
public void adRequestCompleted(InMobiAdView adView) {
Log.d(AdWhirlUtil.ADWHIRL, "InMobi success");
AdWhirlLayout adWhirlLayout = adWhirlLayoutReference.get();
if (adWhirlLayout == null) {
return;
}
adWhirlLayout.adWhirlManager.resetRollover();
adWhirlLayout.handler.post(new ViewAdRunnable(adWhirlLayout,
adView));
adWhirlLayout.rotateThreadedDelayed();
}
public void adRequestFailed(InMobiAdView adView) {
Log.d(AdWhirlUtil.ADWHIRL, "InMobi failure");
adView.stopReceivingNotifications();
AdWhirlLayout adWhirlLayout = adWhirlLayoutReference.get();
if (adWhirlLayout == null) {
return;
}
adWhirlLayout.rollover();
}
public int age() {
return AdWhirlTargeting.getAge();
}
public String areaCode() {
return null;
}
public Location currentLocation() {
return null;
}
public Date dateOfBirth() {
return null;
}
public EducationType education() {
return EducationType.Edu_None;
}
public EthnicityType ethnicity() {
return EthnicityType.Eth_None;
}
public GenderType gender() {
final AdWhirlTargeting.Gender gender = AdWhirlTargeting.getGender();
if (gender == AdWhirlTargeting.Gender.MALE) {
return GenderType.G_M;
} else if (gender == AdWhirlTargeting.Gender.FEMALE) {
return GenderType.G_F;
} else {
return GenderType.G_None;
}
}
public int income() {
return -1;
}
public String interests() {
return null;
}
public boolean isLocationInquiryAllowed() {
return false;
}
public boolean isPublisherProvidingLocation() {
return false;
}
public String keywords() {
final String keywords = AdWhirlTargeting.getKeywordSet() != null ?
TextUtils
.join(",", AdWhirlTargeting.getKeywordSet())
: AdWhirlTargeting.getKeywords();
return keywords;
}
public String postalCode() {
return AdWhirlTargeting.getPostalCode();
}
public String searchString() {
return null;
}
public String siteId() {
return ration.key;
}
public boolean testMode() {
return AdWhirlTargeting.getTestMode();
}
}