|
@@ -2,8 +2,11 @@ package com.example.informationkanban;
|
|
|
|
|
|
import android.content.Intent;
|
|
|
import android.os.Bundle;
|
|
|
+import android.os.CountDownTimer;
|
|
|
import android.text.TextUtils;
|
|
|
import android.util.Log;
|
|
|
+import android.widget.RadioButton;
|
|
|
+import android.widget.RadioGroup;
|
|
|
import android.widget.TextView;
|
|
|
import android.widget.Toast;
|
|
|
|
|
@@ -11,14 +14,21 @@ import androidx.appcompat.app.AppCompatActivity;
|
|
|
|
|
|
import com.blankj.utilcode.util.NetworkUtils;
|
|
|
import com.example.informationkanban.utils.GetInformationUtils;
|
|
|
+import com.example.informationkanban.utils.NetFunctionConfig;
|
|
|
|
|
|
public class InitActivity extends AppCompatActivity {
|
|
|
|
|
|
private TextView tvMac;
|
|
|
private TextView tvIP;
|
|
|
private TextView tvVersion;
|
|
|
+ private TextView tvTime;
|
|
|
+ private RadioGroup group;
|
|
|
+ private RadioButton btnWebview;
|
|
|
+ private RadioButton btnXwalk;
|
|
|
private boolean loop = true;
|
|
|
|
|
|
+ private CountDownTimer countDownTimer;
|
|
|
+
|
|
|
@Override
|
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
|
super.onCreate(savedInstanceState);
|
|
@@ -28,8 +38,51 @@ public class InitActivity extends AppCompatActivity {
|
|
|
tvIP = findViewById(R.id.textView_ip);
|
|
|
tvVersion = findViewById(R.id.textView_version);
|
|
|
tvVersion.setText("版本: V" + BuildConfig.VERSION_NAME);
|
|
|
+ tvTime = findViewById(R.id.textView_countdown);
|
|
|
+ group = findViewById(R.id.group_webview_type);
|
|
|
+ btnWebview = findViewById(R.id.radio_webview);
|
|
|
+ btnXwalk = findViewById(R.id.radio_xwalk);
|
|
|
+
|
|
|
+ //webview类型,默认为原生webview
|
|
|
+ if (NetFunctionConfig.getWebviewType() == 1) {
|
|
|
+ btnWebview.setChecked(true);
|
|
|
+ } else {
|
|
|
+ btnXwalk.setChecked(true);
|
|
|
+ }
|
|
|
+ group.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
|
|
+ @Override
|
|
|
+ public void onCheckedChanged(RadioGroup group, int checkedId) {
|
|
|
+ if (checkedId == R.id.radio_webview) {
|
|
|
+ NetFunctionConfig.setWebviewType(1);
|
|
|
+ } else {
|
|
|
+ NetFunctionConfig.setWebviewType(2);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
updateView();
|
|
|
|
|
|
+ initCountDownTimer();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initCountDownTimer() {
|
|
|
+ countDownTimer = new CountDownTimer(30000, 1000) {
|
|
|
+ @Override
|
|
|
+ public void onTick(long millisUntilFinished) {
|
|
|
+ long untilTime = millisUntilFinished/1000;
|
|
|
+ tvTime.setText("倒计时: " + untilTime + "秒");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFinish() {
|
|
|
+ checkNetwork();
|
|
|
+ }
|
|
|
+ };
|
|
|
+ countDownTimer.start();
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkNetwork() {
|
|
|
new Thread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
@@ -66,10 +119,21 @@ public class InitActivity extends AppCompatActivity {
|
|
|
runOnUiThread(new Runnable() {
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- Intent intent = new Intent(InitActivity.this, XwalkMainActivity.class);
|
|
|
+ Intent intent = new Intent();
|
|
|
+ if (NetFunctionConfig.getWebviewType() == 1) {
|
|
|
+ intent.setClass(getApplicationContext(), MainActivity.class);
|
|
|
+ } else {
|
|
|
+ intent.setClass(getApplicationContext(), XwalkMainActivity.class);
|
|
|
+ }
|
|
|
startActivity(intent);
|
|
|
finish();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onDestroy() {
|
|
|
+ super.onDestroy();
|
|
|
+ countDownTimer.cancel();
|
|
|
+ }
|
|
|
}
|