卡特世界 v1.0.8版本的 MD5 值为:003518196b64b6d0c6e5f7f4996f7146
以下内容为反编译后的 AdWebView.java 源代码,内容仅作参考
package com.beizi.ad.internal.view;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.MutableContextWrapper;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.net.Uri;
import android.net.http.SslError;
import android.os.Build;
import android.os.Handler;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Pair;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.webkit.CookieManager;
import android.webkit.SslErrorHandler;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.FrameLayout;
import android.widget.Toast;
import com.beizi.ad.AdActivity;
import com.beizi.ad.R;
import com.beizi.ad.a.a.k;
import com.beizi.ad.c.e;
import com.beizi.ad.internal.j;
import com.beizi.ad.internal.l;
import com.beizi.ad.internal.network.ServerResponse;
import com.beizi.ad.internal.utilities.HTTPGet;
import com.beizi.ad.internal.utilities.HTTPResponse;
import com.beizi.ad.internal.utilities.HaoboLog;
import com.beizi.ad.internal.utilities.SPUtils;
import com.beizi.ad.internal.utilities.StringUtil;
import com.beizi.ad.internal.utilities.ViewUtil;
import com.beizi.ad.internal.utilities.WebviewUtil;
import com.beizi.ad.internal.video.AdVideoView;
import com.beizi.ad.internal.view.AdViewImpl;
import com.beizi.ad.internal.view.f;
import com.bumptech.glide.load.Key;
import com.bytedance.sdk.openadsdk.downloadnew.core.TTDownloadField;
import com.czhj.sdk.common.Constants;
import com.ss.android.socialbase.downloader.utils.DownloadExpSwitchCode;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
public class AdWebView extends WebView implements com.beizi.ad.internal.view.c {
private boolean A;
private boolean B;
private boolean C;
private boolean D;
private int E;
private long F;
private float G;
private float H;
private boolean I;
private HttpURLConnection J;
private InputStream K;
private final Runnable L;
boolean a;
public ServerResponse ad;
public AdViewImpl adViewImpl;
protected String b;
boolean c;
private boolean d;
private boolean e;
private f f;
private int g;
public GestureDetector gestureDetector;
private int h;
private boolean i;
private int j;
private int k;
private int l;
private int m;
public AdVideoView mAdVideoView;
private int n;
private boolean o;
private boolean p;
private Handler q;
private boolean r;
private int s;
private ProgressDialog t;
private boolean u;
private boolean v;
private int w;
private int x;
private int y;
private boolean z;
public interface b {
void a();
}
@Override
public View getView() {
return this;
}
public AdWebView(AdViewImpl adViewImpl) {
super(new MutableContextWrapper(adViewImpl.getContext()));
this.d = false;
this.ad = null;
this.mAdVideoView = null;
this.a = false;
this.o = false;
this.p = false;
this.q = new Handler();
this.r = false;
this.u = false;
this.v = false;
this.y = -1;
this.z = false;
this.A = false;
this.B = false;
this.C = false;
this.D = false;
this.E = 0;
this.c = false;
this.J = null;
this.K = null;
this.L = new Runnable() {
@Override
public void run() {
if (AdWebView.this.r) {
return;
}
AdWebView.this.f();
AdWebView.this.q.postDelayed(this, 1000L);
}
};
setBackgroundColor(0);
this.adViewImpl = adViewImpl;
this.b = f.a[f.b.STARTING_DEFAULT.ordinal()];
a();
b();
setVisibility(4);
}
protected void a() {
try {
String userAgentString = getSettings().getUserAgentString();
if (!TextUtils.isEmpty(userAgentString) && !userAgentString.equals(com.beizi.ad.internal.g.a().d)) {
SPUtils.put(getContext(), TTDownloadField.TT_USERAGENT, userAgentString);
}
com.beizi.ad.internal.g.a().d = userAgentString;
getSettings().setJavaScriptEnabled(true);
getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
getSettings().setBuiltInZoomControls(false);
getSettings().setEnableSmoothTransition(true);
getSettings().setLightTouchEnabled(false);
getSettings().setPluginState(WebSettings.PluginState.ON);
getSettings().setLoadsImagesAutomatically(true);
getSettings().setSavePassword(false);
getSettings().setSupportZoom(false);
getSettings().setUseWideViewPort(false);
if (Build.VERSION.SDK_INT >= 17) {
getSettings().setMediaPlaybackRequiresUserGesture(false);
}
if (Build.VERSION.SDK_INT >= 21) {
getSettings().setMixedContentMode(0);
}
if (Build.VERSION.SDK_INT >= 19) {
WebView.setWebContentsDebuggingEnabled(false);
}
if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT < 19) {
removeJavascriptInterface("searchBoxJavaBridge_");
removeJavascriptInterface("accessibility");
removeJavascriptInterface("accessibilityTraversal");
}
getSettings().setAllowFileAccess(false);
getSettings().setAllowContentAccess(false);
if (Build.VERSION.SDK_INT >= 16) {
getSettings().setAllowFileAccessFromFileURLs(false);
getSettings().setAllowUniversalAccessFromFileURLs(false);
}
if (Build.VERSION.SDK_INT >= 21) {
CookieManager cookieManager = CookieManager.getInstance();
if (cookieManager != null) {
cookieManager.setAcceptThirdPartyCookies(this, true);
} else {
HaoboLog.d(HaoboLog.baseLogTag, "Failed to set Webview to accept 3rd party cookie");
}
}
setHorizontalScrollbarOverlay(false);
setHorizontalScrollBarEnabled(false);
setVerticalScrollbarOverlay(false);
setVerticalScrollBarEnabled(false);
if (this.B) {
setBackgroundColor(0);
}
setScrollBarStyle(0);
} catch (Throwable th) {
th.printStackTrace();
}
}
protected void b() {
this.f = new f(this);
setWebChromeClient(new h(this));
setWebViewClient(new a());
}
public HashMap<String, Object> getAdExtras() {
ServerResponse serverResponse = this.ad;
if (serverResponse == null) {
return null;
}
return serverResponse.getExtras();
}
public com.beizi.ad.internal.view.c getRealDisplayable() {
AdVideoView adVideoView;
return (!this.C || (adVideoView = this.mAdVideoView) == null) ? this : adVideoView;
}
public void loadAd(ServerResponse serverResponse) {
int i;
if (serverResponse == null) {
return;
}
this.ad = serverResponse;
setCreativeHeight(serverResponse.getHeight());
setCreativeWidth(serverResponse.getWidth());
setCreativeLeft(serverResponse.getLeft());
setCreativeTop(serverResponse.getTop());
setRefreshInterval(serverResponse.getRefreshInterval());
if (serverResponse.isManualClose()) {
this.w = serverResponse.getMinTimer();
} else {
this.w = -1;
}
if (serverResponse.isAutoClose() && serverResponse.getMaxTimer() != 0) {
this.x = serverResponse.getMaxTimer();
} else {
this.x = -1;
}
if (this.w == -1 && this.x == -1 && serverResponse.getAdType() != e.a.ADP_IVIDEO) {
this.w = 0;
} else {
int i2 = this.w;
if (i2 != -1 && (i = this.x) != -1 && i2 > i) {
this.w = i;
}
}
this.z = serverResponse.isAutoPlay();
this.A = serverResponse.isMuted();
this.B = serverResponse.isFullScreen();
this.s = serverResponse.getAdOrientation();
this.D = serverResponse.isWifiOnly();
this.y = -1;
setInitialScale((int) ((com.beizi.ad.internal.g.a().j() * 100.0f) + 0.5f));
loadAdAt(0);
}
public boolean shouldDisplayButton() {
if (this.ad.getAdType() == e.a.ADP_BANNER) {
return false;
}
if (this.ad.getAdType() == e.a.ADP_IVIDEO) {
if (this.ad.getCreatives().get(this.y).first != j.VIDEO) {
return false;
}
} else if (this.y != 0) {
return false;
}
return true;
}
public boolean loadAdBy(int i) {
return loadAdAt(this.y + i);
}
public boolean loadAdAt(int i) {
int creativeHeight;
int creativeWidth;
ServerResponse serverResponse = this.ad;
if (serverResponse != null && this.y != i) {
if (serverResponse.getCreatives().isEmpty() || this.ad.getCreatives().size() <= i) {
h();
} else {
Pair<j, String> pair = this.ad.getCreatives().get(i);
if (StringUtil.isEmpty((String) pair.second)) {
h();
return false;
}
if (pair.first == j.VIDEO) {
if (this.mAdVideoView == null) {
this.mAdVideoView = new AdVideoView(this);
}
this.mAdVideoView.transferAd(this, (String) pair.second);
this.C = true;
String a2 = com.beizi.ad.a.a.b.a("aHR0cDovL2Fib3V0OmJsYW5r");
if (!TextUtils.isEmpty(a2)) {
loadUrl(a2, com.beizi.ad.a.a.h.a());
}
} else {
HaoboLog.v(HaoboLog.baseLogTag, HaoboLog.getString(R.string.webview_loading, (String) pair.second));
a(this.ad.getExtras());
String f = f(e(d((String) pair.second)));
float h = com.beizi.ad.internal.g.a().h();
float i2 = com.beizi.ad.internal.g.a().i();
float j = com.beizi.ad.internal.g.a().j();
if (getCreativeWidth() == -1 && getCreativeHeight() == -1) {
creativeWidth = -1;
creativeHeight = -1;
} else {
creativeHeight = (int) ((getCreativeHeight() * j) + 0.5f);
creativeWidth = (int) ((getCreativeWidth() * j) + 0.5f);
}
if (getCreativeLeft() == 0 && getCreativeTop() == 0) {
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(creativeWidth, creativeHeight, 17);
if (this.ad.mMediaType == l.SPLASH) {
setLayoutParams(new FrameLayout.LayoutParams(-1, -1, 17));
} else if (this.ad.mMediaType == l.BANNER) {
a(new FrameLayout.LayoutParams(-2, -1, 17));
} else {
a(layoutParams);
}
} else {
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(creativeWidth, creativeHeight, 8388659);
layoutParams2.setMargins((int) ((getCreativeLeft() * h) + 0.5f), (int) ((getCreativeTop() * i2) + 0.5f), 0, 0);
if (this.ad.mMediaType == l.SPLASH) {
setLayoutParams(new FrameLayout.LayoutParams(-1, -1, 17));
} else {
a(layoutParams2);
}
}
loadDataWithBaseURL(null, f, "text/html", Key.STRING_CHARSET_NAME, null);
this.C = false;
}
this.y = i;
return true;
}
}
return false;
}
private void a(FrameLayout.LayoutParams layoutParams) {
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl instanceof BannerAdViewImpl) {
if (((BannerAdViewImpl) adViewImpl).getResizeAdToFitContainer()) {
setLayoutParams(new FrameLayout.LayoutParams(-1, -1, 17));
return;
} else {
setLayoutParams(layoutParams);
return;
}
}
setLayoutParams(layoutParams);
}
public String d(String str) {
if (StringUtil.isEmpty(str)) {
return str;
}
str.trim();
if (str.startsWith("<html>")) {
return str;
}
return "<html><body style='padding:0;margin:0;'>" + str + "</body></html>";
}
public String e(String str) {
if (StringUtil.isEmpty(str)) {
return str;
}
Resources resources = getResources();
StringBuilder sb = new StringBuilder("<html><head><script>");
if (resources == null || !StringUtil.appendLocalStr(sb, StringUtil.adscopeJSStr) || !StringUtil.appendLocalStr(sb, StringUtil.adscopeStr) || !StringUtil.appendRes(sb)) {
HaoboLog.e(HaoboLog.baseLogTag, "Error reading SDK's raw resources.");
return str;
}
sb.append("</script></head>");
return str.replaceFirst("<html>", Matcher.quoteReplacement(sb.toString()));
}
public String f(String str) {
return !StringUtil.isEmpty(str) ? str.replaceFirst("<head>", Matcher.quoteReplacement(new StringBuilder("<head><meta name=\"viewport\" content=\"width=device-width,initial-scale=1.0,user-scalable=no\"/>").toString())) : str;
}
private void a(HashMap hashMap) {
if (!hashMap.isEmpty() && hashMap.containsKey(ServerResponse.EXTRAS_KEY_MRAID)) {
this.e = ((Boolean) hashMap.get(ServerResponse.EXTRAS_KEY_MRAID)).booleanValue();
}
}
public void a(final String str) {
new HTTPGet(false, true) {
@Override
public void onPostExecute(HTTPResponse hTTPResponse) {
if (hTTPResponse.getSucceeded()) {
AdWebView.this.loadDataWithBaseURL(null, AdWebView.this.f(AdWebView.this.e(AdWebView.this.d(hTTPResponse.getResponseBody()))), "text/html", Key.STRING_CHARSET_NAME, null);
AdWebView.this.fireMRAIDEnabled();
}
}
@Override
protected String getUrl() {
return str;
}
}.execute(new Void[0]);
}
public f getMRAIDImplementation() {
return this.f;
}
private static float a(float f, float f2, float f3, float f4) {
float f5 = f - f3;
float f6 = f2 - f4;
return a((float) Math.sqrt((f5 * f5) + (f6 * f6)));
}
private static float a(float f) {
return f / com.beizi.ad.internal.g.a().k().density;
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
this.v = true;
int action = motionEvent.getAction();
if (action == 0) {
this.F = System.currentTimeMillis();
this.G = motionEvent.getX();
this.H = motionEvent.getY();
this.I = true;
} else if (action == 1) {
long currentTimeMillis = System.currentTimeMillis();
long j = this.F;
if (currentTimeMillis - j < 1000 && this.I) {
handleClickView(motionEvent, j, currentTimeMillis);
}
} else if (action == 2 && this.I && a(this.G, this.H, motionEvent.getX(), motionEvent.getY()) > 15.0f) {
this.I = false;
}
return super.onTouchEvent(motionEvent);
}
public void handleClickView(MotionEvent motionEvent, long j, long j2) {
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl == null || adViewImpl.getAdDispatcher() == null || this.adViewImpl.isRewardedVideo()) {
return;
}
this.E++;
this.adViewImpl.getAdDispatcher().d();
this.ad.setOpenInNativeBrowser(this.adViewImpl.getOpensNativeBrowser());
if (motionEvent == null) {
this.ad.handleClick(this, "100", "200", "105", "206", String.valueOf(j), String.valueOf(j2), this.c, this.adViewImpl.getAdParameters().a());
} else {
this.ad.handleClick(this, motionEvent.getX() + "", motionEvent.getY() + "", motionEvent.getRawX() + "", motionEvent.getRawY() + "", String.valueOf(j), String.valueOf(j2), this.c, this.adViewImpl.getAdParameters().a());
}
this.c = true;
}
public void handleClickView(com.beizi.ad.c.c cVar, long j, long j2, int i) {
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl == null || adViewImpl.getAdDispatcher() == null || this.adViewImpl.isRewardedVideo()) {
return;
}
this.E++;
this.adViewImpl.getAdDispatcher().d();
this.ad.setOpenInNativeBrowser(this.adViewImpl.getOpensNativeBrowser());
this.ad.handleClick(this, cVar, String.valueOf(j), String.valueOf(j2), this.c, this.adViewImpl.getAdParameters().a(), i);
this.c = true;
}
@Override
protected void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
f();
}
public boolean getUserInteraction() {
return this.v;
}
public int getCreativeLeft() {
return this.j;
}
public void setCreativeLeft(int i) {
this.j = i;
}
public int getCreativeTop() {
return this.k;
}
public void setCreativeTop(int i) {
this.k = i;
}
public void setRefreshInterval(int i) {
this.n = i;
}
public int getShowCloseBtnTime() {
return this.w;
}
public int getAutoCloseTime() {
return this.x;
}
public boolean isAutoPlay() {
return this.z;
}
public boolean isMuted() {
return this.A;
}
public boolean isVideoFullScreen() {
return this.B;
}
public class a extends WebViewClient {
private a() {
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
String str2 = HaoboLog.baseLogTag;
HaoboLog.v(str2, "Loading URL: " + str);
k.a("lance", "Loading:::::::::::::::::::::::" + str);
if (str.startsWith("javascript:")) {
return false;
}
if (str.startsWith("mraid://")) {
HaoboLog.v(HaoboLog.mraidLogTag, str);
if (AdWebView.this.e) {
AdWebView.this.f.a(str, AdWebView.this.v);
} else {
String host = Uri.parse(str).getHost();
if (host != null && host.equals("enable")) {
AdWebView.this.fireMRAIDEnabled();
} else if (host != null && host.equals("open")) {
AdWebView.this.f.a(str, AdWebView.this.v);
}
}
return true;
} else if (str.startsWith("BeiZi://")) {
try {
String host2 = Uri.parse(str).getHost();
if (!TextUtils.isEmpty(host2) && !"ClosePage".equals(host2) && AdWebView.this.ad != null && AdWebView.this.adViewImpl != null && AdWebView.this.adViewImpl.getAdParameters() != null) {
AdWebView.this.ad.handleClick(AdWebView.this, "", "", "", "", "", "", AdWebView.this.c, AdWebView.this.adViewImpl.getAdParameters().a());
AdWebView.this.c = true;
}
} catch (Exception e) {
e.printStackTrace();
}
com.beizi.ad.internal.view.b.a(AdWebView.this, str);
return true;
} else {
AdWebView.this.b(str);
AdWebView.this.c();
return true;
}
}
@Override
public void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
if (AdWebView.this.ad.mMediaType == l.SPLASH) {
AdWebView.this.visible();
}
if (AdWebView.this.i) {
return;
}
if (Build.VERSION.SDK_INT >= 19) {
webView.evaluateJavascript("javascript:window.mraid.util.pageFinished()", null);
} else {
webView.loadUrl("javascript:window.mraid.util.pageFinished()");
}
if (AdWebView.this.e) {
f fVar = AdWebView.this.f;
AdWebView adWebView = AdWebView.this;
fVar.a(adWebView, adWebView.b);
AdWebView.this.i();
}
AdWebView.this.i = true;
}
@Override
public void onLoadResource(WebView webView, String str) {
if (str.startsWith(Constants.HTTP)) {
try {
WebView.HitTestResult hitTestResult = AdWebView.this.getHitTestResult();
if (hitTestResult == null || hitTestResult.getExtra() == null) {
return;
}
if (hitTestResult.getExtra().equals(str)) {
int type = hitTestResult.getType();
if (type == 1 || type == 6 || type == 7 || type == 8) {
AdWebView.this.b(str);
webView.stopLoading();
AdWebView.this.c();
}
}
} catch (NullPointerException unused) {
}
}
}
@Override
public void onReceivedError(WebView webView, int i, String str, String str2) {
HaoboLog.w(HaoboLog.httpRespLogTag, HaoboLog.getString(R.string.webview_received_error, i, str, str2));
if (AdWebView.this.adViewImpl == null || AdWebView.this.adViewImpl.getAdDispatcher() == null) {
return;
}
AdWebView.this.adViewImpl.getAdDispatcher().a(2);
}
@Override
public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
AdWebView.this.h();
HaoboLog.w(HaoboLog.httpRespLogTag, HaoboLog.getString(R.string.webclient_error, sslError.getPrimaryError(), sslError.toString()));
if (AdWebView.this.adViewImpl == null || AdWebView.this.adViewImpl.getAdDispatcher() == null) {
return;
}
AdWebView.this.adViewImpl.getAdDispatcher().a(2);
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
return AdWebView.this.a(webResourceRequest);
}
}
public WebResourceResponse a(WebResourceRequest webResourceRequest) {
try {
if (Build.VERSION.SDK_INT < 21) {
return null;
}
Map<String, String> requestHeaders = webResourceRequest.getRequestHeaders();
String str = "*/*";
if (requestHeaders != null && requestHeaders.size() > 0 && requestHeaders.containsKey("Accept")) {
str = requestHeaders.get("Accept");
}
Uri url = webResourceRequest.getUrl();
if (url == null) {
return null;
}
String uri = url.toString();
if (uri.startsWith(Constants.HTTP)) {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(uri).openConnection();
this.J = httpURLConnection;
httpURLConnection.setRequestMethod(webResourceRequest.getMethod());
this.J.setRequestProperty("X-Requested-With", "");
this.J.setRequestProperty("Accept", str);
this.J.setRequestProperty("User-Agent", com.beizi.ad.internal.g.a().d);
this.K = this.J.getInputStream();
return new WebResourceResponse(str, Key.STRING_CHARSET_NAME, this.K);
}
return null;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public void closeWebResourceRequestConnection() {
try {
if (this.K != null) {
this.K.close();
}
if (this.J != null) {
this.J.disconnect();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void c() {
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl != null) {
adViewImpl.f();
}
}
private boolean g(String str) {
Intent intent = new Intent("android.intent.action.VIEW", Uri.parse(str));
intent.setFlags(DownloadExpSwitchCode.BUGFIX_GETPACKAGEINFO_BY_UNZIP);
try {
this.adViewImpl.getContext().startActivity(intent);
return true;
} catch (ActivityNotFoundException unused) {
HaoboLog.w(HaoboLog.baseLogTag, HaoboLog.getString(R.string.opening_url_failed, str));
if (this.e) {
Toast.makeText(this.adViewImpl.getContext(), R.string.action_cant_be_completed, 0).show();
}
return false;
}
}
public boolean h(String str) {
String a2 = com.beizi.ad.a.a.b.a("aHR0cDovL2Fib3V0OmJsYW5r");
if (str.startsWith(Constants.HTTP) || str.startsWith(a2)) {
return false;
}
HaoboLog.i(HaoboLog.baseLogTag, HaoboLog.getString(R.string.opening_app_store));
return g(str);
}
public void a(WebView webView) {
Class a2 = AdActivity.a();
Intent intent = new Intent(this.adViewImpl.getContext(), a2);
intent.setFlags(DownloadExpSwitchCode.BUGFIX_GETPACKAGEINFO_BY_UNZIP);
intent.putExtra("ACTIVITY_TYPE", "BROWSER");
com.beizi.ad.internal.a.a.a.add(webView);
if (this.adViewImpl.getBrowserStyle() != null) {
String str = "" + super.hashCode();
intent.putExtra("bridgeid", str);
AdViewImpl.c.a.add(new Pair<>(str, this.adViewImpl.getBrowserStyle()));
}
try {
this.adViewImpl.getContext().startActivity(intent);
k();
} catch (ActivityNotFoundException unused) {
HaoboLog.w(HaoboLog.baseLogTag, HaoboLog.getString(R.string.adactivity_missing, a2.getName()));
com.beizi.ad.internal.a.a.a.remove();
}
}
public void b(String str) {
if (!this.adViewImpl.getOpensNativeBrowser()) {
HaoboLog.d(HaoboLog.baseLogTag, HaoboLog.getString(R.string.opening_inapp));
if (h(str)) {
return;
}
try {
if (this.adViewImpl.getLoadsInBackground()) {
final c cVar = new c(getContext());
cVar.loadUrl(str, com.beizi.ad.a.a.h.a());
cVar.setVisibility(8);
this.adViewImpl.addView(cVar);
if (this.adViewImpl.getShowLoadingIndicator()) {
ProgressDialog progressDialog = new ProgressDialog(getContextFromMutableContext());
this.t = progressDialog;
progressDialog.setCancelable(true);
this.t.setOnCancelListener(new DialogInterface.OnCancelListener() {
@Override
public void onCancel(DialogInterface dialogInterface) {
cVar.stopLoading();
}
});
this.t.setMessage(getContext().getResources().getString(R.string.loading));
this.t.setProgressStyle(0);
this.t.show();
}
} else {
WebView webView = new WebView(new MutableContextWrapper(getContext()));
WebviewUtil.setWebViewSettings(webView);
webView.loadUrl(str, com.beizi.ad.a.a.h.a());
a(webView);
}
return;
} catch (Exception e) {
String str2 = HaoboLog.baseLogTag;
HaoboLog.e(str2, "Exception initializing the redirect webview: " + e.getMessage());
return;
}
}
HaoboLog.d(HaoboLog.baseLogTag, HaoboLog.getString(R.string.opening_native));
g(str);
k();
}
public void h() {
this.d = true;
}
public boolean IsVideoWifiOnly() {
return this.D;
}
public int getOrientation() {
return this.s;
}
@Override
public boolean failed() {
return this.d;
}
@Override
public void destroy() {
setVisibility(4);
ViewUtil.removeChildFromParent(this);
super.destroy();
removeAllViews();
j();
}
@Override
public void visible() {
Handler handler;
AdViewImpl adViewImpl;
setVisibility(0);
this.adViewImpl.showAdLogo(this);
if (l.BANNER.equals(this.adViewImpl.getMediaType())) {
AdViewImpl adViewImpl2 = this.adViewImpl;
adViewImpl2.showBannerCloseBtn(adViewImpl2);
}
if (shouldDisplayButton() && (adViewImpl = this.adViewImpl) != null) {
if (adViewImpl.getMediaType() == l.INTERSTITIAL) {
this.adViewImpl.addInterstitialCloseButton(getShowCloseBtnTime(), getAutoCloseTime(), this, this.ad.getAdType() == e.a.ADP_IVIDEO);
} else {
this.adViewImpl.isLoadToShow(this);
}
}
AdViewImpl adViewImpl3 = this.adViewImpl;
if (adViewImpl3 == null || adViewImpl3.getAdDispatcher() == null || this.adViewImpl.getMediaType() != l.BANNER || (handler = this.q) == null) {
return;
}
handler.postDelayed(new Runnable() {
@Override
public void run() {
AdWebView.this.adViewImpl.getAdDispatcher().a();
if (AdWebView.this.ad != null) {
ServerResponse serverResponse = AdWebView.this.ad;
AdWebView adWebView = AdWebView.this;
serverResponse.handleView(adWebView, adWebView.adViewImpl.getAdParameters().a());
}
}
}, 500L);
}
private void setCreativeWidth(int i) {
this.l = i;
}
@Override
public int getCreativeWidth() {
return this.l;
}
private void setCreativeHeight(int i) {
this.m = i;
}
@Override
public int getCreativeHeight() {
return this.m;
}
@Override
public int getRefreshInterval() {
return this.n;
}
@Override
public void onDestroy() {
destroy();
}
public boolean isMRAIDUseCustomClose() {
return this.u;
}
public void setMRAIDUseCustomClose(boolean z) {
this.u = z;
}
private void a(int i, int i2) {
if (i == 0 && i2 == 0) {
WebviewUtil.onResume(this);
this.p = true;
if (this.e && this.i) {
i();
}
} else {
WebviewUtil.onPause(this);
this.p = false;
j();
}
f fVar = this.f;
if (fVar != null) {
fVar.b();
}
}
@Override
protected void onWindowVisibilityChanged(int i) {
super.onWindowVisibilityChanged(i);
a(i, getVisibility());
}
@Override
public void onVisibilityChanged(View view, int i) {
super.onVisibilityChanged(view, i);
a(getWindowVisibility(), i);
}
@Override
public void scrollTo(int i, int i2) {
super.scrollTo(0, 0);
}
public void a(int i, int i2, boolean z, final f fVar, final boolean z2, final AdActivity.b bVar) {
int i3 = i;
int i4 = i2;
DisplayMetrics displayMetrics = new DisplayMetrics();
((WindowManager) getContext().getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(getLayoutParams());
if (!this.f.d) {
this.g = layoutParams.width;
this.h = layoutParams.height;
}
if (i4 == -1 && i3 == -1 && this.adViewImpl != null) {
this.a = true;
}
if (i4 != -1) {
i4 = (int) ((i4 * displayMetrics.density) + 0.5d);
}
int i5 = i4;
if (i3 != -1) {
i3 = (int) ((i3 * displayMetrics.density) + 0.5d);
}
int i6 = i3;
layoutParams.height = i5;
layoutParams.width = i6;
layoutParams.gravity = 17;
b bVar2 = null;
if (this.a) {
bVar2 = new b() {
@Override
public void a() {
f fVar2 = fVar;
if (fVar2 == null || fVar2.c() == null) {
return;
}
AdWebView.this.a(fVar.c(), z2, bVar);
AdViewImpl.setMRAIDFullscreenListener(null);
}
};
}
b bVar3 = bVar2;
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl != null) {
adViewImpl.a(i6, i5, z, fVar, bVar3);
this.adViewImpl.f();
}
setLayoutParams(layoutParams);
}
public void fireMRAIDEnabled() {
if (this.e) {
return;
}
this.e = true;
if (this.i) {
this.f.a(this, this.b);
i();
}
}
public void a(Activity activity, boolean z, AdActivity.b bVar) {
if (bVar != AdActivity.b.none) {
AdActivity.a(activity, bVar);
}
if (z) {
AdActivity.b(activity);
} else if (bVar == AdActivity.b.none) {
AdActivity.a(activity);
}
}
public void d() {
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl != null) {
adViewImpl.c();
}
}
public void e() {
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl != null) {
adViewImpl.a(this.g, this.h, this.f);
}
}
public void f() {
if (getContextFromMutableContext() instanceof Activity) {
int[] iArr = new int[2];
getLocationOnScreen(iArr);
boolean z = false;
int i = iArr[0];
int width = iArr[0] + getWidth();
int i2 = iArr[1];
int height = iArr[1] + getHeight();
int[] screenSizeAsPixels = ViewUtil.getScreenSizeAsPixels((Activity) getContextFromMutableContext());
if (width > 0 && i < screenSizeAsPixels[0] && height > 0 && i2 < screenSizeAsPixels[1]) {
z = true;
}
this.o = z;
f fVar = this.f;
if (fVar != null) {
fVar.b();
this.f.a(i, i2, getWidth(), getHeight());
this.f.a(getContext().getResources().getConfiguration().orientation);
}
}
}
public boolean g() {
return this.o && this.p;
}
public void resize(int i, int i2, int i3, int i4, f.a aVar, boolean z) {
DisplayMetrics displayMetrics = new DisplayMetrics();
((WindowManager) getContext().getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(getLayoutParams());
if (!this.f.d) {
this.g = layoutParams.width;
this.h = layoutParams.height;
}
int i5 = (int) ((i2 * displayMetrics.density) + 0.5d);
int i6 = (int) ((i * displayMetrics.density) + 0.5d);
layoutParams.height = i5;
layoutParams.width = i6;
layoutParams.gravity = 17;
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl != null) {
adViewImpl.a(i6, i5, i3, i4, aVar, z, this.f);
}
AdViewImpl adViewImpl2 = this.adViewImpl;
if (adViewImpl2 != null) {
adViewImpl2.f();
}
setLayoutParams(layoutParams);
}
public void i() {
if (this.p) {
this.r = false;
this.q.removeCallbacks(this.L);
this.q.post(this.L);
}
}
private void j() {
this.r = true;
this.q.removeCallbacks(this.L);
}
public class c extends WebView {
public c(Context context) {
super(new MutableContextWrapper(context));
WebviewUtil.setWebViewSettings(this);
setWebViewClient(new WebViewClient() {
private boolean c = false;
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
String str2 = HaoboLog.browserLogTag;
HaoboLog.v(str2, "Redirecting to URL: " + str);
boolean h = AdWebView.this.h(str);
this.c = h;
if (h && AdWebView.this.t != null && AdWebView.this.t.isShowing()) {
AdWebView.this.t.dismiss();
}
return this.c;
}
@Override
public void onPageFinished(WebView webView, String str) {
String str2 = HaoboLog.browserLogTag;
HaoboLog.v(str2, "Opening URL: " + str);
ViewUtil.removeChildFromParent(c.this);
if (AdWebView.this.t != null && AdWebView.this.t.isShowing()) {
AdWebView.this.t.dismiss();
}
if (this.c) {
this.c = false;
c.this.destroy();
AdWebView.this.k();
return;
}
c.this.setVisibility(0);
AdWebView.this.a(c.this);
}
});
}
}
public void k() {
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl == null || !(adViewImpl instanceof InterstitialAdViewImpl)) {
return;
}
((InterstitialAdViewImpl) adViewImpl).g();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
ProgressDialog progressDialog = this.t;
if (progressDialog == null || !progressDialog.isShowing()) {
return;
}
this.t.dismiss();
}
public Context getContextFromMutableContext() {
if (getContext() instanceof MutableContextWrapper) {
return ((MutableContextWrapper) getContext()).getBaseContext();
}
return getContext();
}
public void c(String str) {
if (Build.VERSION.SDK_INT >= 19) {
evaluateJavascript(str, null);
} else {
loadUrl(str, com.beizi.ad.a.a.h.a());
}
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
}
@Override
protected void onMeasure(int i, int i2) {
super.onMeasure(i, i2);
}
}