Commit 30b4d247 by pye52

1、优化代码结构及注释

2、优化后台切换支付提示语后的响应
parent e251b4e5
......@@ -89,6 +89,7 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
private TextView message;
private AudioManager audioManager;
private Gson gson;
private String idle_notice;
private WorkManager workManager;
private Handler handler = new Handler();
......@@ -107,9 +108,10 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
}
String host = SmartCanteenUtils.getMainWebSocketServerUrl(deviceSN, BuildConfig.VERSION_NAME);
LogUtils.d(TAG, "服务器地址: " + host);
gson = Injection.provideGson();
try {
URI uri = new URI(host);
SCWebSocketClient.init(uri, deviceSN, Injection.provideGson());
SCWebSocketClient.init(uri, deviceSN, gson);
} catch (URISyntaxException e) {
LogUtils.e(TAG, "服务器地址异常: " + e.getMessage(), e);
}
......@@ -247,11 +249,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
commandViewModel.commandFinish(command);
return;
}
// 修改主界面的提示语
if (CommandHelper.changedPaymentNotice(command)) {
Gson gson = Injection.provideGson();
try {
CommandNotice commandNotice = gson.fromJson(command.getData(), CommandNotice.class);
idle_notice = commandNotice.getData().getNotice();
message.setText(idle_notice);
} finally {
commandViewModel.commandFinish(command);
}
......@@ -343,10 +346,12 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
SCWebSocketClient.getInstance().tryConnect();
}
// 检查debug layout是否已初始化
private boolean debugLayoutIsNotInflate() {
return debugVs != null;
}
// 主界面显示模式切换: Debug <==> Release
private void toggleDebugLayout() {
if (debugLayoutIsNotInflate()) {
inflateDebugLayout();
......
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