|
@@ -6,6 +6,7 @@ import android.view.KeyEvent;
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
+import com.bun.miitmdid.core.MdidSdkHelper;
|
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
import com.sheep.gamegroup.absBase.BaseActivity;
|
|
|
import com.sheep.gamegroup.model.entity.DialogConfig;
|
|
import com.sheep.gamegroup.model.entity.DialogConfig;
|
|
|
import com.sheep.gamegroup.model.entity.XianWanEntity;
|
|
import com.sheep.gamegroup.model.entity.XianWanEntity;
|
|
@@ -64,9 +65,9 @@ public class ActXianWanWeb extends BaseActivity {
|
|
|
.setTitleFinish(this, new View.OnClickListener() {
|
|
.setTitleFinish(this, new View.OnClickListener() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
|
- if(mWebView.canGoBack()){
|
|
|
|
|
|
|
+ if (mWebView.canGoBack()) {
|
|
|
mWebView.goBack();
|
|
mWebView.goBack();
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
activity.finish();
|
|
activity.finish();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -79,7 +80,7 @@ public class ActXianWanWeb extends BaseActivity {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
tv_next.setVisibility(View.GONE);
|
|
tv_next.setVisibility(View.GONE);
|
|
|
- if(xianWanEntity == null){
|
|
|
|
|
|
|
+ if (xianWanEntity == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -93,12 +94,12 @@ public class ActXianWanWeb extends BaseActivity {
|
|
|
|
|
|
|
|
private void initJsData() {
|
|
private void initJsData() {
|
|
|
OkHttpUtils.get()
|
|
OkHttpUtils.get()
|
|
|
- .url(xianWanEntity.getJsUrl()+"")
|
|
|
|
|
|
|
+ .url(xianWanEntity.getJsUrl() + "")
|
|
|
.build()
|
|
.build()
|
|
|
.execute(new StringCallback() {
|
|
.execute(new StringCallback() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onError(Call call, Exception e, int id) {
|
|
public void onError(Call call, Exception e, int id) {
|
|
|
- G.showToast( R.string.service_data_error);
|
|
|
|
|
|
|
+ G.showToast(R.string.service_data_error);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -112,7 +113,7 @@ public class ActXianWanWeb extends BaseActivity {
|
|
|
@Override
|
|
@Override
|
|
|
protected void onDestroy() {
|
|
protected void onDestroy() {
|
|
|
super.onDestroy();
|
|
super.onDestroy();
|
|
|
- if(mWebView != null) {
|
|
|
|
|
|
|
+ if (mWebView != null) {
|
|
|
mWebView.setVisibility(View.GONE);
|
|
mWebView.setVisibility(View.GONE);
|
|
|
mWebView.removeAllViews();
|
|
mWebView.removeAllViews();
|
|
|
mWebView.destroy();
|
|
mWebView.destroy();
|
|
@@ -120,10 +121,10 @@ public class ActXianWanWeb extends BaseActivity {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void loadUrl() {
|
|
private void loadUrl() {
|
|
|
- if(mWebView == null){
|
|
|
|
|
|
|
+ if (mWebView == null) {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- mWebView.setWebChromeClient(new WebChromeClient(){
|
|
|
|
|
|
|
+ mWebView.setWebChromeClient(new WebChromeClient() {
|
|
|
@Override
|
|
@Override
|
|
|
public void onReceivedTitle(WebView view, String title) {
|
|
public void onReceivedTitle(WebView view, String title) {
|
|
|
super.onReceivedTitle(view, title);
|
|
super.onReceivedTitle(view, title);
|
|
@@ -142,6 +143,7 @@ public class ActXianWanWeb extends BaseActivity {
|
|
|
}
|
|
}
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void onPageFinished(WebView view, String url) {
|
|
public void onPageFinished(WebView view, String url) {
|
|
|
super.onPageFinished(view, url);
|
|
super.onPageFinished(view, url);
|
|
@@ -151,61 +153,66 @@ public class ActXianWanWeb extends BaseActivity {
|
|
|
});
|
|
});
|
|
|
webViewSettings.setJavaScriptEnabled(true);
|
|
webViewSettings.setJavaScriptEnabled(true);
|
|
|
mWebView.addJavascriptInterface(new WebViewJs(this, mWebView), "android");
|
|
mWebView.addJavascriptInterface(new WebViewJs(this, mWebView), "android");
|
|
|
- mWebView.loadUrl(assemblyData());
|
|
|
|
|
|
|
|
|
|
- mWebView.setOnKeyListener(new View.OnKeyListener() {
|
|
|
|
|
- @Override
|
|
|
|
|
- public boolean onKey(View v, int keyCode, KeyEvent event) {
|
|
|
|
|
- if(keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()){
|
|
|
|
|
- mWebView.goBack();
|
|
|
|
|
- return true;
|
|
|
|
|
- }
|
|
|
|
|
- return false;
|
|
|
|
|
|
|
+ mWebView.setOnKeyListener((v, keyCode, event) -> {
|
|
|
|
|
+ if (keyCode == KeyEvent.KEYCODE_BACK && mWebView.canGoBack()) {
|
|
|
|
|
+ mWebView.goBack();
|
|
|
|
|
+ return true;
|
|
|
}
|
|
}
|
|
|
|
|
+ return false;
|
|
|
});
|
|
});
|
|
|
|
|
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.P) {
|
|
|
|
|
+ int ret = MdidSdkHelper.InitSdk(this, true, (isSupport, supplier) -> {
|
|
|
|
|
+ mWebView.loadUrl(assemblyData(supplier.getOAID()));
|
|
|
|
|
+ });
|
|
|
|
|
+ LogUtil.logI("get oaid result:" + ret);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ mWebView.loadUrl(assemblyData(""));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public void onBackPressed() {
|
|
public void onBackPressed() {
|
|
|
- if(mWebView != null && mWebView.canGoBack()){
|
|
|
|
|
|
|
+ if (mWebView != null && mWebView.canGoBack()) {
|
|
|
mWebView.goBack();
|
|
mWebView.goBack();
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
this.finish();
|
|
this.finish();
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
// 注入js函数监听
|
|
// 注入js函数监听
|
|
|
public void loadJs() {
|
|
public void loadJs() {
|
|
|
ViewUtil.loadJs(mWebView, getJs());
|
|
ViewUtil.loadJs(mWebView, getJs());
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
private String js;
|
|
private String js;
|
|
|
- private String getJs(){
|
|
|
|
|
|
|
+
|
|
|
|
|
+ private String getJs() {
|
|
|
return js;
|
|
return js;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 组装数据
|
|
* 组装数据
|
|
|
- * @return
|
|
|
|
|
- * https://h5.51xianwan.com/try/try_list_plus_browser.aspx?ptype=2&deviceid=8883300242xw&appid=1010&appsign=1000&keycode=07688c3e9a783b245e59311
|
|
|
|
|
|
|
+ *
|
|
|
|
|
+ * @return https://h5.51xianwan.com/try/try_list_plus_browser.aspx?ptype=2&deviceid=8883300242xw&appid=1010&appsign=1000&keycode=07688c3e9a783b245e59311
|
|
|
*/
|
|
*/
|
|
|
- private String assemblyData(){
|
|
|
|
|
|
|
+ private String assemblyData(String oaid) {
|
|
|
String baseUrl = xianWanEntity.getUrl();
|
|
String baseUrl = xianWanEntity.getUrl();
|
|
|
int pType = 2;
|
|
int pType = 2;
|
|
|
String deviceId = DeviceUtil.getDeviceId(activity);
|
|
String deviceId = DeviceUtil.getDeviceId(activity);
|
|
|
- String appId = xianWanEntity.getAndroid().getAppid();
|
|
|
|
|
|
|
+ String appId = xianWanEntity.getAndroid().getAppid();
|
|
|
String userId = DataUtil.getInstance().getUserId();
|
|
String userId = DataUtil.getInstance().getUserId();
|
|
|
- String msaoaid = "";
|
|
|
|
|
int versionCode = Build.VERSION.SDK_INT;
|
|
int versionCode = Build.VERSION.SDK_INT;
|
|
|
String appSecret = xianWanEntity.getAndroid().getAppsecret();
|
|
String appSecret = xianWanEntity.getAndroid().getAppsecret();
|
|
|
String keyCodeBefore = String.format(Locale.CHINA, "%s%s%s%d%d%s%s",
|
|
String keyCodeBefore = String.format(Locale.CHINA, "%s%s%s%d%d%s%s",
|
|
|
appId,
|
|
appId,
|
|
|
deviceId,
|
|
deviceId,
|
|
|
- msaoaid,
|
|
|
|
|
|
|
+ oaid,
|
|
|
versionCode,
|
|
versionCode,
|
|
|
pType,
|
|
pType,
|
|
|
userId,
|
|
userId,
|
|
|
appSecret);
|
|
appSecret);
|
|
|
String keyCode = CommonUtil.getInstance().encrypt2Md5(keyCodeBefore);
|
|
String keyCode = CommonUtil.getInstance().encrypt2Md5(keyCodeBefore);
|
|
|
- LogUtil.logI("Get xianwan params: " + keyCodeBefore);
|
|
|
|
|
return String.format(Locale.CHINA, "%s?ptype=%d&deviceid=%s&appid=%s&appsign=%s&keycode=%s&androidosv=%d&msaoaid=%s",
|
|
return String.format(Locale.CHINA, "%s?ptype=%d&deviceid=%s&appid=%s&appsign=%s&keycode=%s&androidosv=%d&msaoaid=%s",
|
|
|
baseUrl,
|
|
baseUrl,
|
|
|
pType,
|
|
pType,
|
|
@@ -214,6 +221,6 @@ public class ActXianWanWeb extends BaseActivity {
|
|
|
userId,
|
|
userId,
|
|
|
keyCode,
|
|
keyCode,
|
|
|
versionCode,
|
|
versionCode,
|
|
|
- msaoaid);
|
|
|
|
|
|
|
+ oaid);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|