整点视频 v3.3.0版本的 MD5 值为:cba0457dc37421eed445b30f92de25d3
以下内容为反编译后的 AdWebView.java 源代码,内容仅作参考
package com.beizi.ad.internal.view;
import android.annotation.SuppressLint;
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.google.android.material.badge.BadgeDrawable;
import com.ss.android.socialbase.downloader.utils.DownloadExpSwitchCode;
import fi.iki.elonen.NanoHTTPD;
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;
@SuppressLint({"ViewConstructor"})
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 class a extends WebViewClient {
private a() {
}
@Override
public void onLoadResource(WebView webView, String str) {
if (str.startsWith("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 onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
AdWebView adWebView = AdWebView.this;
if (adWebView.ad.mMediaType == l.SPLASH) {
adWebView.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 adWebView2 = AdWebView.this;
fVar.a(adWebView2, adWebView2.b);
AdWebView.this.i();
}
AdWebView.this.i = true;
}
@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));
AdViewImpl adViewImpl = AdWebView.this.adViewImpl;
if (adViewImpl == null || 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()));
AdViewImpl adViewImpl = AdWebView.this.adViewImpl;
if (adViewImpl == null || adViewImpl.getAdDispatcher() == null) {
return;
}
AdWebView.this.adViewImpl.getAdDispatcher().a(2);
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
return AdWebView.this.a(webResourceRequest);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
AdViewImpl adViewImpl;
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 adWebView = AdWebView.this;
if (adWebView.ad != null && (adViewImpl = adWebView.adViewImpl) != null && adViewImpl.getAdParameters() != null) {
AdWebView adWebView2 = AdWebView.this;
adWebView2.ad.handleClick(adWebView2, "", "", "", "", "", "", adWebView2.c, adWebView2.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;
}
}
}
public interface b {
void a();
}
public class c extends WebView {
@SuppressLint({"SetJavaScriptEnabled"})
public c(Context context) {
super(new MutableContextWrapper(context));
WebviewUtil.setWebViewSettings(this);
setWebViewClient(new WebViewClient() {
private boolean c = false;
@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);
c cVar = c.this;
AdWebView.this.a(cVar);
}
@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;
}
});
}
}
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);
}
public void k() {
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl == null || !(adViewImpl instanceof InterstitialAdViewImpl)) {
return;
}
((InterstitialAdViewImpl) adViewImpl).g();
}
private void setCreativeHeight(int i) {
this.m = i;
}
private void setCreativeWidth(int i) {
this.l = i;
}
public boolean IsVideoWifiOnly() {
return this.D;
}
public void closeWebResourceRequestConnection() {
try {
InputStream inputStream = this.K;
if (inputStream != null) {
inputStream.close();
}
HttpURLConnection httpURLConnection = this.J;
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void destroy() {
setVisibility(4);
ViewUtil.removeChildFromParent(this);
super.destroy();
removeAllViews();
j();
}
@Override
public boolean failed() {
return this.d;
}
public void fireMRAIDEnabled() {
if (this.e) {
return;
}
this.e = true;
if (this.i) {
this.f.a(this, this.b);
i();
}
}
public HashMap<String, Object> getAdExtras() {
ServerResponse serverResponse = this.ad;
if (serverResponse == null) {
return null;
}
return serverResponse.getExtras();
}
public int getAutoCloseTime() {
return this.x;
}
public Context getContextFromMutableContext() {
if (getContext() instanceof MutableContextWrapper) {
return ((MutableContextWrapper) getContext()).getBaseContext();
}
return getContext();
}
@Override
public int getCreativeHeight() {
return this.m;
}
public int getCreativeLeft() {
return this.j;
}
public int getCreativeTop() {
return this.k;
}
@Override
public int getCreativeWidth() {
return this.l;
}
public f getMRAIDImplementation() {
return this.f;
}
public int getOrientation() {
return this.s;
}
public com.beizi.ad.internal.view.c getRealDisplayable() {
AdVideoView adVideoView;
return (!this.C || (adVideoView = this.mAdVideoView) == null) ? this : adVideoView;
}
@Override
public int getRefreshInterval() {
return this.n;
}
public int getShowCloseBtnTime() {
return this.w;
}
public boolean getUserInteraction() {
return this.v;
}
@Override
public View getView() {
return this;
}
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 boolean isAutoPlay() {
return this.z;
}
public boolean isMRAIDUseCustomClose() {
return this.u;
}
public boolean isMuted() {
return this.A;
}
public boolean isVideoFullScreen() {
return this.B;
}
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 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) {
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);
l lVar = this.ad.mMediaType;
if (lVar == l.SPLASH) {
setLayoutParams(new FrameLayout.LayoutParams(-1, -1, 17));
} else if (lVar == l.BANNER) {
a(new FrameLayout.LayoutParams(-2, -1, 17));
} else {
a(layoutParams);
}
} else {
FrameLayout.LayoutParams layoutParams2 = new FrameLayout.LayoutParams(creativeWidth, creativeHeight, BadgeDrawable.TOP_START);
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, NanoHTTPD.MIME_HTML, Key.STRING_CHARSET_NAME, null);
this.C = false;
}
this.y = i;
return true;
}
h();
}
return false;
}
public boolean loadAdBy(int i) {
return loadAdAt(this.y + i);
}
@Override
protected void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
f();
}
@Override
public void onDestroy() {
destroy();
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
ProgressDialog progressDialog = this.t;
if (progressDialog == null || !progressDialog.isShowing()) {
return;
}
this.t.dismiss();
}
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
}
@Override
protected void onMeasure(int i, int i2) {
super.onMeasure(i, i2);
}
@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) {
if (action == 2 && this.I && a(this.G, this.H, motionEvent.getX(), motionEvent.getY()) > 15.0f) {
this.I = false;
}
} else {
long currentTimeMillis = System.currentTimeMillis();
long j = this.F;
if (currentTimeMillis - j < 1000 && this.I) {
handleClickView(motionEvent, j, currentTimeMillis);
}
}
return super.onTouchEvent(motionEvent);
}
@Override
public void onVisibilityChanged(View view, int i) {
super.onVisibilityChanged(view, i);
a(getWindowVisibility(), i);
}
@Override
protected void onWindowVisibilityChanged(int i) {
super.onWindowVisibilityChanged(i);
a(i, getVisibility());
}
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());
f fVar = this.f;
if (!fVar.d) {
this.g = layoutParams.width;
this.h = layoutParams.height;
}
float f = displayMetrics.density;
int i5 = (int) ((i2 * f) + 0.5d);
int i6 = (int) ((i * f) + 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, fVar);
}
AdViewImpl adViewImpl2 = this.adViewImpl;
if (adViewImpl2 != null) {
adViewImpl2.f();
}
setLayoutParams(layoutParams);
}
@Override
public void scrollTo(int i, int i2) {
super.scrollTo(0, 0);
}
public void setCreativeLeft(int i) {
this.j = i;
}
public void setCreativeTop(int i) {
this.k = i;
}
public void setMRAIDUseCustomClose(boolean z) {
this.u = z;
}
public void setRefreshInterval(int i) {
this.n = i;
}
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;
}
@Override
public void visible() {
Handler handler;
AdViewImpl adViewImpl;
setVisibility(0);
this.adViewImpl.showAdLogo(this);
l lVar = l.BANNER;
if (lVar.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() != lVar || (handler = this.q) == null) {
return;
}
handler.postDelayed(new Runnable() {
@Override
public void run() {
AdWebView.this.adViewImpl.getAdDispatcher().a();
AdWebView adWebView = AdWebView.this;
ServerResponse serverResponse = adWebView.ad;
if (serverResponse != null) {
serverResponse.handleView(adWebView, adWebView.adViewImpl.getAdParameters().a());
}
}
}, 500L);
}
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)) {
sb.append("</script></head>");
return str.replaceFirst("<html>", Matcher.quoteReplacement(sb.toString()));
}
HaoboLog.e(HaoboLog.baseLogTag, "Error reading SDK's raw resources.");
return str;
}
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 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("http") || str.startsWith(a2)) {
return false;
}
HaoboLog.i(HaoboLog.baseLogTag, HaoboLog.getString(R.string.opening_app_store));
return g(str);
}
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 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>";
}
@SuppressLint({"SetJavaScriptEnabled"})
protected void b() {
this.f = new f(this);
setWebChromeClient(new h(this));
setWebViewClient(new a());
}
public void c() {
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl != null) {
adViewImpl.f();
}
}
public void c(String str) {
if (Build.VERSION.SDK_INT >= 19) {
evaluateJavascript(str, null);
} else {
loadUrl(str, com.beizi.ad.a.a.h.a());
}
}
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 void h() {
this.d = true;
}
@SuppressLint({"SetJavaScriptEnabled"})
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);
int i = Build.VERSION.SDK_INT;
if (i >= 17) {
getSettings().setMediaPlaybackRequiresUserGesture(false);
}
if (i >= 21) {
getSettings().setMixedContentMode(0);
}
if (i >= 19) {
WebView.setWebContentsDebuggingEnabled(false);
}
if (i >= 11 && i < 19) {
removeJavascriptInterface("searchBoxJavaBridge_");
removeJavascriptInterface("accessibility");
removeJavascriptInterface("accessibilityTraversal");
}
getSettings().setAllowFileAccess(false);
getSettings().setAllowContentAccess(false);
if (i >= 16) {
getSettings().setAllowFileAccessFromFileURLs(false);
getSettings().setAllowUniversalAccessFromFileURLs(false);
}
if (i >= 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();
}
}
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 d() {
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl != null) {
adViewImpl.c();
}
}
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;
}
public boolean g() {
return this.o && this.p;
}
public void e() {
AdViewImpl adViewImpl = this.adViewImpl;
if (adViewImpl != null) {
adViewImpl.a(this.g, this.h, this.f);
}
}
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);
}
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
protected String getUrl() {
return str;
}
@Override
public void onPostExecute(HTTPResponse hTTPResponse) {
if (hTTPResponse.getSucceeded()) {
AdWebView.this.loadDataWithBaseURL(null, AdWebView.this.f(AdWebView.this.e(AdWebView.this.d(hTTPResponse.getResponseBody()))), NanoHTTPD.MIME_HTML, Key.STRING_CHARSET_NAME, null);
AdWebView.this.fireMRAIDEnabled();
}
}
}.execute(new Void[0]);
}
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;
}
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("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 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();
}
}
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();
}
}
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 a(Activity activity, boolean z, AdActivity.b bVar) {
AdActivity.b bVar2 = AdActivity.b.none;
if (bVar != bVar2) {
AdActivity.a(activity, bVar);
}
if (z) {
AdActivity.b(activity);
} else if (bVar == bVar2) {
AdActivity.a(activity);
}
}
}