|
@ -5,7 +5,9 @@ import android.content.Context; |
|
|
import android.content.Intent; |
|
|
import android.content.Intent; |
|
|
import android.content.IntentFilter; |
|
|
import android.content.IntentFilter; |
|
|
import android.os.Bundle; |
|
|
import android.os.Bundle; |
|
|
|
|
|
import android.os.Handler; |
|
|
import android.view.View; |
|
|
import android.view.View; |
|
|
|
|
|
import android.view.ViewGroup; |
|
|
import android.view.Window; |
|
|
import android.view.Window; |
|
|
import android.view.WindowManager; |
|
|
import android.view.WindowManager; |
|
|
import android.widget.Button; |
|
|
import android.widget.Button; |
|
@ -39,6 +41,12 @@ public class OrderVerificationResultActivity extends AppCompatActivity { |
|
|
private ScrollView scrollContent; |
|
|
private ScrollView scrollContent; |
|
|
private LinearLayout layoutContent; |
|
|
private LinearLayout layoutContent; |
|
|
|
|
|
|
|
|
|
|
|
// 倒计时相关 |
|
|
|
|
|
private TextView tvCountdown; |
|
|
|
|
|
private Handler countdownHandler; |
|
|
|
|
|
private Runnable countdownRunnable; |
|
|
|
|
|
private int countdownSeconds = 5; // 5秒倒计时 |
|
|
|
|
|
|
|
|
// 订单数据 |
|
|
// 订单数据 |
|
|
private int verificationType; // 1-验证码验证, 2-人脸验证, 3-扫码验证, 4-扫码器验证 |
|
|
private int verificationType; // 1-验证码验证, 2-人脸验证, 3-扫码验证, 4-扫码器验证 |
|
|
private int orderType; // 订单类型:0-场次, 1-人次, 3-年月卡, 5-课程 |
|
|
private int orderType; // 订单类型:0-场次, 1-人次, 3-年月卡, 5-课程 |
|
@ -91,6 +99,17 @@ public class OrderVerificationResultActivity extends AppCompatActivity { |
|
|
tvMessage = findViewById(R.id.tv_message); |
|
|
tvMessage = findViewById(R.id.tv_message); |
|
|
scrollContent = findViewById(R.id.scroll_content); |
|
|
scrollContent = findViewById(R.id.scroll_content); |
|
|
layoutContent = findViewById(R.id.layout_content); |
|
|
layoutContent = findViewById(R.id.layout_content); |
|
|
|
|
|
|
|
|
|
|
|
// 初始化倒计时显示 |
|
|
|
|
|
tvCountdown = findViewById(R.id.tv_countdown); |
|
|
|
|
|
if (tvCountdown == null) { |
|
|
|
|
|
// 如果布局文件中没有倒计时文本,动态创建一个 |
|
|
|
|
|
tvCountdown = new TextView(this); |
|
|
|
|
|
tvCountdown.setTextSize(16); |
|
|
|
|
|
tvCountdown.setTextColor(getResources().getColor(android.R.color.darker_gray)); |
|
|
|
|
|
tvCountdown.setGravity(android.view.Gravity.CENTER); |
|
|
|
|
|
tvCountdown.setPadding(0, 20, 0, 20); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private void getIntentData() { |
|
|
private void getIntentData() { |
|
@ -213,8 +232,19 @@ public class OrderVerificationResultActivity extends AppCompatActivity { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 隐藏关闭按钮和确认按钮 |
|
|
|
|
|
if (btnClose != null) { |
|
|
|
|
|
btnClose.setVisibility(View.GONE); |
|
|
|
|
|
} |
|
|
|
|
|
if (btnConfirm != null) { |
|
|
|
|
|
btnConfirm.setVisibility(View.GONE); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 根据订单类型显示不同的内容 |
|
|
// 根据订单类型显示不同的内容 |
|
|
buildOrderTypeSpecificContent(); |
|
|
buildOrderTypeSpecificContent(); |
|
|
|
|
|
|
|
|
|
|
|
// 启动倒计时 |
|
|
|
|
|
startCountdown(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -590,6 +620,9 @@ public class OrderVerificationResultActivity extends AppCompatActivity { |
|
|
protected void onDestroy() { |
|
|
protected void onDestroy() { |
|
|
super.onDestroy(); |
|
|
super.onDestroy(); |
|
|
|
|
|
|
|
|
|
|
|
// 停止倒计时 |
|
|
|
|
|
stopCountdown(); |
|
|
|
|
|
|
|
|
// 恢复摄像头预览 |
|
|
// 恢复摄像头预览 |
|
|
resumeCameraPreview(); |
|
|
resumeCameraPreview(); |
|
|
|
|
|
|
|
@ -602,7 +635,86 @@ public class OrderVerificationResultActivity extends AppCompatActivity { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
LogManager.logInfo(TAG, "订单核销结果Activity已销毁"); |
|
|
|
|
|
|
|
|
LogManager.logInfo(TAG, "订单核销结果页面已销毁,摄像头已恢复"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 启动倒计时 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void startCountdown() { |
|
|
|
|
|
if (countdownHandler == null) { |
|
|
|
|
|
countdownHandler = new Handler(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 在布局中添加倒计时显示 |
|
|
|
|
|
addCountdownToLayout(); |
|
|
|
|
|
|
|
|
|
|
|
countdownRunnable = new Runnable() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void run() { |
|
|
|
|
|
if (countdownSeconds > 0) { |
|
|
|
|
|
updateCountdownDisplay(); |
|
|
|
|
|
countdownSeconds--; |
|
|
|
|
|
countdownHandler.postDelayed(this, 1000); // 1秒后再次执行 |
|
|
|
|
|
} else { |
|
|
|
|
|
// 倒计时结束,关闭页面 |
|
|
|
|
|
LogManager.logInfo(TAG, "倒计时结束,自动关闭核销结果页面"); |
|
|
|
|
|
finish(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
countdownHandler.post(countdownRunnable); |
|
|
|
|
|
LogManager.logInfo(TAG, "启动核销结果页面倒计时," + countdownSeconds + "秒后自动关闭"); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 在布局中添加倒计时显示 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void addCountdownToLayout() { |
|
|
|
|
|
try { |
|
|
|
|
|
// 查找主布局容器 |
|
|
|
|
|
ViewGroup mainLayout = findViewById(R.id.main_content); |
|
|
|
|
|
if (mainLayout == null) { |
|
|
|
|
|
// 如果找不到,尝试使用根布局 |
|
|
|
|
|
mainLayout = (ViewGroup) findViewById(android.R.id.content); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (mainLayout != null && tvCountdown != null) { |
|
|
|
|
|
// 设置倒计时的布局参数 |
|
|
|
|
|
ViewGroup.LayoutParams params = new ViewGroup.LayoutParams( |
|
|
|
|
|
ViewGroup.LayoutParams.MATCH_PARENT, |
|
|
|
|
|
ViewGroup.LayoutParams.WRAP_CONTENT |
|
|
|
|
|
); |
|
|
|
|
|
tvCountdown.setLayoutParams(params); |
|
|
|
|
|
|
|
|
|
|
|
// 将倒计时文本添加到布局中 |
|
|
|
|
|
mainLayout.addView(tvCountdown); |
|
|
|
|
|
LogManager.logInfo(TAG, "倒计时显示已添加到布局中"); |
|
|
|
|
|
} |
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
LogManager.logError(TAG, "添加倒计时显示失败", e); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 更新倒计时显示 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void updateCountdownDisplay() { |
|
|
|
|
|
if (tvCountdown != null) { |
|
|
|
|
|
tvCountdown.setText("页面将在 " + countdownSeconds + " 秒后自动关闭"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 停止倒计时 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void stopCountdown() { |
|
|
|
|
|
if (countdownHandler != null && countdownRunnable != null) { |
|
|
|
|
|
countdownHandler.removeCallbacks(countdownRunnable); |
|
|
|
|
|
countdownRunnable = null; |
|
|
|
|
|
LogManager.logInfo(TAG, "倒计时已停止"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|