XPJ v3.0.6版本的 MD5 值为:c31c0f1861a74a2223b50f64fc02b761
以下内容为反编译后的 GameActivity.java 源代码,内容仅作参考
package wendu.dsbridge.game;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.http.SslError;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.CookieManager;
import android.webkit.JavascriptInterface;
import android.webkit.RenderProcessGoneDetail;
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.ImageView;
import android.widget.LinearLayout;
import com.gyf.immersionbar.BarHide;
import com.gyf.immersionbar.ImmersionBar;
import java.lang.ref.WeakReference;
import java.util.Timer;
import java.util.TimerTask;
import wendu.dsbridge.CompletionHandler;
import wendu.dsbridge.DWebView;
import wendu.dsbridge.R;
import wendu.dsbridge.game.Html5WebView;
@RequiresApi(api = 21)
public class GameActivity extends AppCompatActivity implements View.OnClickListener {
private static final String GAME_ID = "gameId";
private static final String GAME_TYPE = "gameType";
private static final String URL = "url";
private DisplayMetrics displayMetrics;
private String gameId;
private String gameType;
private boolean isFullScreen;
private ImageView ivBack;
private ImageView ivExpand;
private LinearLayout layout_back_view;
private LinearLayout llOpts;
private long mLastBackTime;
private Html5WebView mNewWebView;
private DWebView mTxqpWebView;
private Html5WebView mWebView;
private FrameLayout rl_parent_layout;
private Timer timer;
private Toolbar toolbar;
private String url = "";
private LoadingDialog mLoading = null;
public static Intent initData(Context context, String str, String str2, String str3) {
Intent intent = new Intent(context, (Class<?>) GameActivity.class);
intent.putExtra(URL, str);
intent.putExtra(GAME_TYPE, str2);
intent.putExtra(GAME_ID, str3);
return intent;
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_main2);
this.url = getIntent().getStringExtra(URL);
this.gameType = getIntent().getStringExtra(GAME_TYPE);
this.gameId = getIntent().getStringExtra(GAME_ID);
this.rl_parent_layout = (FrameLayout) findViewById(R.id.rl_parent_layout);
findViewById(R.id.layout_title_left).setOnClickListener(this);
findViewById(R.id.layout_title_right).setOnClickListener(this);
this.layout_back_view = (LinearLayout) findViewById(R.id.layout_back_view);
this.layout_back_view.setOnClickListener(this);
this.toolbar = (Toolbar) findViewById(R.id.toolbar);
this.mWebView = (Html5WebView) findViewById(R.id.wv_game);
this.mTxqpWebView = (DWebView) findViewById(R.id.wv_txqp_game);
this.ivExpand = (ImageView) findViewById(R.id.ivExpand);
this.ivBack = (ImageView) findViewById(R.id.ivBack);
this.llOpts = (LinearLayout) findViewById(R.id.llOpts);
this.ivExpand.setOnClickListener(this);
this.ivBack.setOnClickListener(this);
setOrientationByGame(this.gameType, this.gameId);
if (!TextUtils.isEmpty(this.gameType) && this.gameType.equalsIgnoreCase("dtqp")) {
this.mTxqpWebView.setVisibility(0);
this.mWebView.setVisibility(8);
this.rl_parent_layout.setVisibility(8);
initTxqpWebView();
this.mTxqpWebView.loadUrl(this.url);
} else {
this.rl_parent_layout.setVisibility(0);
this.mWebView.setVisibility(0);
this.mTxqpWebView.setVisibility(8);
initWebView(this.mWebView);
this.mWebView.loadUrl(this.url);
}
this.timer = new Timer();
}
private void initTitle(boolean z) {
this.toolbar.setVisibility(z ? 8 : 0);
this.layout_back_view.setVisibility(z ? 0 : 8);
this.isFullScreen = z;
if (z) {
ImmersionBar.with(this).transparentBar().fullScreen(true).hideBar(BarHide.FLAG_HIDE_BAR).keyboardEnable(true).init();
} else {
ImmersionBar.with(this).titleBar(this.toolbar).transparentBar().hideBar(BarHide.FLAG_HIDE_NAVIGATION_BAR).keyboardEnable(true).statusBarDarkFont(false, 0.0f).init();
}
}
private void initDTitle() {
this.toolbar.setVisibility(8);
this.layout_back_view.setVisibility(8);
ImmersionBar.with(this).transparentBar().fullScreen(true).hideBar(BarHide.FLAG_HIDE_BAR).keyboardEnable(true).init();
}
private void getScreenOrientation() {
this.displayMetrics = getResources().getDisplayMetrics();
if (this.displayMetrics.widthPixels > this.displayMetrics.heightPixels) {
initTitle(true);
} else {
initTitle(false);
}
}
private void initTxqpWebView() {
initDTitle();
WebSettings settings = this.mTxqpWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
settings.setBuiltInZoomControls(false);
settings.setUseWideViewPort(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
settings.setLoadWithOverviewMode(true);
settings.setDisplayZoomControls(false);
if (Build.VERSION.SDK_INT >= 21) {
settings.setMixedContentMode(0);
}
DWebView.setWebContentsDebuggingEnabled(true);
this.mTxqpWebView.addJavascriptObject(new JaveJsBridge(this), "echo");
this.mTxqpWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
if (str.startsWith("http://no_return/") || str.startsWith("http://202.172.18.226/") || str.startsWith("https://no_return/") || str.startsWith("https://202.172.18.226/")) {
GameActivity.this.finish();
return true;
}
webView.getSettings().setCacheMode(-1);
return super.shouldOverrideUrlLoading(webView, str);
}
@Override
public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
sslErrorHandler.proceed();
}
});
}
public void initWebView(final Html5WebView html5WebView) {
getScreenOrientation();
html5WebView.requestFocus();
html5WebView.setEnabled(true);
WebSettings settings = html5WebView.getSettings();
if (Build.VERSION.SDK_INT >= 21) {
settings.setMixedContentMode(2);
}
settings.setSupportMultipleWindows(true);
settings.setJavaScriptEnabled(true);
settings.setAllowFileAccess(true);
settings.setBuiltInZoomControls(true);
settings.setAppCacheEnabled(true);
settings.setDomStorageEnabled(true);
settings.supportMultipleWindows();
settings.setAllowContentAccess(true);
settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setSavePassword(true);
settings.setSaveFormData(true);
settings.setJavaScriptCanOpenWindowsAutomatically(true);
settings.setLoadsImagesAutomatically(true);
if (Build.VERSION.SDK_INT >= 21) {
CookieManager.getInstance().setAcceptThirdPartyCookies(html5WebView, true);
} else {
CookieManager.getInstance().setAcceptCookie(true);
}
Html5WebView.setWebContentsDebuggingEnabled(true);
html5WebView.setWebViewClient(new WebViewClient() {
@Override
public WebResourceResponse shouldInterceptRequest(WebView webView, WebResourceRequest webResourceRequest) {
try {
if (GameActivity.this.url.startsWith("no_return") || GameActivity.this.url.startsWith("202.172.18.226") || GameActivity.this.url.startsWith("tx1212.com")) {
GameActivity.this.finish();
return null;
}
} catch (Exception e) {
e.printStackTrace();
}
return super.shouldInterceptRequest(webView, webResourceRequest);
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
if ((!str.contains("cdn.zhongfangletou.com/h5Front/index") && str.contains("cdn.zhongfangletou.com/h5Front/")) || (!str.contains("cdn-ali.zhongfangletou.com/h5Front/index") && str.contains("cdn-ali.zhongfangletou.com/h5Front/"))) {
GameActivity.this.finish();
return true;
}
return super.shouldOverrideUrlLoading(webView, str);
}
@Override
public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
sslErrorHandler.proceed();
if (Build.VERSION.SDK_INT >= 21) {
html5WebView.getSettings().setMixedContentMode(2);
}
}
@Override
public boolean onRenderProcessGone(WebView webView, RenderProcessGoneDetail renderProcessGoneDetail) {
ViewGroup viewGroup = (ViewGroup) GameActivity.this.mWebView.getParent();
GameActivity.this.destroyWebView();
GameActivity gameActivity = GameActivity.this;
gameActivity.mWebView = new Html5WebView(gameActivity);
GameActivity.this.mWebView.setFocusable(true);
GameActivity.this.mWebView.setFocusableInTouchMode(true);
viewGroup.addView(GameActivity.this.mWebView, 0, new FrameLayout.LayoutParams(-1, -1));
GameActivity gameActivity2 = GameActivity.this;
gameActivity2.initWebView(gameActivity2.mWebView);
GameActivity.this.mWebView.loadUrl(GameActivity.this.url);
return true;
}
});
this.mWebView.setWebChromeClient(new Html5WebView.TXWebChromeClient() {
@Override
public void onProgressChanged(WebView webView, int i) {
super.onProgressChanged(webView, i);
if (i >= 100) {
GameActivity.this.hideLoadingDialog();
} else {
GameActivity.this.showLoadingDialog();
}
}
@Override
public boolean onCreateWindow(WebView webView, boolean z, boolean z2, Message message) {
GameActivity gameActivity = GameActivity.this;
gameActivity.mNewWebView = new Html5WebView(gameActivity);
GameActivity.this.mNewWebView.setFocusable(true);
GameActivity.this.mNewWebView.setFocusableInTouchMode(true);
GameActivity.this.rl_parent_layout.addView(GameActivity.this.mNewWebView);
GameActivity gameActivity2 = GameActivity.this;
gameActivity2.initWebView(gameActivity2.mNewWebView);
((WebView.WebViewTransport) message.obj).setWebView(GameActivity.this.mNewWebView);
message.sendToTarget();
return true;
}
@Override
public void onCloseWindow(WebView webView) {
super.onCloseWindow(webView);
if (GameActivity.this.mNewWebView != null) {
GameActivity.this.rl_parent_layout.removeView(GameActivity.this.mNewWebView);
}
GameActivity.this.finish();
}
});
}
@SuppressLint({"SourceLockedOrientationActivity"})
private void setOrientationByGame(String str, String str2) {
if (isCagayan88(str, str2) || isXYBY(str, str2) || isBYDS(str, str2)) {
setRequestedOrientation(1);
}
}
private boolean isCagayan88(String str, String str2) {
return "CG".equals(str) && "".equals(str2);
}
private boolean isXYBY(String str, String str2) {
return "BG".equals(str) && "411".equals(str2);
}
private boolean isBYDS(String str, String str2) {
return "BG".equals(str) && "105".equals(str2);
}
@Override
public void onBackPressed() {
if (this.isFullScreen && (TextUtils.isEmpty(this.gameType) || !this.gameType.equalsIgnoreCase("dtqp"))) {
initTitle(false);
return;
}
long currentTimeMillis = System.currentTimeMillis();
if (currentTimeMillis - this.mLastBackTime > 2000) {
this.mLastBackTime = currentTimeMillis;
} else {
super.onBackPressed();
}
}
@Override
public void onClick(View view) {
int id = view.getId();
if (id == R.id.ivExpand) {
this.ivExpand.animate().translationX(this.ivExpand.getWidth()).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
GameActivity.this.llOpts.setVisibility(0);
}
});
this.timer.schedule(new ResetStateTask(), 2000L);
} else if (id == R.id.ivBack) {
onBackPressed();
}
if (id == R.id.layout_title_right) {
initTitle(true);
}
if (id == R.id.layout_title_left || id == R.id.layout_back_view) {
finish();
}
}
public class JaveJsBridge {
private WeakReference<Activity> wrf;
public JaveJsBridge(Activity activity) {
this.wrf = null;
this.wrf = new WeakReference<>(activity);
}
@JavascriptInterface
@SuppressLint({"JavascriptInterface"})
public void routToCustomerService(Object obj, CompletionHandler<String> completionHandler) {
WeakReference<Activity> weakReference = this.wrf;
if (weakReference == null || weakReference.get() == null) {
return;
}
this.wrf.get().finish();
}
@JavascriptInterface
@SuppressLint({"JavascriptInterface"})
public void backExitApp(Object obj, CompletionHandler<String> completionHandler) {
WeakReference<Activity> weakReference = this.wrf;
if (weakReference == null || weakReference.get() == null) {
return;
}
this.wrf.get().finish();
}
}
private class ResetStateTask extends TimerTask {
private ResetStateTask() {
}
@Override
public void run() {
GameActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
GameActivity.this.ivExpand.animate().translationX(0.0f).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animator) {
GameActivity.this.llOpts.setVisibility(8);
}
});
}
});
}
}
@Override
public void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
if (configuration.orientation == 2) {
initTitle(true);
} else {
initTitle(false);
}
}
@Override
public void onDestroy() {
super.onDestroy();
hideLoadingDialog();
Html5WebView html5WebView = this.mWebView;
if (html5WebView != null) {
html5WebView.destroy();
}
this.timer.cancel();
}
public void showLoadingDialog() {
if (this.mLoading == null) {
this.mLoading = new LoadingDialog(this);
this.mLoading.setCancelable(false);
this.mLoading.setCanceledOnTouchOutside(false);
this.mLoading.setTitleText("加载中...");
}
if (this.mLoading.isShowing()) {
return;
}
this.mLoading.show();
}
public void hideLoadingDialog() {
LoadingDialog loadingDialog = this.mLoading;
if (loadingDialog == null || !loadingDialog.isShowing()) {
return;
}
this.mLoading.dismiss();
}
public void destroyWebView() {
this.mWebView.loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
this.mWebView.clearHistory();
((ViewGroup) this.mWebView.getParent()).removeView(this.mWebView);
this.mWebView.destroy();
this.mWebView = null;
}
}