红果免费短剧 v6.2.3.32版本的 MD5 值为:a6b05492607eab2c8a25f26d2f238ae0
以下内容为反编译后的 d.java 源代码,内容仅作参考
package com.dragon.community.saas.webview;
import android.app.Activity;
import android.app.Application;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewParent;
import android.webkit.CookieManager;
import android.webkit.WebChromeClient;
import android.webkit.WebResourceError;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import androidx.viewpager.widget.ViewPager;
import com.bytedance.android.monitorV2.webview.WebViewMonitorHelper;
import com.bytedance.pia.core.api.resource.IResourceRequest;
import com.bytedance.pia.core.api.resource.IResourceResponse;
import com.bytedance.pia.core.api.resource.LoadFrom;
import com.bytedance.pia.core.utils.ResourceConverterKt;
import com.dragon.community.saas.ui.view.TitleBar;
import com.dragon.community.saas.ui.view.swipeback.SwipeBackLayout;
import com.dragon.community.saas.utils.o;
import com.dragon.community.saas.utils.p;
import com.dragon.community.saas.utils.s;
import com.dragon.community.saas.utils.t;
import com.dragon.community.saas.webview.resize.ScrollableAreaRect;
import com.dragon.read.c.ad;
import com.google.gson.JsonObject;
import com.phoenix.read.R;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import me.ele.lancet.base.Scope;
import me.ele.lancet.base.annotations.Insert;
import me.ele.lancet.base.annotations.TargetClass;
public class d extends com.bytedance.webx.core.webview.d implements com.dragon.community.saas.a.a.a {
public static final s f37729a = new s("ReadingWebView");
private static int e = 10;
public boolean f37730b;
protected String f37731c;
protected final com.dragon.community.saas.webview.pia.a d;
private HashMap<String, a> f;
private HashMap<String, a> g;
private InterfaceC1476d h;
private f i;
private c j;
private com.dragon.community.saas.ui.a k;
private e l;
private Application.ActivityLifecycleCallbacks m;
private b n;
private com.dragon.community.saas.ui.view.swipeback.e o;
private List<ScrollableAreaRect> p;
private float q;
private float r;
private long s;
private long t;
private long u;
private boolean v;
private String w;
private TitleBar x;
public interface a {
void a();
}
public interface b {
void a();
void a(WebView webView);
}
public interface c {
boolean a(boolean z);
}
public interface InterfaceC1476d {
void a(boolean z);
}
public interface e {
void a();
}
public interface f {
}
protected static class i extends com.dragon.community.saas.webview.a.j {
protected i() {
}
@Override
public void onPageFinished(WebView webView, String str) {
super.onPageFinished(webView, str);
WebViewMonitorHelper.getInstance().onPageFinished(webView, str);
j.f37778a.a(webView, str);
}
@Override
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
super.onPageStarted(webView, str, bitmap);
WebViewMonitorHelper.getInstance().onPageStarted(webView, str, bitmap);
}
@Override
public void onReceivedHttpError(WebView webView, WebResourceRequest webResourceRequest, WebResourceResponse webResourceResponse) {
super.onReceivedHttpError(webView, webResourceRequest, webResourceResponse);
WebViewMonitorHelper.getInstance().handleRequestHttpError(webView, webResourceRequest, webResourceResponse);
}
@Override
public void onReceivedError(WebView webView, WebResourceRequest webResourceRequest, WebResourceError webResourceError) {
super.onReceivedError(webView, webResourceRequest, webResourceError);
WebViewMonitorHelper.getInstance().handleRequestError(webView, webResourceRequest, webResourceError);
}
@Override
public void onReceivedError(WebView webView, int i, String str, String str2) {
super.onReceivedError(webView, i, str, str2);
WebViewMonitorHelper.getInstance().handleRequestError(webView, i, str, str2);
}
}
public void e() {
l();
}
public void g() {
super.destroy();
}
public InterfaceC1476d getOnCloseEventListener() {
return this.h;
}
public TitleBar getTitleBar() {
return this.x;
}
@Override
public long getViewCreateTime() {
return this.u;
}
@Override
public void onPause() {
super.onPause();
}
@Override
public void onResume() {
super.onResume();
}
public void a(boolean z) {
if (z) {
b();
} else {
j();
}
}
public void a(boolean z, JsonObject jsonObject) {
if (this.f37730b) {
return;
}
if (z) {
f37729a.c("页面可见,手动分发 url = %s", getUrl());
com.dragon.community.saas.webview.xbridge.a.f37793a.a((WebView) this, "onPageVisible", jsonObject);
} else {
f37729a.c("页面不可见,手动分发 url = %s", getUrl());
com.dragon.community.saas.webview.xbridge.a.f37793a.a((WebView) this, "onPageInvisible", jsonObject);
}
}
protected void d() {
loadUrl("about:blank");
}
public void i() {
e eVar = this.l;
if (eVar != null) {
eVar.a();
}
}
private void l() {
com.dragon.community.saas.webview.xbridge.a.f37793a.a((WebView) this, "login_status_change", new JsonObject());
}
@Override
public void destroy() {
WebViewMonitorHelper.getInstance().destroy(this);
this.d.onDestroy();
super.destroy();
}
@Override
public void goBack() {
WebViewMonitorHelper.getInstance().goBack(this);
super.goBack();
}
@Override
public void reload() {
WebViewMonitorHelper.getInstance().reload(this);
super.reload();
}
private void k() {
if (this.m != null) {
return;
}
Context applicationContext = getContext().getApplicationContext();
if (applicationContext instanceof Application) {
com.dragon.community.saas.h.d dVar = new com.dragon.community.saas.h.d() {
@Override
public void onActivityDestroyed(Activity activity) {
super.onActivityDestroyed(activity);
if (com.dragon.community.saas.utils.f.getActivity(d.this.getContext()) == activity) {
d.f37729a.c("webview activity 销毁,url = %s", d.this.getUrl());
com.dragon.community.saas.webview.xbridge.a.f37793a.a((WebView) d.this, "onPageDestroy", (JsonObject) null);
}
}
@Override
public void onActivityPaused(Activity activity) {
super.onActivityPaused(activity);
if (d.this.f37730b && com.dragon.community.saas.utils.f.getActivity(d.this.getContext()) == activity && !activity.isFinishing()) {
d.f37729a.c("页面不可见,url = %s", d.this.getUrl());
com.dragon.community.saas.webview.xbridge.a.f37793a.a((WebView) d.this, "onPageInvisible", (JsonObject) null);
}
}
@Override
public void onActivityResumed(Activity activity) {
super.onActivityResumed(activity);
if (d.this.f37730b && com.dragon.community.saas.utils.f.getActivity(d.this.getContext()) == activity) {
d.f37729a.c("页面可见,url = %s", d.this.getUrl());
com.dragon.community.saas.webview.xbridge.a.f37793a.a((WebView) d.this, "onPageVisible", (JsonObject) null);
}
}
};
this.m = dVar;
((Application) applicationContext).registerActivityLifecycleCallbacks(dVar);
}
}
protected void f() {
if (11 <= Build.VERSION.SDK_INT && Build.VERSION.SDK_INT <= 17) {
removeJavascriptInterface("searchBoxJavaBridge_");
removeJavascriptInterface("accessibility");
removeJavascriptInterface("accessibilityTraversal");
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
f37729a.c("webView detachFromWindow", new Object[0]);
this.v = false;
b bVar = this.n;
if (bVar != null) {
bVar.a();
}
}
private void b() {
if (com.dragon.community.saas.utils.f.getActivity(getContext()) == null) {
return;
}
f37729a.c("进入前台,url = %s", getUrl());
this.v = true;
com.dragon.community.saas.webview.xbridge.a.f37793a.a((WebView) this, "enterForeground", (JsonObject) null);
}
private void j() {
if (com.dragon.community.saas.utils.f.getActivity(getContext()) == null) {
return;
}
f37729a.c("进入后台,url = %s", getUrl());
this.v = false;
com.dragon.community.saas.webview.xbridge.a.f37793a.a((WebView) this, "enterBackground", (JsonObject) null);
}
public void c() {
a();
try {
CookieManager.getInstance().setAcceptCookie(true);
} catch (Throwable unused) {
}
f();
WebViewMonitorHelper.getInstance().handleViewCreate(this);
this.d.onBindView(this);
this.u = System.currentTimeMillis();
}
public void h() {
Application.ActivityLifecycleCallbacks activityLifecycleCallbacks;
m();
setOnCloseEventListener(null);
a((c) null, true);
setHideNativeLoadingListener(null);
Context applicationContext = getContext().getApplicationContext();
if ((applicationContext instanceof Application) && (activityLifecycleCallbacks = this.m) != null) {
((Application) applicationContext).unregisterActivityLifecycleCallbacks(activityLifecycleCallbacks);
}
this.m = null;
d();
}
@Override
public void onAttachedToWindow() {
WebViewMonitorHelper.getInstance().onAttachedToWindow(this);
super.onAttachedToWindow();
f37729a.c("webView attachToWindow", new Object[0]);
this.v = true;
k();
b bVar = this.n;
if (bVar != null) {
bVar.a(this);
}
}
private void a() {
WebSettings settings = getSettings();
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
settings.setUseWideViewPort(true);
settings.setJavaScriptEnabled(true);
settings.setDomStorageEnabled(true);
settings.setAllowFileAccess(true);
settings.setDatabaseEnabled(true);
settings.setAppCacheEnabled(true);
settings.setBlockNetworkImage(false);
settings.setLoadWithOverviewMode(true);
if (Build.VERSION.SDK_INT >= 21) {
settings.setMixedContentMode(0);
}
settings.setUserAgentString(com.dragon.community.saas.webview.f.b.a().b(getsUserAgent()));
settings.setSavePassword(false);
}
private void m() {
HashMap<String, a> hashMap = this.f;
if (hashMap != null && hashMap.size() > 0) {
Iterator<a> it2 = this.f.values().iterator();
while (it2.hasNext()) {
it2.next().a();
}
this.f.clear();
}
HashMap<String, a> hashMap2 = this.g;
if (hashMap2 != null && hashMap2.size() > 0) {
Iterator<a> it3 = this.g.values().iterator();
while (it3.hasNext()) {
it3.next().a();
}
this.g.clear();
}
}
public String getsUserAgent() {
if (TextUtils.isEmpty(this.f37731c)) {
synchronized (d.class) {
if (TextUtils.isEmpty(this.f37731c)) {
this.f37731c = getSettings().getUserAgentString() + " " + com.dragon.community.saas.webview.d.c.f37737a.e().f37734a + "/" + com.dragon.community.saas.webview.d.c.f37737a.e().f37735b;
this.f37731c = com.dragon.community.saas.webview.f.b.a().b(this.f37731c);
}
}
}
return this.f37731c;
}
public void a(WebChromeClient webChromeClient) {
super.setWebChromeClient(webChromeClient);
}
public void setCallback(b bVar) {
this.n = bVar;
}
public void setHideNativeLoadingListener(e eVar) {
this.l = eVar;
}
public void setOnCloseEventListener(InterfaceC1476d interfaceC1476d) {
this.h = interfaceC1476d;
}
public void setTitleBar(TitleBar titleBar) {
this.x = titleBar;
}
public void setVisibilityAutoDispatch(boolean z) {
this.f37730b = z;
}
public static class g extends i {
private final com.dragon.community.saas.webview.pia.a f37739b;
@Override
public boolean shouldOverrideUrlLoading(WebView webView, WebResourceRequest webResourceRequest) {
return a(this, webView, webResourceRequest);
}
public g(com.dragon.community.saas.webview.pia.a aVar) {
this.f37739b = aVar;
}
@Override
public void onPageFinished(WebView webView, String str) {
if (str != null) {
this.f37739b.onLoadFinish(str);
}
super.onPageFinished(webView, str);
}
public boolean a(WebView webView, WebResourceRequest webResourceRequest) {
if (webResourceRequest != null && webResourceRequest.getUrl() != null) {
this.f37739b.onRedirect(webResourceRequest.getUrl().toString());
}
return super.shouldOverrideUrlLoading(webView, webResourceRequest);
}
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
IResourceResponse resourceResponse;
if (webResourceRequest != null && this.f37739b.shouldHandleResource(webResourceRequest.getUrl())) {
IResourceRequest resourceRequest = ResourceConverterKt.toResourceRequest(webResourceRequest);
IResourceResponse onBeforeLoadResource = this.f37739b.onBeforeLoadResource(resourceRequest);
if (onBeforeLoadResource != null) {
return ResourceConverterKt.toWebResourceResponse(onBeforeLoadResource);
}
WebResourceResponse shouldInterceptRequest = super.shouldInterceptRequest(webView, webResourceRequest);
com.dragon.community.saas.webview.pia.a aVar = this.f37739b;
if (shouldInterceptRequest == null) {
resourceResponse = null;
} else {
resourceResponse = ResourceConverterKt.toResourceResponse(shouldInterceptRequest, LoadFrom.Auto);
}
IResourceResponse onAfterLoadResource = aVar.onAfterLoadResource(resourceRequest, resourceResponse);
if (onAfterLoadResource != null) {
return ResourceConverterKt.toWebResourceResponse(onAfterLoadResource);
}
return shouldInterceptRequest;
}
return super.shouldInterceptRequest(webView, webResourceRequest);
}
@Override
public void onPageStarted(WebView webView, String str, Bitmap bitmap) {
if (str != null) {
this.f37739b.onLoadStart(str);
}
super.onPageStarted(webView, str, bitmap);
}
@TargetClass(scope = Scope.LEAF, value = "android.webkit.WebViewClient")
@Insert("shouldOverrideUrlLoading")
public static boolean a(g gVar, WebView webView, WebResourceRequest webResourceRequest) {
boolean a2 = gVar.a(webView, webResourceRequest);
if (ad.b(webView, webResourceRequest)) {
ad.f46099a.i("shouldOverrideUrlLoading, url: %s", webResourceRequest.getUrl().toString());
return true;
}
return a2;
}
}
public d(Context context) {
this(context, null);
}
public void b(boolean z) {
a(z, (JsonObject) null);
}
public void c(boolean z) {
InterfaceC1476d interfaceC1476d = this.h;
if (interfaceC1476d != null) {
interfaceC1476d.a(z);
}
}
public void a(WebViewClient webViewClient) {
super.setWebViewClient(webViewClient);
}
public boolean d(boolean z) {
c cVar = this.j;
if (cVar != null && cVar.a(z)) {
return true;
}
return false;
}
@Override
public void setWebChromeClient(WebChromeClient webChromeClient) {
if (webChromeClient == null) {
super.setWebChromeClient(null);
return;
}
h hVar = new h();
hVar.f37719a = webChromeClient;
super.setWebChromeClient(hVar);
}
@Override
public void setWebViewClient(WebViewClient webViewClient) {
if (webViewClient == null) {
super.setWebViewClient(null);
return;
}
g gVar = new g(this.d);
gVar.f37720a = webViewClient;
super.setWebViewClient(gVar);
}
public static String a(String str) {
if (com.dragon.community.saas.webview.d.c.f37737a.b() && !TextUtils.isEmpty(str)) {
String replace = str.replace("reading.snssdk.com/reading_offline/", "boe-ic.snssdk.com/reading_offline/");
if (replace.startsWith("https://boe-ic")) {
replace = replace.replaceFirst("https", "http");
}
t.d("web_view,BOE访问成功,original_url=%s,url_fixed = %s", str, replace);
return replace;
}
return str;
}
@Override
public boolean dispatchTouchEvent(MotionEvent motionEvent) {
int action = motionEvent.getAction();
if (action != 0) {
if (action == 1 && SystemClock.elapsedRealtime() - this.s < 100) {
this.t = SystemClock.elapsedRealtime();
}
} else {
this.s = SystemClock.elapsedRealtime();
}
return super.dispatchTouchEvent(motionEvent);
}
@Override
public void loadUrl(String str) {
String a2 = com.dragon.community.saas.webview.f.b.a().a(str);
String str2 = "";
if (!TextUtils.isEmpty(a2)) {
a2 = com.dragon.community.saas.webview.f.b.a().a(a(a2), "");
}
if (this.w == null) {
if (a2 != null) {
str2 = a2;
}
this.w = str2;
}
WebViewMonitorHelper.getInstance().onLoadUrl(this, str);
this.d.loadUrl(a2);
Map<String, String> a3 = com.dragon.community.saas.webview.f.d.a(null);
com.dragon.community.saas.webview.g.a().a(a3);
if (a3.isEmpty()) {
super.loadUrl(a2);
} else {
super.loadUrl(a2, a3);
}
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
ViewParent a2;
if (motionEvent.getAction() == 0) {
this.q = motionEvent.getX();
this.r = motionEvent.getY();
ViewParent a3 = a(this, e);
if (a3 != null) {
a3.requestDisallowInterceptTouchEvent(true);
}
} else if ((motionEvent.getAction() == 1 || motionEvent.getAction() == 3) && a(this.q, this.r) && (a2 = a(this, e)) != null) {
a2.requestDisallowInterceptTouchEvent(false);
}
return super.onTouchEvent(motionEvent);
}
public void a(int i2, int i3) {
setMeasuredDimension(i2, i3);
layout(0, 0, i2, i3);
}
protected static class h extends com.dragon.community.saas.webview.a.i {
@Override
public void onProgressChanged(WebView webView, int i) {
super.onProgressChanged(webView, i);
WebViewMonitorHelper.getInstance().onProgressChanged(webView, i);
}
}
public d(Context context, AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
private void b(String str, String str2) {
com.dragon.community.saas.webview.xbridge.a.f37793a.a(this, str, o.a(str2));
}
@Override
public void loadUrl(String str, Map<String, String> map) {
WebViewMonitorHelper.getInstance().onLoadUrl(this, str);
super.loadUrl(str, com.dragon.community.saas.webview.f.d.a(map));
}
private ViewParent a(View view, int i2) {
ViewParent parent;
if (i2 < 0 || (parent = view.getParent()) == 0) {
return null;
}
if (parent instanceof ViewPager) {
return parent;
}
if (!(parent instanceof View)) {
return null;
}
return a((View) parent, i2 - 1);
}
public void b(String str, a aVar) {
f37729a.b("[reportOnClosed] event: %s", str);
HashMap<String, a> hashMap = this.g;
if (hashMap != null) {
if (aVar == null) {
hashMap.remove(str);
} else {
hashMap.put(str, aVar);
}
}
}
private boolean a(float f2, float f3) {
if (p.a((Collection) this.p)) {
return false;
}
for (ScrollableAreaRect scrollableAreaRect : this.p) {
if (scrollableAreaRect != null && scrollableAreaRect.isInArea(f2, f3)) {
return true;
}
}
return false;
}
public void a(c cVar, boolean z) {
this.j = cVar;
for (ViewParent parent = getParent(); parent != null; parent = parent.getParent()) {
if (parent instanceof SwipeBackLayout) {
SwipeBackLayout swipeBackLayout = (SwipeBackLayout) parent;
if (swipeBackLayout.getId() == R.id.d03) {
swipeBackLayout.setSwipeBackEnabled(z);
if (this.o == null) {
com.dragon.community.saas.ui.view.swipeback.e eVar = new com.dragon.community.saas.ui.view.swipeback.e() {
@Override
public void a(SwipeBackLayout swipeBackLayout2, int i2) {
super.a(swipeBackLayout2, i2);
d.this.d(true);
}
};
this.o = eVar;
swipeBackLayout.a(eVar);
return;
}
return;
}
}
}
}
public void a(String str, a aVar) {
HashMap<String, a> hashMap = this.f;
if (hashMap != null) {
if (aVar == null) {
hashMap.remove(str);
} else {
hashMap.put(str, aVar);
}
}
}
public void a(String str, String str2) {
b(str, str2);
}
public d(Context context, AttributeSet attributeSet, int i2) {
super(context, attributeSet, i2);
this.f37730b = true;
this.f37731c = null;
this.f = new HashMap<>();
this.g = new HashMap<>();
this.v = false;
this.w = null;
this.d = new com.dragon.community.saas.webview.pia.a(this);
c();
}
@Override
public void onScrollChanged(int i2, int i3, int i4, int i5) {
super.onScrollChanged(i2, i3, i4, i5);
com.dragon.community.saas.ui.a aVar = this.k;
if (aVar != null) {
aVar.a(this, i2, i3, i4, i5);
}
}
@Override
public void onOverScrolled(int i2, int i3, boolean z, boolean z2) {
if (z || z2) {
ViewParent a2 = a(this, e);
boolean a3 = a(this.q, this.r);
if (a2 != null && !a3) {
a2.requestDisallowInterceptTouchEvent(false);
}
}
super.onOverScrolled(i2, i3, z, z2);
}
}