畅玩新葡京 v8.2.8版本的 MD5 值为:1e36e0a7adef719a26e0a466b52c398d
以下内容为反编译后的 WebGameActivity.java 源代码,内容仅作参考
package org.cocos2dx.javascript;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.Configuration;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.URLUtil;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentActivity;
import com.alipay.sdk.cons.b;
import com.bumptech.glide.Glide;
import com.google.gson.Gson;
import com.tencent.connect.common.Constants;
import com.tencent.smtt.sdk.CookieSyncManager;
import com.tencent.smtt.sdk.ValueCallback;
import com.tencent.smtt.sdk.WebChromeClient;
import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;
import com.yojsn1111.cocosandroid.R;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import np.C0046;
import np.NPFog;
import org.cocos2dx.javascript.utils.ActivityManager;
import org.cocos2dx.javascript.utils.AppDensityUtil;
import org.cocos2dx.javascript.utils.GlobalLayoutUtil;
import org.cocos2dx.javascript.utils.KLog;
import org.cocos2dx.javascript.utils.MQTTManager;
import org.cocos2dx.javascript.utils.MqttRelevantConstant;
import org.cocos2dx.javascript.utils.MqttResponseBean;
import org.cocos2dx.javascript.utils.NotchTools;
import org.cocos2dx.javascript.utils.UpayinfoBean;
import org.cocos2dx.javascript.utils.Utils;
import org.cocos2dx.javascript.views.X5WebView;
import org.cocos2dx.lib.DragButtons;
public class WebGameActivity extends AppCompatActivity {
public static final String INTENT_URL = "intentUrl";
public static final String LOOP_URL = "loopUrl";
public static final String LOTTERY = "lottery";
public static final String NOTINITIAL = "notInitial";
public static final String ORIENTATION = "orientation";
private static final String TAG = "WebGameActivity";
public static final String TOKEN = "token";
public static final String UPAYINFO = "UPayInfo";
public static boolean isLottery;
public static int trueOri;
public static boolean ubshow;
private WebGameActivity activity;
private FrameLayout base_frame;
private DragButtons btn_home;
private FrameLayout flGameWebView;
private String loopUrl;
private ValueCallback<Uri[]> mUploadCallbackAboveL;
private X5WebView mWebView;
private RelativeLayout rl_loadbg;
private String token;
private String upay_info;
private String initial = "0";
private String orientation = "0";
private int status = 2;
private ScheduledExecutorService scheduledThreadPool = Executors.newScheduledThreadPool(4);
private final int FILECHOOSER_RESULTCODE = 10000;
class RequestTask implements Runnable {
public RequestTask() {
Log.i(WebGameActivity.TAG, "RequestTask: 空构造方法执行了");
}
@Override
public void run() {
BufferedReader bufferedReader;
Log.i(WebGameActivity.TAG, "线程名: " + Thread.currentThread().getName() + ", 线程状态: " + Thread.currentThread().getState());
InputStream inputStream = null;
try {
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(WebGameActivity.this.loopUrl).openConnection();
Log.i(WebGameActivity.TAG, "HttpURLConnection: " + httpURLConnection);
httpURLConnection.setRequestMethod(Constants.HTTP_GET);
httpURLConnection.addRequestProperty("Authorization", WebGameActivity.this.token);
httpURLConnection.setConnectTimeout(20000);
httpURLConnection.setReadTimeout(20000);
httpURLConnection.connect();
if (httpURLConnection.getResponseCode() == 200) {
InputStream inputStream2 = httpURLConnection.getInputStream();
try {
bufferedReader = new BufferedReader(new InputStreamReader(inputStream2, "utf-8"));
} catch (Exception e) {
e = e;
bufferedReader = null;
} catch (Throwable th) {
th = th;
bufferedReader = null;
}
try {
Log.i(WebGameActivity.TAG, "response: " + WebGameActivity.this.is2String(bufferedReader));
inputStream = inputStream2;
} catch (Exception e2) {
e = e2;
inputStream = inputStream2;
try {
e.printStackTrace();
Log.i(WebGameActivity.TAG, "Exception: " + e.getMessage());
if (inputStream != null) {
inputStream.close();
}
if (bufferedReader != null) {
bufferedReader.close();
return;
}
return;
} catch (Throwable th2) {
th = th2;
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e3) {
e3.printStackTrace();
throw th;
}
}
if (bufferedReader != null) {
bufferedReader.close();
}
throw th;
}
} catch (Throwable th3) {
th = th3;
inputStream = inputStream2;
if (inputStream != null) {
}
if (bufferedReader != null) {
}
throw th;
}
} else {
bufferedReader = null;
}
if (inputStream != null) {
inputStream.close();
}
if (bufferedReader != null) {
bufferedReader.close();
}
} catch (IOException e4) {
e4.printStackTrace();
}
} catch (Exception e5) {
e = e5;
bufferedReader = null;
} catch (Throwable th4) {
th = th4;
bufferedReader = null;
}
}
}
private void fitSys() {
Log.e(TAG, "全屏 status=" + this.status);
NotchTools.statusBarAndNavigationBar(this, this.status == 1);
}
private void initView() {
String string;
String str;
this.btn_home = (DragButtons) findViewById(NPFog.d(2131232122));
this.base_frame = (FrameLayout) findViewById(NPFog.d(2131232085));
getResources().getConfiguration();
if (trueOri == 1) {
this.btn_home.setImageResource(R.drawable.home2);
ViewGroup.LayoutParams layoutParams = this.btn_home.getLayoutParams();
int dip2px = AppDensityUtil.dip2px(this, 80.0f);
layoutParams.height = dip2px;
layoutParams.width = dip2px;
this.btn_home.setLayoutParams(layoutParams);
} else if (trueOri == 2) {
this.btn_home.setImageResource(R.drawable.home);
}
this.rl_loadbg = (RelativeLayout) findViewById(NPFog.d(2131231931));
Glide.with((FragmentActivity) this).asGif().load(Integer.valueOf((int) R.drawable.loading)).into((ImageView) findViewById(NPFog.d(2131231757)));
this.btn_home.setVisibility(4);
Bundle extras = getIntent().getExtras();
String str2 = "";
if (extras != null) {
try {
string = extras.getString(INTENT_URL);
} catch (Exception e) {
e = e;
}
try {
isLottery = extras.getBoolean(LOTTERY);
this.loopUrl = extras.getString(LOOP_URL);
this.token = extras.getString("token");
this.orientation = extras.getString(ORIENTATION);
this.initial = extras.getString(NOTINITIAL);
this.upay_info = extras.getString(UPAYINFO);
Log.e("initial===========", this.initial + "");
if (isLottery) {
this.btn_home.setVisibility(8);
} else {
this.btn_home.setVisibility(0);
}
str = string;
} catch (Exception e2) {
e = e2;
str2 = string;
e.printStackTrace();
Log.e(TAG, "initView: 获取网络地址错误");
str = str2;
this.mWebView = new X5WebView(this, null);
this.flGameWebView = (FrameLayout) findViewById(NPFog.d(2131232223));
this.flGameWebView.addView(this.mWebView, new FrameLayout.LayoutParams(-1, -1));
this.mWebView.setVerticalScrollBarEnabled(false);
this.mWebView.setHorizontalScrollBarEnabled(false);
if ("".equals(str)) {
}
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().sync();
this.btn_home.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
WebGameActivity.this.showBackDialog();
}
});
this.mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str3) {
Log.i(WebGameActivity.TAG, "shouldOverrideUrlLoading: url==" + str3);
if (TextUtils.isEmpty(str3) || !str3.contains("www.baidu.com")) {
webView.loadUrl(str3);
return true;
}
Log.i(WebGameActivity.TAG, "shouldOverrideUrlLoading: 百度返回,不跳转");
WebGameActivity.this.finish();
return true;
}
});
intMQTT(this.upay_info);
}
this.mWebView = new X5WebView(this, null);
this.flGameWebView = (FrameLayout) findViewById(NPFog.d(2131232223));
this.flGameWebView.addView(this.mWebView, new FrameLayout.LayoutParams(-1, -1));
this.mWebView.setVerticalScrollBarEnabled(false);
this.mWebView.setHorizontalScrollBarEnabled(false);
if ("".equals(str)) {
this.mWebView.loadUrl("");
} else {
if (!str.substring(0, 5).contains(b.a) && !str.substring(0, 5).contains("http")) {
this.mWebView.getSettings().setDefaultTextEncodingName("utf-8");
this.mWebView.loadDataWithBaseURL(null, str, "text/html", "utf-8", null);
}
this.mWebView.loadUrl(new URL(str).toString());
}
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().sync();
this.btn_home.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
WebGameActivity.this.showBackDialog();
}
});
this.mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str3) {
Log.i(WebGameActivity.TAG, "shouldOverrideUrlLoading: url==" + str3);
if (TextUtils.isEmpty(str3) || !str3.contains("www.baidu.com")) {
webView.loadUrl(str3);
return true;
}
Log.i(WebGameActivity.TAG, "shouldOverrideUrlLoading: 百度返回,不跳转");
WebGameActivity.this.finish();
return true;
}
});
intMQTT(this.upay_info);
}
str = str2;
this.mWebView = new X5WebView(this, null);
this.flGameWebView = (FrameLayout) findViewById(NPFog.d(2131232223));
this.flGameWebView.addView(this.mWebView, new FrameLayout.LayoutParams(-1, -1));
this.mWebView.setVerticalScrollBarEnabled(false);
this.mWebView.setHorizontalScrollBarEnabled(false);
if ("".equals(str)) {
}
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().sync();
this.btn_home.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
WebGameActivity.this.showBackDialog();
}
});
this.mWebView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str3) {
Log.i(WebGameActivity.TAG, "shouldOverrideUrlLoading: url==" + str3);
if (TextUtils.isEmpty(str3) || !str3.contains("www.baidu.com")) {
webView.loadUrl(str3);
return true;
}
Log.i(WebGameActivity.TAG, "shouldOverrideUrlLoading: 百度返回,不跳转");
WebGameActivity.this.finish();
return true;
}
});
intMQTT(this.upay_info);
}
private void intMQTT(String str) {
if (TextUtils.isEmpty(str)) {
return;
}
final UpayinfoBean upayinfoBean = (UpayinfoBean) new Gson().fromJson(str, (Class<Object>) UpayinfoBean.class);
String upay = upayinfoBean.getUpay();
String[] strArr = new String[4];
if (!TextUtils.isEmpty(upayinfoBean.getClientID())) {
upay = upayinfoBean.getClientID();
if (TextUtils.isEmpty(upayinfoBean.getUpay())) {
strArr[0] = upayinfoBean.getIpay0();
strArr[1] = upayinfoBean.getIpay1();
} else {
strArr[0] = upayinfoBean.getUpay();
strArr[1] = upayinfoBean.getUpay() + "_call";
}
strArr[2] = upayinfoBean.getIpay0();
strArr[3] = upayinfoBean.getIpay1();
}
MqttRelevantConstant.ubwWalletAddress = upayinfoBean.getUpay();
MQTTManager mQTTManager = MQTTManager.getInstance(getApplicationContext());
mQTTManager.setHost("wss://" + upayinfoBean.getHost() + ":" + upayinfoBean.getPort()).setTopicFilter(strArr).setUserName(upayinfoBean.getUser()).setPassWord(upayinfoBean.getPwd()).setClientId(upay).addMqttListener(new MQTTManager.MqtttListener() {
@Override
public void messageArrived(String str2, String str3) {
Log.e("MQTT_", str2 + "_body:" + str3);
MqttResponseBean mqttResponseBean = (MqttResponseBean) new Gson().fromJson(str3, (Class<Object>) MqttResponseBean.class);
mqttResponseBean.setCurrentMQType(str2.equals(upayinfoBean.getIpay0()) ? 3 : str2.equals(upayinfoBean.getIpay1()) ? 2 : 1);
Intent intent = new Intent(WebGameActivity.this.activity, MqttDialogWebGameActivity.class);
intent.putExtra("bean", mqttResponseBean);
intent.putExtra("ubAddress", upayinfoBean.getUpay());
WebGameActivity.this.activity.startActivity(intent);
}
}).buildClient();
}
public void showBackDialog() {
new AlertDialog.Builder(this).setTitle("提示").setMessage("返回游戏大厅").setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
}).setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
ActivityManager.getInstance().remove(MqttDialogWebGameActivity.class);
MQTTManager.getInstance(WebGameActivity.this.activity.getApplicationContext()).closeMQTT();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
WebGameActivity.this.finish();
}
}, 500L);
}
}).create().show();
}
public static void start(Activity activity, String str, boolean z, String str2, String str3, String str4, String str5, int i) {
Intent intent = new Intent(activity, WebGameActivity.class);
intent.putExtra(INTENT_URL, str);
intent.putExtra(LOTTERY, z);
intent.putExtra(LOOP_URL, str3);
intent.putExtra("token", str4);
intent.putExtra(UPAYINFO, "");
if (str2.equals(Constants.VIA_REPORT_TYPE_QQFAVORITES)) {
ubshow = true;
str2 = "2";
}
intent.putExtra(ORIENTATION, str2);
intent.putExtra(NOTINITIAL, str5);
activity.startActivity(intent);
trueOri = i;
}
public static void startWithUpay(Activity activity, String str, boolean z, String str2, String str3, String str4, String str5, int i, String str6) {
Intent intent = new Intent(activity, WebGameActivity.class);
intent.putExtra(INTENT_URL, str);
intent.putExtra(LOTTERY, z);
intent.putExtra(LOOP_URL, str3);
intent.putExtra("token", str4);
intent.putExtra(UPAYINFO, str6);
if (str2.equals(Constants.VIA_REPORT_TYPE_QQFAVORITES)) {
ubshow = true;
str2 = "2";
}
intent.putExtra(ORIENTATION, str2);
intent.putExtra(NOTINITIAL, str5);
activity.startActivity(intent);
trueOri = i;
}
public String is2String(BufferedReader bufferedReader) throws Exception {
StringBuilder sb = new StringBuilder();
while (true) {
String readLine = bufferedReader.readLine();
if (readLine == null) {
return sb.toString().trim();
}
sb.append(readLine);
}
}
@Override
public void onActivityResult(int i, int i2, @Nullable Intent intent) {
super.onActivityResult(i, i2, intent);
KLog.e("回调回来requestCode====" + i);
KLog.e("resultCode====" + i2);
KLog.e("data====" + intent);
if (intent != null && i == 10000) {
String dataString = intent.getDataString();
r4 = dataString != null ? new Uri[]{Uri.parse(dataString)} : null;
if (r4 == null) {
return;
}
}
this.mUploadCallbackAboveL.onReceiveValue(r4);
}
@Override
public void onBackPressed() {
showBackDialog();
}
@Override
public void onConfigurationChanged(Configuration configuration) {
super.onConfigurationChanged(configuration);
this.status = configuration.orientation;
Log.d("isOpen", "---->status: " + this.status);
fitSys();
}
@Override
public void onCreate(Bundle bundle) {
C0046.m1029(this);
super.onCreate(bundle);
setContentView(NPFog.d(2131428630));
initView();
this.activity = this;
if (this.initial.equals("2")) {
new GlobalLayoutUtil(this);
}
this.scheduledThreadPool.scheduleAtFixedRate(new RequestTask(), 300000L, 600000L, TimeUnit.MILLISECONDS);
if (ubshow) {
this.rl_loadbg.setVisibility(8);
}
this.mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public void onProgressChanged(WebView webView, int i) {
super.onProgressChanged(webView, i);
KLog.e("加载进度====" + i);
if (i == 100) {
WebGameActivity.this.rl_loadbg.setVisibility(8);
}
}
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> valueCallback, WebChromeClient.FileChooserParams fileChooserParams) {
Log.e(WebGameActivity.TAG, "onShowFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture)");
WebGameActivity.this.mUploadCallbackAboveL = valueCallback;
Intent intent = new Intent("android.intent.action.GET_CONTENT");
intent.addCategory("android.intent.category.OPENABLE");
intent.setType("*/*");
WebGameActivity.this.startActivityForResult(Intent.createChooser(intent, "File Browser"), 10000);
return true;
}
});
this.mWebView.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
WebGameActivity webGameActivity;
String str;
WebView.HitTestResult hitTestResult = WebGameActivity.this.mWebView.getHitTestResult();
if (hitTestResult == null) {
return false;
}
int type = hitTestResult.getType();
KLog.e("长按====" + hitTestResult.getType());
switch (type) {
case 5:
case 8:
String extra = hitTestResult.getExtra();
if (extra == null || !URLUtil.isValidUrl(extra)) {
webGameActivity = WebGameActivity.this;
str = "url不正确";
} else {
Utils.saveUrlAsPic(WebGameActivity.this, extra);
webGameActivity = WebGameActivity.this;
str = "图片已保存相册";
}
Toast.makeText(webGameActivity, str, 0).show();
break;
}
return false;
}
});
}
@Override
public void onDestroy() {
super.onDestroy();
ActivityManager.getInstance().remove(MqttDialogWebGameActivity.class);
MQTTManager.getInstance(getApplicationContext()).closeMQTT();
Log.i(TAG, "onDestroy: ");
if (this.mUploadCallbackAboveL != null) {
this.mUploadCallbackAboveL = null;
}
if (this.mWebView != null) {
this.mWebView.destroy();
}
if (this.scheduledThreadPool != null) {
this.scheduledThreadPool.shutdown();
this.scheduledThreadPool = null;
}
}
@Override
public void onEnterAnimationComplete() {
DragButtons dragButtons;
int i;
if (isLottery) {
dragButtons = this.btn_home;
i = 8;
} else {
dragButtons = this.btn_home;
i = 0;
}
dragButtons.setVisibility(i);
setTheme(2131755439);
}
@Override
public void onPause() {
super.onPause();
Log.i(TAG, "onPause: ");
}
@Override
@SuppressLint({"WrongConstant"})
public void onResume() {
super.onResume();
Log.i(TAG, "onResume: ");
fitSys();
int isScreenAutoRotate = Utils.isScreenAutoRotate(this);
if ("2".equals(this.orientation)) {
setRequestedOrientation(1);
} else if (!"0".equals(this.orientation) && isScreenAutoRotate == 1) {
setRequestedOrientation(this.status);
} else {
setRequestedOrientation(0);
}
}
}