Commit 21199278 by pye52

Merge branch 'new_master' into new_for_phone

# Conflicts:
#	app/src/main/java/com/bgycc/smartcanteen/MainActivity.java
parents 41669ad6 fcdb977b
...@@ -63,7 +63,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -63,7 +63,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private CommandViewModel commandViewModel; private CommandViewModel commandViewModel;
private String deviceSN; private String deviceSN;
// TODO 可用ViewStub取代
private ViewStub debugVs; private ViewStub debugVs;
private LinearLayout debugLayout; private LinearLayout debugLayout;
private LinearLayout settingLayout; private LinearLayout settingLayout;
...@@ -129,7 +128,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -129,7 +128,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
initQRCodeUI(); initQRCodeUI();
SCWebSocketClient.getInstance().getConnectStateEvent().observe(this, event -> { SCWebSocketClient.getInstance().getConnectStateEvent().observe(this, event -> {
if (debugVs != null) return; if (debugLayoutIsNotInflate()) return;
String networkType = NetworkUtils.getNetworkType(this); String networkType = NetworkUtils.getNetworkType(this);
String msg; String msg;
switch (event.getState()) { switch (event.getState()) {
...@@ -168,7 +167,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -168,7 +167,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
String log = "支付进度: " + time + " - " + event.getMessage(); String log = "支付进度: " + time + " - " + event.getMessage();
LogUtils.file(TAG, log); LogUtils.file(TAG, log);
if (debugVs != null) return; if (debugLayoutIsNotInflate()) return;
sendText.setText(log); sendText.setText(log);
break; break;
case PayOnlineState.SUCCESS: case PayOnlineState.SUCCESS:
...@@ -221,7 +220,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -221,7 +220,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
} }
} }
if (debugVs != null) return; if (debugLayoutIsNotInflate()) return;
String msg; String msg;
if (data != null) { if (data != null) {
msg = String.format(Locale.getDefault(), getString(R.string.qrcode_text), data.getPayCode()); msg = String.format(Locale.getDefault(), getString(R.string.qrcode_text), data.getPayCode());
...@@ -270,8 +269,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -270,8 +269,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
SCWebSocketClient.getInstance().tryConnect(); SCWebSocketClient.getInstance().tryConnect();
} }
private boolean debugLayoutIsNotInflate() {
return debugVs != null;
}
private void toggleDebugLayout() { private void toggleDebugLayout() {
if (debugVs != null) { if (debugLayoutIsNotInflate()) {
inflateDebugLayout(); inflateDebugLayout();
} else { } else {
if (debugLayout.getVisibility() == View.GONE) { if (debugLayout.getVisibility() == View.GONE) {
...@@ -298,7 +301,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -298,7 +301,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
String successLog = "支付成功: " + successTime + " - " + successMessage; String successLog = "支付成功: " + successTime + " - " + successMessage;
LogUtils.file(TAG, successLog); LogUtils.file(TAG, successLog);
if (debugVs != null) return; if (debugLayoutIsNotInflate()) return;
recText.setText(successLog); recText.setText(successLog);
} }
...@@ -316,7 +319,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe ...@@ -316,7 +319,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
String failedLog = "支付失败: " + failedTime + " - " + failedMessage; String failedLog = "支付失败: " + failedTime + " - " + failedMessage;
LogUtils.file(TAG, failedLog); LogUtils.file(TAG, failedLog);
if (debugVs != null) return; if (debugLayoutIsNotInflate()) return;
recText.setText(failedLog); recText.setText(failedLog);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment