|
|
@ -100,16 +100,12 @@ public class OrderVerificationResultActivity extends AppCompatActivity { |
|
|
|
scrollContent = findViewById(R.id.scroll_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); |
|
|
|
} |
|
|
|
// 初始化倒计时显示(动态创建) |
|
|
|
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() { |
|
|
@ -673,24 +669,25 @@ public class OrderVerificationResultActivity extends AppCompatActivity { |
|
|
|
*/ |
|
|
|
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, "倒计时显示已添加到布局中"); |
|
|
|
// 查找布局容器,将倒计时添加到确认按钮下方 |
|
|
|
Button btnConfirm = findViewById(R.id.btn_confirm_result); |
|
|
|
if (btnConfirm != null && btnConfirm.getParent() instanceof ViewGroup) { |
|
|
|
ViewGroup parentLayout = (ViewGroup) btnConfirm.getParent(); |
|
|
|
|
|
|
|
if (tvCountdown != null && tvCountdown.getParent() == null) { |
|
|
|
// 设置倒计时的布局参数(RelativeLayout参数) |
|
|
|
android.widget.RelativeLayout.LayoutParams params = new android.widget.RelativeLayout.LayoutParams( |
|
|
|
android.widget.RelativeLayout.LayoutParams.MATCH_PARENT, |
|
|
|
android.widget.RelativeLayout.LayoutParams.WRAP_CONTENT |
|
|
|
); |
|
|
|
params.addRule(android.widget.RelativeLayout.BELOW, R.id.btn_confirm_result); |
|
|
|
params.setMargins(0, 20, 0, 0); |
|
|
|
tvCountdown.setLayoutParams(params); |
|
|
|
|
|
|
|
// 将倒计时文本添加到布局中 |
|
|
|
parentLayout.addView(tvCountdown); |
|
|
|
LogManager.logInfo(TAG, "倒计时显示已添加到布局中"); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
LogManager.logError(TAG, "添加倒计时显示失败", e); |
|
|
|