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
private CommandViewModel commandViewModel;
private String deviceSN;
// TODO 可用ViewStub取代
private ViewStub debugVs;
private LinearLayout debugLayout;
private LinearLayout settingLayout;
......@@ -129,7 +128,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
initQRCodeUI();
SCWebSocketClient.getInstance().getConnectStateEvent().observe(this, event -> {
if (debugVs != null) return;
if (debugLayoutIsNotInflate()) return;
String networkType = NetworkUtils.getNetworkType(this);
String msg;
switch (event.getState()) {
......@@ -168,7 +167,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
String log = "支付进度: " + time + " - " + event.getMessage();
LogUtils.file(TAG, log);
if (debugVs != null) return;
if (debugLayoutIsNotInflate()) return;
sendText.setText(log);
break;
case PayOnlineState.SUCCESS:
......@@ -221,7 +220,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
}
if (debugVs != null) return;
if (debugLayoutIsNotInflate()) return;
String msg;
if (data != null) {
msg = String.format(Locale.getDefault(), getString(R.string.qrcode_text), data.getPayCode());
......@@ -270,8 +269,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
SCWebSocketClient.getInstance().tryConnect();
}
private boolean debugLayoutIsNotInflate() {
return debugVs != null;
}
private void toggleDebugLayout() {
if (debugVs != null) {
if (debugLayoutIsNotInflate()) {
inflateDebugLayout();
} else {
if (debugLayout.getVisibility() == View.GONE) {
......@@ -298,7 +301,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
String successLog = "支付成功: " + successTime + " - " + successMessage;
LogUtils.file(TAG, successLog);
if (debugVs != null) return;
if (debugLayoutIsNotInflate()) return;
recText.setText(successLog);
}
......@@ -316,7 +319,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
String failedLog = "支付失败: " + failedTime + " - " + failedMessage;
LogUtils.file(TAG, failedLog);
if (debugVs != null) return;
if (debugLayoutIsNotInflate()) return;
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