酷狗概念版 v2.5.5版本的 MD5 值为:782d327088fca4e58310f35a56f41319
以下内容为反编译后的 WebViewDialog.java 源代码,内容仅作参考
package com.kugou.android.app.fanxing.live.head;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.support.annotation.Nullable;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.ViewGroup;
import android.view.Window;
import android.webkit.JavascriptInterface;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
import android.widget.FrameLayout;
import com.kugou.android.app.flexowebview.a.a;
import com.kugou.android.lite.R;
import com.kugou.common.app.KGCommonApplication;
import com.kugou.common.utils.as;
import com.kugou.common.utils.br;
import com.kugou.common.web.WebSafeUtil;
import com.kugou.common.widget.BaseWebView;
import com.kugou.fanxing.delegate.FanxingModule;
import com.tencent.connect.common.Constants;
import java.lang.ref.WeakReference;
import java.net.HttpURLConnection;
import java.net.URI;
import org.apache.commons.codec.net.StringEncodings;
import org.json.JSONException;
import org.json.JSONObject;
public class WebViewDialog extends com.kugou.android.common.dialog.b {
private BaseWebView f8648a;
private com.kugou.common.web.c f8649b;
private a f8650c;
public WebViewDialog(Context context) {
super(context, R.style.co);
a(context);
b(context);
setCanceledOnTouchOutside(true);
this.f8650c = new a(this);
this.f8649b = a(true);
}
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
com.kugou.common.web.c cVar = this.f8649b;
if (cVar != null) {
cVar.OnCreate();
}
}
@Override
public void onStop() {
super.onStop();
com.kugou.common.web.c cVar = this.f8649b;
if (cVar != null) {
cVar.OnDestory();
}
}
private void a(Context context) {
Window window = getWindow();
window.setLayout(-1, -1);
window.setDimAmount(0.0f);
}
private void b(Context context) {
this.f8648a = new BaseWebView(context);
this.f8648a.setBackgroundColor(0);
com.kugou.android.app.fanxing.live.e.c.a(this.f8648a);
a();
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindow().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
FrameLayout frameLayout = new FrameLayout(context);
frameLayout.addView(this.f8648a, new FrameLayout.LayoutParams(displayMetrics.widthPixels, displayMetrics.heightPixels));
setContentView(frameLayout);
}
private void a() {
JavaWebExternal javaWebExternal = new JavaWebExternal(this);
if (!com.kugou.common.web.a.a.Is_Injected_Open) {
this.f8648a.addJavascriptInterface(javaWebExternal, "external");
}
this.f8648a.setWebChromeClient(new com.kugou.common.web.a.a("external", JavaWebExternal.class));
this.f8648a.setWebViewClient(new b());
}
public static class b extends com.kugou.common.datacollect.view.web.c {
private b() {
}
@Override
@Nullable
public WebResourceResponse shouldInterceptRequest(WebView webView, String str) {
if (as.f54365e) {
as.b("WebViewDialog", "shouldInterceptRequest: " + str);
}
try {
if (str.startsWith("https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb") && ("4.4.3".equals(Build.VERSION.RELEASE) || "4.4.4".equals(Build.VERSION.RELEASE))) {
HttpURLConnection httpURLConnection = (HttpURLConnection) URI.create(str).toURL().openConnection();
httpURLConnection.setRequestProperty("Referer", "http://mfanxing.kugou.com/");
httpURLConnection.setRequestMethod(Constants.HTTP_GET);
return new WebResourceResponse("html", StringEncodings.UTF8, httpURLConnection.getInputStream());
}
return WebSafeUtil.a(str);
} catch (Exception e2) {
as.e(e2);
return super.shouldInterceptRequest(webView, str);
}
}
}
public String a(int i, String str) {
Log.d("WebViewDialog", "handleJsMessage 代号:" + i + ",内容:" + str);
Message.obtain(this.f8650c, i, str).sendToTarget();
this.f8649b = a(true);
Log.d("WebViewDialog", "getKanCallback: " + this.f8649b);
com.kugou.common.web.c cVar = this.f8649b;
return cVar == null ? "" : cVar.superCall(i, str);
}
private com.kugou.common.web.c a(boolean z) {
com.kugou.common.web.c cVar = this.f8649b;
if (cVar != null) {
return cVar;
}
if (z) {
FanxingModule.init();
}
return a((com.kugou.common.web.b) null, this.ap, "com.kugou.fanxing.livehall.activity.KugouKanWebLogic");
}
private com.kugou.common.web.c a(com.kugou.common.web.b bVar, Context context, String str) {
try {
return (com.kugou.common.web.c) Class.forName(str).getConstructor(com.kugou.common.web.b.class, Context.class).newInstance(bVar, context);
} catch (Exception e2) {
as.e(e2);
return null;
}
}
public void a(String str) {
this.f8648a.loadUrl(str);
}
public static class JavaWebExternal extends com.kugou.common.datacollect.view.web.a implements a.InterfaceC0174a {
private final WeakReference<WebViewDialog> reference;
public JavaWebExternal(WebViewDialog webViewDialog) {
this.reference = new WeakReference<>(webViewDialog);
}
@Override
@JavascriptInterface
public String superCall(int i, String str) {
super.superCall(i, str);
WebViewDialog webViewDialog = this.reference.get();
return webViewDialog != null ? webViewDialog.a(i, str) : "";
}
@Override
@JavascriptInterface
public String superCall(int i) {
super.superCall(i);
WebViewDialog webViewDialog = this.reference.get();
return webViewDialog != null ? webViewDialog.a(i, "") : "";
}
}
public static class a extends com.kugou.framework.common.utils.stacktrace.e {
private WeakReference<WebViewDialog> f8651a;
public a(WebViewDialog webViewDialog) {
this.f8651a = new WeakReference<>(webViewDialog);
}
@Override
public void handleMessage(Message message) {
int optInt;
super.handleMessage(message);
WebViewDialog webViewDialog = this.f8651a.get();
if (webViewDialog == null) {
return;
}
int i = message.what;
if (i != 403) {
if (i == 470) {
webViewDialog.show();
return;
} else {
if (i != 471) {
return;
}
webViewDialog.dismiss();
return;
}
}
JSONObject a2 = a(message);
if (a2 != null && (optInt = a2.optInt("changeWebViewHeight")) > 0) {
ViewGroup.LayoutParams layoutParams = webViewDialog.f8648a.getLayoutParams();
layoutParams.height = br.a(KGCommonApplication.getContext(), optInt);
webViewDialog.f8648a.setLayoutParams(layoutParams);
}
}
private JSONObject a(Message message) {
try {
return new JSONObject((String) message.obj);
} catch (JSONException e2) {
as.e(e2);
return null;
}
}
}
}