鸠摩搜书官方正版 v1.7版本的 MD5 值为:01c9a20d2c415de3233d7f691829edf5
以下内容为反编译后的 SmaatoAdapter.java 源代码,内容仅作参考
package com.admogo.adapters;
import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.webkit.WebView;
import com.admogo.AdMogoLayout;
import com.admogo.obj.Extra;
import com.admogo.obj.Ration;
import com.admogo.util.AdMogoUtil;
import com.madhouse.android.ads.AdView;
import java.io.UnsupportedEncodingException;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.URLEncoder;
import java.util.Enumeration;
import java.util.concurrent.TimeUnit;
public class SmaatoAdapter extends AdMogoAdapter {
private static String APIURL = "http://soma.smaato.net/oapi/reqAd.jsp?adspace=%s&pub=%s&beacon=true&devip=%s&device=%s&dimension=xxlarge&client=client&format=all&response=HTML";
private static final int TIMEOUT_TIME = 30000;
private static WebView webView;
private WebView bannerView;
private double density;
Extra extra;
private double px320;
private double px50;
public SmaatoAdapter(AdMogoLayout adMogoLayout, Ration ration) {
super(adMogoLayout, ration);
webView = new WebView((Context) adMogoLayout.activityReference.get());
}
private static String encodeInfo(String str) {
try {
return URLEncoder.encode(str, "utf-8");
} catch (UnsupportedEncodingException e) {
return str;
}
}
public String getLocalIPAddress() {
try {
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
while (networkInterfaces.hasMoreElements()) {
Enumeration<InetAddress> inetAddresses = networkInterfaces.nextElement().getInetAddresses();
while (inetAddresses.hasMoreElements()) {
InetAddress nextElement = inetAddresses.nextElement();
if (!nextElement.isLoopbackAddress()) {
return nextElement.getHostAddress().toString();
}
}
}
} catch (SocketException e) {
Log.e("Error", e.toString());
}
return "";
}
public static String getUA(Context context) {
return context == null ? "" : encodeInfo(webView.getSettings().getUserAgentString());
}
@Override
public void click() {
AdMogoLayout adMogoLayout = (AdMogoLayout) this.adMogoLayoutReference.get();
if (adMogoLayout == null) {
return;
}
adMogoLayout.countClick();
}
public void displaySmaatoAD(String str) {
Activity activity;
byte b = 0;
AdMogoLayout adMogoLayout = (AdMogoLayout) this.adMogoLayoutReference.get();
if (adMogoLayout == null || (activity = (Activity) adMogoLayout.activityReference.get()) == null) {
return;
}
Log.d(AdMogoUtil.ADMOGO, "Serving Smaato type: banner");
this.bannerView = new WebView(activity);
this.bannerView.getSettings().setJavaScriptEnabled(true);
this.bannerView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
this.bannerView.setHorizontalScrollBarEnabled(false);
this.bannerView.setVerticalScrollBarEnabled(false);
String replace = str.replace("width=\"300\"", "width=\"320\"");
if (replace.contains("<div class=\"celtra-ad-v2\">")) {
adMogoLayout.rollover();
Log.e(AdMogoUtil.ADMOGO, "Smaato request err at html");
} else {
this.bannerView.loadData("<style> *{margin: 0px; padding: 0px;}</style>" + replace, "text/html", "UTF-8");
}
this.bannerView.setScrollBarStyle(33554432);
this.bannerView.setWebViewClient(new aa(this, b));
}
@Override
public void finish() {
Log.d(AdMogoUtil.ADMOGO, "Smaato Finished");
if (webView != null) {
webView.clearView();
}
if (this.bannerView != null) {
this.bannerView.clearView();
}
}
@Override
public void handle() {
AdMogoLayout adMogoLayout = (AdMogoLayout) this.adMogoLayoutReference.get();
if (adMogoLayout == null) {
return;
}
this.density = AdMogoUtil.density;
this.px50 = AdMogoUtil.convertToScreenPixels(50, this.density);
this.px320 = AdMogoUtil.convertToScreenPixels(AdView.PHONE_AD_MEASURE_320, this.density);
this.extra = adMogoLayout.extra;
adMogoLayout.scheduler.schedule(new z(this, this, this.ration), 0L, TimeUnit.SECONDS);
}
}