refactor(app): 优化 ReadCardActivity 中的时间延迟处理

- 使用 handler.postDelayed 替代 Thread.sleep 方法,提高 UI 响应性
- 在停止交易成功后添加延迟完成逻辑,提升用户体验
- 优化蓝牙设备断开连接和资源释放流程
This commit is contained in:
2025-07-07 18:05:45 +08:00
parent bb1c67ed43
commit 92088771f6
@@ -119,12 +119,7 @@ public class ReadCardActivity extends AppCompatActivity {
public void connected() {
isConnected = true;
Log.d(TAG, "connected1==========");
try {
Thread.sleep(200);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
beginReadCard();
handler.postDelayed(ReadCardActivity.this::beginReadCard,1000);
}
@Override
@@ -597,7 +592,7 @@ public class ReadCardActivity extends AppCompatActivity {
@Override
public void onStopTradeSuccess() {
Log.e(TAG, "onStopTradeSuccess");
finish();
handler.postDelayed(ReadCardActivity.this::finish,1000);
}
@Override
@@ -644,8 +639,11 @@ public class ReadCardActivity extends AppCompatActivity {
if (mBluetoothController != null) {
Log.d(TAG,"释放mBluetoothController====");
mBluetoothController.scanLeDevice(false);
mBluetoothController.disConnect();
mBluetoothController.close();
// mBluetoothController.unRegisterConnectReceiver( this);
mBluetoothController.unRegisterReceiver();
// mBluetoothController.release();
mBluetoothController = null;
}
if (executorService != null && !executorService.isShutdown()) {