|
|
@ -650,7 +650,7 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
// 获取进入按钮并设置为加载状态 |
|
|
|
View buttonEnter = dialog.findViewById(R.id.buttonEnter); |
|
|
|
if (buttonEnter != null) { |
|
|
|
buttonEnter.setEnabled(false); |
|
|
|
// buttonEnter.setEnabled(false); |
|
|
|
TextView buttonText = (TextView) buttonEnter; |
|
|
|
buttonText.setText("正在进入..."); |
|
|
|
} |
|
|
@ -694,6 +694,11 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
* @param selectedPad 选中的Pad信息 |
|
|
|
*/ |
|
|
|
private void selectPadAndEnter(Dialog dialog, View buttonEnter, PadApiService.PadInfo selectedPad) { |
|
|
|
System.out.println("MainActivity: selectPadAndEnter called"); |
|
|
|
System.out.println("MainActivity: selectPadAndEnter thread: " + Thread.currentThread().getName()); |
|
|
|
android.util.Log.d("MainActivity", "selectPadAndEnter called"); |
|
|
|
android.util.Log.d("MainActivity", "selectPadAndEnter thread: " + Thread.currentThread().getName()); |
|
|
|
|
|
|
|
// 禁用按钮防止重复点击 |
|
|
|
buttonEnter.setEnabled(false); |
|
|
|
|
|
|
@ -702,7 +707,7 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
String originalText = buttonText.getText().toString(); |
|
|
|
|
|
|
|
// 显示loading文字 |
|
|
|
buttonText.setText("正在进入..."); |
|
|
|
buttonText.setText("已自动选择设备..."); |
|
|
|
|
|
|
|
// 获取所需参数 |
|
|
|
int hardwareId = selectedPad.getHardwareId(); |
|
|
@ -713,10 +718,18 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
android.util.Log.d("MainActivity", "=== 设备选择参数 ==="); |
|
|
|
android.util.Log.d("MainActivity", "Hardware ID: " + hardwareId); |
|
|
|
android.util.Log.d("MainActivity", "Device ID: " + deviceId); |
|
|
|
android.util.Log.d("MainActivity", "token: " + token); |
|
|
|
android.util.Log.d("MainActivity", "Token: " + (token != null && !token.isEmpty() ? "present" : "null")); |
|
|
|
android.util.Log.d("MainActivity", "Selected Pad Name: " + selectedPad.getHardwareName()); |
|
|
|
android.util.Log.d("MainActivity", "=========================="); |
|
|
|
|
|
|
|
// 添加更多调试信息 |
|
|
|
System.out.println("MainActivity: About to call selectPadWithFullResponse"); |
|
|
|
System.out.println("MainActivity: hardwareId: " + hardwareId); |
|
|
|
System.out.println("MainActivity: deviceId: " + deviceId); |
|
|
|
System.out.println("MainActivity: token: " + (token != null ? "present" : "null")); |
|
|
|
System.out.println("MainActivity: selectedPad: " + (selectedPad != null ? selectedPad.getHardwareName() : "null")); |
|
|
|
|
|
|
|
// 调用Pad选择API(使用新的API格式,支持完整API响应) |
|
|
|
NetworkUtils.selectPadWithFullResponse(hardwareId, deviceId, token, |
|
|
|
new CompleteApiResponseCallback<PadApiService.PadSelectResponse>() { |
|
|
@ -724,7 +737,7 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
public void onSuccessWithFullResponse(ApiResponse<PadApiService.PadSelectResponse> apiResponse) { |
|
|
|
// 选择成功,保存完整的API响应数据(code和data) |
|
|
|
showToast("进入 " + selectedPad.getHardwareName() + " 成功!"); |
|
|
|
|
|
|
|
android.util.Log.d("MainActivity", "=== onSuccessWithFullResponse ==="); |
|
|
|
// 保存完整的API响应数据到本地进行持久化保存 |
|
|
|
deviceSelectDataManager.saveCompleteApiResponse(apiResponse, selectedPad); |
|
|
|
|
|
|
@ -741,11 +754,38 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
android.util.Log.d("MainActivity", "API Message: " + deviceSelectDataManager.getApiResponseMessage()); |
|
|
|
android.util.Log.d("MainActivity", "==============================="); |
|
|
|
|
|
|
|
// 新增:调用获取小程序码接口 |
|
|
|
fetchAndSaveMiniQrcode(token, hardwareId, dialog, buttonEnter, buttonText, originalText); |
|
|
|
// 添加成功信息输出到日志 |
|
|
|
LogManager.logInfo("MainActivity", "设备选择成功: " + selectedPad.getHardwareName() + |
|
|
|
", Hardware ID: " + hardwareId + |
|
|
|
", API Code: " + apiResponse.getCode()); |
|
|
|
|
|
|
|
// 新增:调用获取小程序码接口和上传人脸小程序码接口 |
|
|
|
// 使用计数器确保两个请求都完成后再进入人脸识别界面 |
|
|
|
final int[] completedRequests = {0}; |
|
|
|
final Object lock = new Object(); |
|
|
|
|
|
|
|
// 完成一个请求的回调 |
|
|
|
Runnable onOneRequestComplete = new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
synchronized (lock) { |
|
|
|
completedRequests[0]++; |
|
|
|
android.util.Log.d("MainActivity", "请求完成计数: " + completedRequests[0] + "/2"); |
|
|
|
|
|
|
|
// 当两个请求都完成时,进入人脸识别界面 |
|
|
|
if (completedRequests[0] >= 2) { |
|
|
|
android.util.Log.d("MainActivity", "所有请求完成,准备进入人脸识别界面"); |
|
|
|
initializeFaceSDKIfNeeded(dialog, buttonEnter, buttonText, originalText); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
// 调用获取小程序码接口 |
|
|
|
fetchAndSaveMiniQrcode(token, hardwareId, dialog, buttonEnter, buttonText, originalText, onOneRequestComplete); |
|
|
|
|
|
|
|
// 新增:调用获取上传人脸小程序码接口 |
|
|
|
fetchAndSaveUploadFaceMiniQrcode(token, hardwareId, dialog, buttonEnter, buttonText, originalText); |
|
|
|
// 调用获取上传人脸小程序码接口 |
|
|
|
fetchAndSaveUploadFaceMiniQrcode(token, hardwareId, dialog, buttonEnter, buttonText, originalText, onOneRequestComplete); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -768,10 +808,24 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onException(Throwable throwable) { |
|
|
|
// 异常处理 |
|
|
|
showToast("选择设备时发生异常: " + throwable.getMessage()); |
|
|
|
|
|
|
|
// 恢复按钮状态 |
|
|
|
buttonEnter.setEnabled(true); |
|
|
|
buttonText.setText(originalText); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onComplete() { |
|
|
|
// 请求完成 |
|
|
|
android.util.Log.d("MainActivity", "设备选择请求完成"); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
System.out.println("MainActivity: selectPadWithFullResponse method called"); |
|
|
|
System.out.println("MainActivity: After calling selectPadWithFullResponse, thread: " + Thread.currentThread().getName()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -812,8 +866,11 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
android.util.Log.e("MainActivity", logMessage, e); |
|
|
|
LogManager.logError("FaceSDK", logMessage, e); |
|
|
|
|
|
|
|
// 发生异常时,直接进入人脸识别界面 |
|
|
|
enterFaceRecognitionActivity(dialog); |
|
|
|
// 即使发生异常,也要确保弹框被关闭 |
|
|
|
if (dialog != null && dialog.isShowing()) { |
|
|
|
dialog.dismiss(); |
|
|
|
} |
|
|
|
currentDialog = null; // 清除引用 |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -1199,8 +1256,9 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
* @param buttonEnter 进入按钮 |
|
|
|
* @param buttonText 按钮文字视图 |
|
|
|
* @param originalText 原始按钮文字 |
|
|
|
* @param onComplete 请求完成回调 |
|
|
|
*/ |
|
|
|
private void fetchAndSaveMiniQrcode(String token, int hardwareId, Dialog dialog, View buttonEnter, TextView buttonText, String originalText) { |
|
|
|
private void fetchAndSaveMiniQrcode(String token, int hardwareId, Dialog dialog, View buttonEnter, TextView buttonText, String originalText, Runnable onComplete) { |
|
|
|
// 调用获取小程序码接口 |
|
|
|
NetworkUtils.miniQrcode(token, hardwareId, new NetworkCallback<PadApiService.MiniQrcodeResponse>() { |
|
|
|
@Override |
|
|
@ -1228,8 +1286,10 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
LogManager.logWarning("MainActivity", "获取到的小程序码数据为空或URL为空"); |
|
|
|
} |
|
|
|
|
|
|
|
// 继续执行后续流程 |
|
|
|
initializeFaceSDKIfNeeded(dialog, buttonEnter, buttonText, originalText); |
|
|
|
// 执行完成回调 |
|
|
|
if (onComplete != null) { |
|
|
|
onComplete.run(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -1238,8 +1298,10 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
android.util.Log.e("MainActivity", "获取小程序码失败 - 错误码: " + errorCode + ", 错误信息: " + errorMessage); |
|
|
|
LogManager.logError("MainActivity", "获取小程序码失败 - 错误码: " + errorCode + ", 错误信息: " + errorMessage); |
|
|
|
|
|
|
|
// 即使获取小程序码失败,也继续执行后续流程 |
|
|
|
initializeFaceSDKIfNeeded(dialog, buttonEnter, buttonText, originalText); |
|
|
|
// 即使获取小程序码失败,也执行完成回调 |
|
|
|
if (onComplete != null) { |
|
|
|
onComplete.run(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -1257,8 +1319,9 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
* @param buttonEnter 进入按钮 |
|
|
|
* @param buttonText 按钮文字视图 |
|
|
|
* @param originalText 原始按钮文字 |
|
|
|
* @param onComplete 请求完成回调 |
|
|
|
*/ |
|
|
|
private void fetchAndSaveUploadFaceMiniQrcode(String token, int hardwareId, Dialog dialog, View buttonEnter, TextView buttonText, String originalText) { |
|
|
|
private void fetchAndSaveUploadFaceMiniQrcode(String token, int hardwareId, Dialog dialog, View buttonEnter, TextView buttonText, String originalText, Runnable onComplete) { |
|
|
|
// 获取品牌ID |
|
|
|
int brandId = loginDataManager.getBrandId(); |
|
|
|
|
|
|
@ -1266,8 +1329,10 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
if (brandId <= 0) { |
|
|
|
android.util.Log.e("MainActivity", "无效的品牌ID: " + brandId); |
|
|
|
LogManager.logError("MainActivity", "获取上传人脸小程序码失败 - 无效的品牌ID: " + brandId); |
|
|
|
// 即使获取上传人脸小程序码失败,也继续执行后续流程 |
|
|
|
initializeFaceSDKIfNeeded(dialog, buttonEnter, buttonText, originalText); |
|
|
|
// 即使获取上传人脸小程序码失败,也执行完成回调 |
|
|
|
if (onComplete != null) { |
|
|
|
onComplete.run(); |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
@ -1298,8 +1363,10 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
LogManager.logWarning("MainActivity", "获取到的上传人脸小程序码数据为空或URL为空"); |
|
|
|
} |
|
|
|
|
|
|
|
// 继续执行后续流程 |
|
|
|
initializeFaceSDKIfNeeded(dialog, buttonEnter, buttonText, originalText); |
|
|
|
// 执行完成回调 |
|
|
|
if (onComplete != null) { |
|
|
|
onComplete.run(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
@ -1308,8 +1375,10 @@ public class MainActivity extends AppCompatActivity { |
|
|
|
android.util.Log.e("MainActivity", "获取上传人脸小程序码失败 - 错误码: " + errorCode + ", 错误信息: " + errorMessage); |
|
|
|
LogManager.logError("MainActivity", "获取上传人脸小程序码失败 - 错误码: " + errorCode + ", 错误信息: " + errorMessage); |
|
|
|
|
|
|
|
// 即使获取上传人脸小程序码失败,也继续执行后续流程 |
|
|
|
initializeFaceSDKIfNeeded(dialog, buttonEnter, buttonText, originalText); |
|
|
|
// 即使获取上传人脸小程序码失败,也执行完成回调 |
|
|
|
if (onComplete != null) { |
|
|
|
onComplete.run(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|