Stick Squad 3 v1.2.5.9版本的 MD5 值为:375cf7f77a7075270cd68d1397368279
以下内容为反编译后的 FuseInterstitial.java 源代码,内容仅作参考
package com.fusepowered.ads.adapters;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.RelativeLayout;
import com.fusepowered.ads.Size;
import java.util.HashMap;
import java.util.Map;
public class FuseInterstitial extends WebViewClient {
private static final String BASE_URL = "http://www.fuseboxx.com";
private static final String ENCODING = "UTF-8";
private static final String MIME_TYPE = "text/html";
public static final int ORIENTATION_ANY = 0;
public static final int ORIENTATION_LANDSCAPE = 2;
public static final int ORIENTATION_PORTRAIT = 1;
private static FuseInterstitial sInstance = null;
private Bundle adExtras;
private Context context;
private Listener listener;
private boolean ready;
private WebView webView;
private final WebViewFactory webViewFactory;
public interface Listener {
void onFuseAdClicked(FuseInterstitial fuseInterstitial);
void onFuseAdClosed(FuseInterstitial fuseInterstitial);
void onFuseAdDisplayed(FuseInterstitial fuseInterstitial);
void onFuseAdError(FuseInterstitial fuseInterstitial);
void onFuseAdReady(FuseInterstitial fuseInterstitial);
}
public static FuseInterstitial getInstance() {
if (sInstance == null) {
sInstance = new FuseInterstitial(new WebViewFactory());
}
return sInstance;
}
public WebView getWebView() {
this.ready = false;
return this.webView;
}
public FuseInterstitial(WebViewFactory factory) throws IllegalArgumentException {
if (factory == null) {
throw new IllegalArgumentException("Factory may not be null");
}
this.webViewFactory = factory;
this.ready = false;
}
public void prepare(int adId, String action, String htmlBody, Size size, int orientation, Context context) {
boolean validAdId = adId > 0;
if (!validAdId) {
throw new IllegalArgumentException("Ad id must not be null or empty");
}
boolean validAction = action != null && action.length() > 0;
if (!validAction) {
throw new IllegalArgumentException("Action must not be null or empty");
}
boolean validHtmlBody = htmlBody != null && htmlBody.length() > 0;
if (!validHtmlBody) {
throw new IllegalArgumentException("Html body must not be null or empty");
}
boolean validSize = size != null;
if (!validSize) {
throw new IllegalArgumentException("Size must not be null");
}
this.ready = false;
this.context = context;
this.webView = this.webViewFactory.createWebView(context);
this.webView.setWebViewClient(this);
this.webView.loadDataWithBaseURL(BASE_URL, htmlBody, MIME_TYPE, "UTF-8", null);
this.adExtras = new Bundle();
this.adExtras.putString("AD_ACTION", action);
this.adExtras.putInt("AD_ID", adId);
this.adExtras.putInt("o", orientation);
this.adExtras.putInt("PH", size.portraitHeight);
this.adExtras.putInt("PW", size.portraitWidth);
this.adExtras.putInt("LH", size.landscapeHeight);
this.adExtras.putInt("LW", size.landscapeWidth);
}
public boolean isReady() {
return this.ready;
}
@Override
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
this.ready = false;
if (this.listener != null) {
this.listener.onFuseAdError(this);
}
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
if (!url.equals("about:blank") && !this.ready) {
this.ready = true;
if (this.listener != null) {
this.listener.onFuseAdReady(this);
}
}
}
public void setListener(Listener listener) {
this.listener = listener;
}
public boolean displayAd() {
if (!isReady()) {
return false;
}
Intent intent = new Intent(this.context, (Class<?>) FuseInterstitialActivity.class);
intent.putExtras(this.adExtras);
this.context.startActivity(intent);
return true;
}
public Bundle getAdExtras() {
return this.adExtras;
}
public void onAdClicked() {
if (this.listener != null) {
this.listener.onFuseAdClicked(this);
}
}
public void onAdClosed() {
if (this.listener != null) {
this.listener.onFuseAdClosed(this);
}
}
public void onAdDisplayed() {
if (this.listener != null) {
this.listener.onFuseAdDisplayed(this);
}
}
public static class WebViewFactory {
@SuppressLint({"NewApi"})
public WebView createWebView(Context context) {
WebView webView = new WebView(context);
Map<String, String> extraHeaders = new HashMap<>();
extraHeaders.put("Referer", "about:blank");
webView.loadUrl("about:blank", extraHeaders);
webView.setBackgroundColor(0);
webView.setId(1);
WebSettings settings = webView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setUseWideViewPort(true);
settings.setSupportZoom(false);
settings.setLoadWithOverviewMode(true);
webView.setWebChromeClient(new WebChromeClient());
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(-1, -1);
layoutParams.addRule(13);
webView.setLayoutParams(layoutParams);
webView.setHorizontalFadingEdgeEnabled(false);
webView.setVerticalFadingEdgeEnabled(false);
webView.setHorizontalScrollBarEnabled(false);
webView.setVerticalScrollBarEnabled(false);
if (Build.VERSION.SDK_INT == 14 || Build.VERSION.SDK_INT == 15) {
webView.setLayerType(1, null);
}
return webView;
}
}
}