From b3c962c03b23a6bd385a202ff271bca888aa79b2 Mon Sep 17 00:00:00 2001 From: ningwenqiang Date: Sat, 21 Sep 2024 15:55:16 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=98=E8=AE=A4=E6=A0=B7=E5=BC=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/utils/DateFormatUtil.java | 28 +++++++++- .../main/res/drawable/background_white_5.xml | 6 +++ .../adapter/LiveAnchorSayItemsAdapter.java | 29 +++++----- .../yunbao/live/views/LiveEndViewHolder.java | 2 +- live/src/main/res/layout/item_anchor_say.xml | 53 +++++++++++++------ live/src/main/res/layout/view_live_end.xml | 50 ++++++++++------- live/src/main/res/values-zh/strings.xml | 2 + live/src/main/res/values/strings.xml | 2 + 8 files changed, 119 insertions(+), 53 deletions(-) create mode 100644 common/src/main/res/drawable/background_white_5.xml diff --git a/common/src/main/java/com/yunbao/common/utils/DateFormatUtil.java b/common/src/main/java/com/yunbao/common/utils/DateFormatUtil.java index 1115acae3..d0bc8c30f 100644 --- a/common/src/main/java/com/yunbao/common/utils/DateFormatUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/DateFormatUtil.java @@ -7,6 +7,7 @@ import android.text.TextUtils; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +import java.util.concurrent.TimeUnit; import io.rong.common.RLog; import io.rong.imkit.utils.language.LangUtils; @@ -50,8 +51,31 @@ public class DateFormatUtil { return formattedDate; } - public static String getDiffInMilliseconds(String time1, String time2) { - return String.valueOf((Long.parseLong(time2) - Long.parseLong(time1)) / (60 * 1000)); + public static String getDiffInMilliseconds(String time1, String time2, String day, String hour, String minute) { + return getTime(Long.parseLong(time1), Long.parseLong(time2), day, hour, minute); + } + + + //根据时间计算出 分钟,小时,天 + private static String getTime(Long startTime, Long endTime, String day, String hour, String minute) { + if (startTime == null || endTime == null || startTime >= endTime) { + return "Invalid time range"; + } + + long diff = endTime - startTime; + long days = TimeUnit.MILLISECONDS.toDays(diff); + long hours = TimeUnit.MILLISECONDS.toHours(diff) - (days * 24); + long minutes = TimeUnit.MILLISECONDS.toMinutes(diff) - (TimeUnit.MILLISECONDS.toHours(diff) * 60); + + StringBuilder stringBuilder = new StringBuilder(); + if (days > 0) { + stringBuilder.append(days).append(day).append(" "); + } else if (hours > 0) { + stringBuilder.append(hours).append(hour).append(" "); + } else if (minutes > 0) { + stringBuilder.append(minutes).append(minute); + } + return stringBuilder.toString(); } diff --git a/common/src/main/res/drawable/background_white_5.xml b/common/src/main/res/drawable/background_white_5.xml new file mode 100644 index 000000000..a7c1f9afd --- /dev/null +++ b/common/src/main/res/drawable/background_white_5.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveAnchorSayItemsAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveAnchorSayItemsAdapter.java index 4b4438ad3..9a4edf534 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveAnchorSayItemsAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveAnchorSayItemsAdapter.java @@ -66,11 +66,12 @@ public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter click()); - textView.setOnClickListener(v -> click()); - icon.setOnClickListener(v -> click()); +// textView = itemView.findViewById(R.id.contentTv); +// icon = itemView.findViewById(R.id.anchorSayBg); +// itemView.setOnClickListener(v -> click()); +// textView.setOnClickListener(v -> click()); +// icon.setOnClickListener(v -> click()); } @@ -91,16 +92,16 @@ public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter + android:background="@drawable/bg_anchor_say_select"> - + app:layout_constraintTop_toTopOf="parent" /> + + + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" /> + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_live_end.xml b/live/src/main/res/layout/view_live_end.xml index c9552d839..16784a5f5 100644 --- a/live/src/main/res/layout/view_live_end.xml +++ b/live/src/main/res/layout/view_live_end.xml @@ -454,7 +454,7 @@ android:layout_weight="1" android:text="主播等级Lv.1 | 差600經驗升級" android:textColor="#898989" - android:textSize="11sp" /> + android:textSize="10sp" /> - - - + + + + - + 直播攻略 我的等级 + + 小時 分鐘 本場總計鑽石: 打賞人數: diff --git a/live/src/main/res/values/strings.xml b/live/src/main/res/values/strings.xml index 58ff7853e..3637f091f 100644 --- a/live/src/main/res/values/strings.xml +++ b/live/src/main/res/values/strings.xml @@ -162,6 +162,8 @@ Live strategy My level total + day + hour minute Get diamonds: Gift givers: