赵明涛 5 days ago
parent
commit
a073fd1980
  1. 47
      app/src/main/java/com/ouxuan/oxface/orderOX/adapter/OrderSelectionAdapter.java
  2. 18
      app/src/main/res/layout/item_order_selection.xml

47
app/src/main/java/com/ouxuan/oxface/orderOX/adapter/OrderSelectionAdapter.java

@ -88,15 +88,14 @@ public class OrderSelectionAdapter extends RecyclerView.Adapter<OrderSelectionAd
holder.itemView.setSelected(false);
}
// 设置点击事件
// 设置点击事件 - 直接触发核销操作
holder.itemView.setOnClickListener(v -> {
if (onOrderClickListener != null) {
onOrderClickListener.onOrderClick(order, position);
onOrderClickListener.onVerifyClick(order, position); // 直接调用核销操作
}
setSelectedPosition(position);
});
// 去核销按钮点击事件
// 去核销按钮点击事件 - 同样触发核销操作
holder.tvVerifyButton.setOnClickListener(v -> {
if (onOrderClickListener != null) {
onOrderClickListener.onVerifyClick(order, position);
@ -251,25 +250,29 @@ public class OrderSelectionAdapter extends RecyclerView.Adapter<OrderSelectionAd
));
LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) lineLayout.getLayoutParams();
layoutParams.setMargins(0, dpToPx(holder.itemView.getContext(), 8), 0, 0);
layoutParams.setMargins(0, dpToPx(holder.itemView.getContext(), 6), 0, 0); // 减少上边距
lineLayout.setLayoutParams(layoutParams);
// 标签
// 标签 - 固定宽度避免变形
TextView labelView = new TextView(holder.itemView.getContext());
labelView.setText(label);
labelView.setTextColor(0xFF9A9A9D);
labelView.setTextSize(12);
labelView.setTextSize(11); // 略微减小字体
labelView.setSingleLine(true); // 单行显示
LinearLayout.LayoutParams labelParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
dpToPx(holder.itemView.getContext(), 70), // 固定宽度
LinearLayout.LayoutParams.WRAP_CONTENT
);
labelView.setLayoutParams(labelParams);
//
// - 使用剩余空间
TextView valueView = new TextView(holder.itemView.getContext());
valueView.setText(value);
valueView.setTextColor(0xFF1B1B1B);
valueView.setTextSize(12);
valueView.setTextSize(11); // 略微减小字体
valueView.setSingleLine(false); // 允许换行但优化显示
valueView.setMaxLines(2); // 最多两行
valueView.setEllipsize(android.text.TextUtils.TruncateAt.END); // 超出显示省略号
LinearLayout.LayoutParams valueParams = new LinearLayout.LayoutParams(
0,
LinearLayout.LayoutParams.WRAP_CONTENT,
@ -285,18 +288,19 @@ public class OrderSelectionAdapter extends RecyclerView.Adapter<OrderSelectionAd
TextView tagView = new TextView(holder.itemView.getContext());
tagView.setText("可多次进出");
tagView.setTextColor(0xFFE60012);
tagView.setTextSize(10);
tagView.setTextSize(9); // 小字体
tagView.setBackgroundResource(R.drawable.many_enter_tag_background);
tagView.setPadding(dpToPx(holder.itemView.getContext(), 6),
dpToPx(holder.itemView.getContext(), 2),
dpToPx(holder.itemView.getContext(), 6),
dpToPx(holder.itemView.getContext(), 2));
tagView.setPadding(dpToPx(holder.itemView.getContext(), 4),
dpToPx(holder.itemView.getContext(), 1),
dpToPx(holder.itemView.getContext(), 4),
dpToPx(holder.itemView.getContext(), 1));
tagView.setSingleLine(true);
LinearLayout.LayoutParams tagParams = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
);
tagParams.setMargins(dpToPx(holder.itemView.getContext(), 12), 0, 0, 0);
tagParams.setMargins(dpToPx(holder.itemView.getContext(), 8), 0, 0, 0); // 减小左边距
tagView.setLayoutParams(tagParams);
lineLayout.addView(tagView);
@ -309,11 +313,16 @@ public class OrderSelectionAdapter extends RecyclerView.Adapter<OrderSelectionAd
* 获取格式化的场馆信息
*/
private String getFormattedVenueInfo(OrderVerificationData.OrderItem order) {
// 这里可以根据实际的info结构来解析场馆信息
// 由于当前数据模型中没有详细的场馆信息结构所以使用简化逻辑
// 简化显示避免过长换行
String timeInfo = order.getFormattedTimeInfo();
String projectName = order.getProjectName();
return projectName + " " + timeInfo;
// 如果项目名称过长只显示时间
if (projectName.length() > 8) {
return timeInfo;
} else {
return projectName + " " + timeInfo;
}
}
/**

18
app/src/main/res/layout/item_order_selection.xml

@ -53,10 +53,10 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/divider_line"
android:layout_marginLeft="18dp"
android:layout_marginTop="20dp"
android:layout_marginRight="140dp"
android:layout_marginBottom="20dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="16dp"
android:layout_marginRight="100dp"
android:layout_marginBottom="16dp"
android:orientation="vertical">
<!-- 订单信息标题 -->
@ -64,10 +64,10 @@
android:id="@+id/tv_order_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dp"
android:layout_marginBottom="4dp"
android:text="订单信息(共4场次)"
android:textColor="#1B1B1B"
android:textSize="12sp"
android:textSize="11sp"
android:textStyle="bold" />
<!-- 订单信息列表 -->
@ -201,8 +201,8 @@
<!-- 右上角核销按钮 -->
<TextView
android:id="@+id/tv_verify_button"
android:layout_width="90dp"
android:layout_height="40dp"
android:layout_width="80dp"
android:layout_height="36dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:background="@drawable/verify_button_background"
@ -211,6 +211,6 @@
android:gravity="center"
android:text="去核销"
android:textColor="@android:color/white"
android:textSize="14sp" />
android:textSize="13sp" />
</RelativeLayout>
Loading…
Cancel
Save