|
1
|
-package com.qiwan.gamebox;
|
1
|
+package com.qw7277.game;
|
|
2
|
|
2
|
|
|
3
|
import android.app.Activity;
|
3
|
import android.app.Activity;
|
|
|
|
4
|
+import android.content.Context;
|
|
4
|
import android.graphics.Color;
|
5
|
import android.graphics.Color;
|
|
5
|
import android.os.Build;
|
6
|
import android.os.Build;
|
|
6
|
import android.os.Bundle;
|
7
|
import android.os.Bundle;
|
|
|
|
8
|
+import android.text.TextUtils;
|
|
|
|
9
|
+import android.util.Log;
|
|
7
|
import android.view.WindowManager;
|
10
|
import android.view.WindowManager;
|
|
8
|
import android.webkit.WebSettings;
|
11
|
import android.webkit.WebSettings;
|
|
9
|
import android.webkit.WebView;
|
12
|
import android.webkit.WebView;
|
|
10
|
import android.widget.LinearLayout;
|
13
|
import android.widget.LinearLayout;
|
|
11
|
import android.widget.Toast;
|
14
|
import android.widget.Toast;
|
|
|
|
15
|
+import com.qw7277.game.util.AppUtils;
|
|
12
|
|
16
|
|
|
13
|
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
17
|
import com.readystatesoftware.systembartint.SystemBarTintManager;
|
|
14
|
|
18
|
|
|
15
|
public class MainActivity extends Activity {
|
19
|
public class MainActivity extends Activity {
|
|
|
|
20
|
+ private Context mContext;
|
|
16
|
private LinearLayout mLlRoot;
|
21
|
private LinearLayout mLlRoot;
|
|
17
|
private WebView mWebView;
|
22
|
private WebView mWebView;
|
|
18
|
private SystemBarTintManager mTintManager;
|
23
|
private SystemBarTintManager mTintManager;
|
|
19
|
private String mUrl = "https://cdn.kky.cn/yxhz/index.html#/home";
|
24
|
private String mUrl = "https://cdn.kky.cn/yxhz/index.html#/home";
|
|
|
|
25
|
+ private String mParams="";
|
|
20
|
|
26
|
|
|
21
|
@Override
|
27
|
@Override
|
|
22
|
protected void onCreate(Bundle savedInstanceState) {
|
28
|
protected void onCreate(Bundle savedInstanceState) {
|
|
23
|
super.onCreate(savedInstanceState);
|
29
|
super.onCreate(savedInstanceState);
|
|
|
|
30
|
+ mContext = this;
|
|
24
|
mTintManager = new SystemBarTintManager(this);
|
31
|
mTintManager = new SystemBarTintManager(this);
|
|
25
|
mTintManager.setStatusBarTintEnabled(false);
|
32
|
mTintManager.setStatusBarTintEnabled(false);
|
|
26
|
mTintManager.setNavigationBarTintEnabled(true);
|
33
|
mTintManager.setNavigationBarTintEnabled(true);
|
|
@@ -36,13 +43,13 @@ public class MainActivity extends Activity { |
|
@@ -36,13 +43,13 @@ public class MainActivity extends Activity { |
|
36
|
initView();
|
43
|
initView();
|
|
37
|
initWebView();
|
44
|
initWebView();
|
|
38
|
initData();
|
45
|
initData();
|
|
39
|
-
|
|
|
|
40
|
- mWebView.loadUrl(mUrl);
|
46
|
+ Log.d("ZhenWan", mUrl+"?"+mParams);
|
|
|
|
47
|
+ mWebView.loadUrl(mUrl+"?"+mParams);
|
|
41
|
}
|
48
|
}
|
|
42
|
|
49
|
|
|
43
|
private void initView() {
|
50
|
private void initView() {
|
|
44
|
mLlRoot = findViewById(R.id.ll_root);
|
51
|
mLlRoot = findViewById(R.id.ll_root);
|
|
45
|
- mLlRoot.setPadding(0, mTintManager.getConfig().getStatusBarHeight(), 0, mTintManager.getConfig().getNavigationBarHeight()+20);
|
52
|
+ mLlRoot.setPadding(0, mTintManager.getConfig().getStatusBarHeight(), 0, mTintManager.getConfig().getNavigationBarHeight() + 20);
|
|
46
|
mWebView = findViewById(R.id.webview);
|
53
|
mWebView = findViewById(R.id.webview);
|
|
47
|
}
|
54
|
}
|
|
48
|
|
55
|
|
|
@@ -58,21 +65,21 @@ public class MainActivity extends Activity { |
|
@@ -58,21 +65,21 @@ public class MainActivity extends Activity { |
|
58
|
|
65
|
|
|
59
|
private void initData() {
|
66
|
private void initData() {
|
|
60
|
Bundle extras = getIntent().getExtras();
|
67
|
Bundle extras = getIntent().getExtras();
|
|
61
|
- if (extras != null) {
|
|
|
|
62
|
- if (extras.containsKey("AuthParams")) {
|
|
|
|
63
|
- String parameterValue = extras.getString("AuthParams");
|
|
|
|
64
|
- mUrl = mUrl + "?" + parameterValue;
|
|
|
|
65
|
- }
|
68
|
+ if (extras != null && extras.containsKey("AuthParams")) {
|
|
|
|
69
|
+ mParams = extras.getString("AuthParams");
|
|
66
|
}
|
70
|
}
|
|
|
|
71
|
+ String cid = AppUtils.getLogicChannel(mContext, "sid");
|
|
|
|
72
|
+ mParams += (TextUtils.isEmpty(mParams) ? "" : "&") + "cid=" + cid;
|
|
67
|
}
|
73
|
}
|
|
68
|
|
74
|
|
|
69
|
private long mBackPressedTime = 0;
|
75
|
private long mBackPressedTime = 0;
|
|
|
|
76
|
+
|
|
70
|
@Override
|
77
|
@Override
|
|
71
|
public void onBackPressed() {
|
78
|
public void onBackPressed() {
|
|
72
|
if (mWebView != null && mWebView.canGoBack()) {
|
79
|
if (mWebView != null && mWebView.canGoBack()) {
|
|
73
|
mWebView.goBack();
|
80
|
mWebView.goBack();
|
|
74
|
} else {
|
81
|
} else {
|
|
75
|
- if(System.currentTimeMillis() - mBackPressedTime > 2000) {
|
82
|
+ if (System.currentTimeMillis() - mBackPressedTime > 2000) {
|
|
76
|
Toast.makeText(this, "再按一次退出应用", Toast.LENGTH_SHORT).show();
|
83
|
Toast.makeText(this, "再按一次退出应用", Toast.LENGTH_SHORT).show();
|
|
77
|
mBackPressedTime = System.currentTimeMillis();
|
84
|
mBackPressedTime = System.currentTimeMillis();
|
|
78
|
} else {
|
85
|
} else {
|