4 changed files with 421 additions and 1 deletions
-
6app/src/main/AndroidManifest.xml
-
51app/src/main/java/com/ouxuan/oxface/OXFaceOnlineActivity.java
-
180app/src/main/java/com/ouxuan/oxface/orderOX/OrderVerificationResultActivity.java
-
185app/src/main/res/layout/activity_order_verification_result.xml
@ -0,0 +1,180 @@ |
|||||
|
package com.ouxuan.oxface.orderOX; |
||||
|
|
||||
|
import android.content.Intent; |
||||
|
import android.os.Bundle; |
||||
|
import android.view.View; |
||||
|
import android.view.Window; |
||||
|
import android.view.WindowManager; |
||||
|
import android.widget.Button; |
||||
|
import android.widget.ImageButton; |
||||
|
import android.widget.TextView; |
||||
|
import android.widget.Toast; |
||||
|
|
||||
|
import androidx.appcompat.app.AppCompatActivity; |
||||
|
|
||||
|
import com.ouxuan.oxface.R; |
||||
|
import com.ouxuan.oxface.utils.LogManager; |
||||
|
|
||||
|
/** |
||||
|
* 订单核销结果Activity |
||||
|
* 提供一个覆盖在视频流上的弹窗界面,用于显示订单核销结果 |
||||
|
*/ |
||||
|
public class OrderVerificationResultActivity extends AppCompatActivity { |
||||
|
|
||||
|
private static final String TAG = "OrderVerificationResultActivity"; |
||||
|
|
||||
|
private ImageButton btnClose; |
||||
|
private Button btnConfirm; |
||||
|
private TextView tvTitle, tvOrderNo, tvVerificationCode, tvOrderType, tvCardNo, tvStatus; |
||||
|
private String orderNo, verificationCode, orderType, cardNo, status; |
||||
|
private int verificationType; // 1-验证码验证, 4-扫码器验证 |
||||
|
|
||||
|
@Override |
||||
|
protected void onCreate(Bundle savedInstanceState) { |
||||
|
super.onCreate(savedInstanceState); |
||||
|
|
||||
|
// 设置无标题栏 |
||||
|
requestWindowFeature(Window.FEATURE_NO_TITLE); |
||||
|
|
||||
|
// 设置背景透明,实现弹窗效果 |
||||
|
getWindow().setBackgroundDrawableResource(android.R.color.transparent); |
||||
|
|
||||
|
setContentView(R.layout.activity_order_verification_result); |
||||
|
|
||||
|
// 设置窗口属性 |
||||
|
Window window = getWindow(); |
||||
|
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT); |
||||
|
window.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS, WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); |
||||
|
|
||||
|
initViews(); |
||||
|
getIntentData(); |
||||
|
updateUI(); |
||||
|
setupListeners(); |
||||
|
|
||||
|
// 暂停摄像头预览 |
||||
|
pauseCameraPreview(); |
||||
|
|
||||
|
LogManager.logInfo(TAG, "订单核销结果Activity启动成功"); |
||||
|
} |
||||
|
|
||||
|
private void initViews() { |
||||
|
// 初始化按钮 |
||||
|
btnClose = findViewById(R.id.btn_close_result); |
||||
|
btnConfirm = findViewById(R.id.btn_confirm_result); |
||||
|
|
||||
|
// 初始化文本视图 |
||||
|
tvTitle = findViewById(R.id.tv_result_title); |
||||
|
tvOrderNo = findViewById(R.id.tv_order_no); |
||||
|
tvVerificationCode = findViewById(R.id.tv_verification_code); |
||||
|
tvOrderType = findViewById(R.id.tv_order_type); |
||||
|
tvCardNo = findViewById(R.id.tv_card_no); |
||||
|
tvStatus = findViewById(R.id.tv_status); |
||||
|
} |
||||
|
|
||||
|
private void getIntentData() { |
||||
|
Intent intent = getIntent(); |
||||
|
if (intent != null) { |
||||
|
verificationType = intent.getIntExtra("verification_type", 1); |
||||
|
orderNo = intent.getStringExtra("order_no"); |
||||
|
verificationCode = intent.getStringExtra("verification_code"); |
||||
|
orderType = intent.getStringExtra("order_type"); |
||||
|
cardNo = intent.getStringExtra("card_no"); |
||||
|
status = intent.getStringExtra("status"); |
||||
|
} |
||||
|
|
||||
|
// 设置默认值 |
||||
|
if (orderNo == null) orderNo = ""; |
||||
|
if (verificationCode == null) verificationCode = ""; |
||||
|
if (orderType == null) orderType = ""; |
||||
|
if (cardNo == null) cardNo = ""; |
||||
|
if (status == null) status = "核销成功"; |
||||
|
} |
||||
|
|
||||
|
private void updateUI() { |
||||
|
// 根据验证类型设置标题 |
||||
|
if (verificationType == 1) { |
||||
|
tvTitle.setText("验证码核销结果"); |
||||
|
} else if (verificationType == 4) { |
||||
|
tvTitle.setText("扫码器核销结果"); |
||||
|
} else { |
||||
|
tvTitle.setText("订单核销结果"); |
||||
|
} |
||||
|
|
||||
|
// 更新UI内容 |
||||
|
tvOrderNo.setText(orderNo); |
||||
|
tvVerificationCode.setText(verificationCode); |
||||
|
tvOrderType.setText(orderType); |
||||
|
tvCardNo.setText(cardNo); |
||||
|
tvStatus.setText(status); |
||||
|
} |
||||
|
|
||||
|
private void setupListeners() { |
||||
|
// 确认按钮 |
||||
|
btnConfirm.setOnClickListener(new View.OnClickListener() { |
||||
|
@Override |
||||
|
public void onClick(View v) { |
||||
|
handleConfirm(); |
||||
|
} |
||||
|
}); |
||||
|
|
||||
|
// 关闭按钮 |
||||
|
btnClose.setOnClickListener(new View.OnClickListener() { |
||||
|
@Override |
||||
|
public void onClick(View v) { |
||||
|
finish(); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
|
private void handleConfirm() { |
||||
|
LogManager.logInfo(TAG, "用户确认订单核销结果"); |
||||
|
Toast.makeText(this, "订单核销完成", Toast.LENGTH_SHORT).show(); |
||||
|
finish(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 暂停摄像头预览 |
||||
|
* 通过发送广播通知OXFaceOnlineActivity暂停摄像头预览 |
||||
|
*/ |
||||
|
private void pauseCameraPreview() { |
||||
|
try { |
||||
|
// 发送广播通知OXFaceOnlineActivity暂停摄像头预览 |
||||
|
Intent intent = new Intent("com.ouxuan.oxface.ACTION_PAUSE_CAMERA"); |
||||
|
sendBroadcast(intent); |
||||
|
LogManager.logInfo(TAG, "已发送暂停摄像头预览广播"); |
||||
|
} catch (Exception e) { |
||||
|
LogManager.logError(TAG, "发送暂停摄像头预览广播失败", e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 恢复摄像头预览 |
||||
|
* 通过发送广播通知OXFaceOnlineActivity恢复摄像头预览 |
||||
|
*/ |
||||
|
private void resumeCameraPreview() { |
||||
|
try { |
||||
|
// 发送广播通知OXFaceOnlineActivity恢复摄像头预览 |
||||
|
Intent intent = new Intent("com.ouxuan.oxface.ACTION_RESUME_CAMERA"); |
||||
|
sendBroadcast(intent); |
||||
|
LogManager.logInfo(TAG, "已发送恢复摄像头预览广播"); |
||||
|
} catch (Exception e) { |
||||
|
LogManager.logError(TAG, "发送恢复摄像头预览广播失败", e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void onBackPressed() { |
||||
|
super.onBackPressed(); |
||||
|
// 恢复摄像头预览 |
||||
|
resumeCameraPreview(); |
||||
|
finish(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
protected void onDestroy() { |
||||
|
super.onDestroy(); |
||||
|
// 恢复摄像头预览 |
||||
|
resumeCameraPreview(); |
||||
|
LogManager.logInfo(TAG, "订单核销结果Activity已销毁"); |
||||
|
} |
||||
|
} |
@ -0,0 +1,185 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" |
||||
|
xmlns:app="http://schemas.android.com/apk/res-auto" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="match_parent" |
||||
|
android:background="@android:color/transparent"> |
||||
|
|
||||
|
<!-- 弹窗背景 --> |
||||
|
<RelativeLayout |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_centerInParent="true" |
||||
|
android:layout_marginStart="30dp" |
||||
|
android:layout_marginEnd="30dp" |
||||
|
android:background="@drawable/dialog_background" |
||||
|
android:padding="20dp"> |
||||
|
|
||||
|
<!-- 标题栏 --> |
||||
|
<RelativeLayout |
||||
|
android:id="@+id/rl_title_bar_result" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_marginBottom="20dp"> |
||||
|
|
||||
|
<!-- 标题 --> |
||||
|
<TextView |
||||
|
android:id="@+id/tv_result_title" |
||||
|
android:layout_width="wrap_content" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_centerHorizontal="true" |
||||
|
android:text="订单核销结果" |
||||
|
android:textColor="#333333" |
||||
|
android:textSize="18sp" |
||||
|
android:textStyle="bold" /> |
||||
|
|
||||
|
<!-- 关闭按钮 --> |
||||
|
<ImageButton |
||||
|
android:id="@+id/btn_close_result" |
||||
|
android:layout_width="30dp" |
||||
|
android:layout_height="30dp" |
||||
|
android:layout_alignParentEnd="true" |
||||
|
android:background="?android:attr/selectableItemBackgroundBorderless" |
||||
|
android:contentDescription="关闭" |
||||
|
android:src="@drawable/ic_close" /> |
||||
|
|
||||
|
</RelativeLayout> |
||||
|
|
||||
|
<!-- 订单信息 --> |
||||
|
<LinearLayout |
||||
|
android:id="@+id/ll_order_info" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_below="@id/rl_title_bar_result" |
||||
|
android:layout_marginBottom="20dp" |
||||
|
android:orientation="vertical"> |
||||
|
|
||||
|
<!-- 订单号 --> |
||||
|
<LinearLayout |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_marginBottom="10dp" |
||||
|
android:orientation="horizontal"> |
||||
|
|
||||
|
<TextView |
||||
|
android:layout_width="80dp" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:text="订单号:" |
||||
|
android:textColor="#666666" |
||||
|
android:textSize="14sp" /> |
||||
|
|
||||
|
<TextView |
||||
|
android:id="@+id/tv_order_no" |
||||
|
android:layout_width="0dp" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_weight="1" |
||||
|
android:text="20230908001" |
||||
|
android:textColor="#333333" |
||||
|
android:textSize="14sp" /> |
||||
|
|
||||
|
</LinearLayout> |
||||
|
|
||||
|
<!-- 验证码 --> |
||||
|
<LinearLayout |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_marginBottom="10dp" |
||||
|
android:orientation="horizontal"> |
||||
|
|
||||
|
<TextView |
||||
|
android:layout_width="80dp" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:text="验证码:" |
||||
|
android:textColor="#666666" |
||||
|
android:textSize="14sp" /> |
||||
|
|
||||
|
<TextView |
||||
|
android:id="@+id/tv_verification_code" |
||||
|
android:layout_width="0dp" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_weight="1" |
||||
|
android:text="123456" |
||||
|
android:textColor="#333333" |
||||
|
android:textSize="14sp" /> |
||||
|
|
||||
|
</LinearLayout> |
||||
|
|
||||
|
<!-- 订单类型 --> |
||||
|
<LinearLayout |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_marginBottom="10dp" |
||||
|
android:orientation="horizontal"> |
||||
|
|
||||
|
<TextView |
||||
|
android:layout_width="80dp" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:text="订单类型:" |
||||
|
android:textColor="#666666" |
||||
|
android:textSize="14sp" /> |
||||
|
|
||||
|
<TextView |
||||
|
android:id="@+id/tv_order_type" |
||||
|
android:layout_width="0dp" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_weight="1" |
||||
|
android:text="普通订单" |
||||
|
android:textColor="#333333" |
||||
|
android:textSize="14sp" /> |
||||
|
|
||||
|
</LinearLayout> |
||||
|
|
||||
|
<!-- 卡号 --> |
||||
|
<LinearLayout |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_marginBottom="10dp" |
||||
|
android:orientation="horizontal"> |
||||
|
|
||||
|
<TextView |
||||
|
android:layout_width="80dp" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:text="卡号:" |
||||
|
android:textColor="#666666" |
||||
|
android:textSize="14sp" /> |
||||
|
|
||||
|
<TextView |
||||
|
android:id="@+id/tv_card_no" |
||||
|
android:layout_width="0dp" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_weight="1" |
||||
|
android:text="CARD001" |
||||
|
android:textColor="#333333" |
||||
|
android:textSize="14sp" /> |
||||
|
|
||||
|
</LinearLayout> |
||||
|
|
||||
|
</LinearLayout> |
||||
|
|
||||
|
<!-- 状态信息 --> |
||||
|
<TextView |
||||
|
android:id="@+id/tv_status" |
||||
|
android:layout_width="wrap_content" |
||||
|
android:layout_height="wrap_content" |
||||
|
android:layout_below="@id/ll_order_info" |
||||
|
android:layout_centerHorizontal="true" |
||||
|
android:layout_marginBottom="20dp" |
||||
|
android:text="核销成功" |
||||
|
android:textColor="#009874" |
||||
|
android:textSize="16sp" |
||||
|
android:textStyle="bold" /> |
||||
|
|
||||
|
<!-- 确认按钮 --> |
||||
|
<Button |
||||
|
android:id="@+id/btn_confirm_result" |
||||
|
android:layout_width="match_parent" |
||||
|
android:layout_height="45dp" |
||||
|
android:layout_below="@id/tv_status" |
||||
|
android:background="@drawable/gradient_button_selector" |
||||
|
android:text="确认" |
||||
|
android:textColor="@android:color/white" |
||||
|
android:textSize="16sp" /> |
||||
|
|
||||
|
</RelativeLayout> |
||||
|
|
||||
|
</RelativeLayout> |
Write
Preview
Loading…
Cancel
Save
Reference in new issue