From 279575d80b7adf04f67c62a07715213e5a80d172 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Mon, 26 Jun 2023 18:04:58 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E7=BA=A2=E5=8C=85=E7=9B=B4=E6=92=AD?= =?UTF-8?q?=E9=97=B4=E5=B1=95=E7=A4=BA=E6=A0=B7=E5=BC=8F=E6=9E=84=E5=BB=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/main/res/values/strings.xml | 10 + .../live/dialog/SendRendPacketPopup.java | 146 ++++++++++++ .../yunbao/live/views/LiveRoomViewHolder.java | 11 + .../drawable/background_red_packet_select.xml | 15 ++ .../drawable/background_send_red_packet.xml | 8 + live/src/main/res/layout/view_live_room.xml | 28 ++- live/src/main/res/layout/view_red_packet.xml | 55 +++++ .../main/res/layout/view_send_red_packet.xml | 219 ++++++++++++++++++ .../mipmap-xhdpi/background_red_packet.png | Bin 0 -> 266190 bytes .../main/res/mipmap-xxxhdpi/icon_ellipse.png | Bin 0 -> 17915 bytes .../res/mipmap-xxxhdpi/icon_instructions.png | Bin 0 -> 2572 bytes .../res/mipmap-xxxhdpi/icon_red_packet.png | Bin 0 -> 17123 bytes 12 files changed, 483 insertions(+), 9 deletions(-) create mode 100644 live/src/main/java/com/yunbao/live/dialog/SendRendPacketPopup.java create mode 100644 live/src/main/res/drawable/background_red_packet_select.xml create mode 100644 live/src/main/res/drawable/background_send_red_packet.xml create mode 100644 live/src/main/res/layout/view_red_packet.xml create mode 100644 live/src/main/res/layout/view_send_red_packet.xml create mode 100644 live/src/main/res/mipmap-xhdpi/background_red_packet.png create mode 100644 live/src/main/res/mipmap-xxxhdpi/icon_ellipse.png create mode 100644 live/src/main/res/mipmap-xxxhdpi/icon_instructions.png create mode 100644 live/src/main/res/mipmap-xxxhdpi/icon_red_packet.png diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 5dcfc909b..7b352cfcb 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1195,4 +1195,14 @@ Limited ride And limited avatar frame Create Vote Error Over the maximum value Insufficient balance, continue to recharge + 攢人氣紅包 + 金額 + + 條件 + + 關注主播 + 紅包%s鑚/個 + 共計消耗%s鑚 + 去充值> + 范围区间为[%s] diff --git a/live/src/main/java/com/yunbao/live/dialog/SendRendPacketPopup.java b/live/src/main/java/com/yunbao/live/dialog/SendRendPacketPopup.java new file mode 100644 index 000000000..35d9e9023 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/SendRendPacketPopup.java @@ -0,0 +1,146 @@ +package com.yunbao.live.dialog; + +import android.content.Context; +import android.graphics.Color; +import android.text.Editable; +import android.text.TextUtils; +import android.text.TextWatcher; +import android.widget.Button; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.core.CenterPopupView; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; +import com.yunbao.live.R; + +public class SendRendPacketPopup extends CenterPopupView { + private Button thereIsNo, followingAnchor; + private TextView redEnvelopeRill, totalConsumptionOfDrill; + private TextView rill, total; + + public SendRendPacketPopup(@NonNull Context context) { + super(context); + } + + // 返回自定义弹窗的布局离开 + @Override + protected int getImplLayoutId() { + return R.layout.view_send_red_packet; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + initView(); + } + + private void initView() { + thereIsNo = findViewById(R.id.there_is_no); + followingAnchor = findViewById(R.id.following_anchor); + redEnvelopeRill = findViewById(R.id.red_envelope_rill); + totalConsumptionOfDrill = findViewById(R.id.total_consumption_of_drill); + rill = findViewById(R.id.rill); + total = findViewById(R.id.total); + selectText(thereIsNo, true); + selectText(followingAnchor, false); + ViewClicksAntiShake.clicksAntiShake(thereIsNo, () -> { + selectText(thereIsNo, true); + selectText(followingAnchor, false); + }); + ViewClicksAntiShake.clicksAntiShake(followingAnchor, () -> { + selectText(thereIsNo, false); + selectText(followingAnchor, true); + }); + redEnvelopeRill.setText(String.format(getContext().getString(R.string.red_envelope_rill), "0")); + totalConsumptionOfDrill.setText(String.format(getContext().getString(R.string.total_consumption_of_drill), "0")); + rill.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + + + String number = s.toString(); + String rillNumber = total.getText().toString(); + int totalInt = 0; + try { + totalInt = Integer.parseInt(rillNumber); + } catch (NumberFormatException e) { + totalInt = 0; + } + if (TextUtils.isEmpty(number)) { + redEnvelopeRill.setText(String.format(getContext().getString(R.string.red_envelope_rill), "0")); + totalConsumptionOfDrill.setText(String.format(getContext().getString(R.string.total_consumption_of_drill), "0")); + } else { + int numberInt = Integer.parseInt(number); + if (numberInt >= 200 && numberInt <= 10000) { + totalConsumptionOfDrill.setText(String.format(getContext().getString(R.string.total_consumption_of_drill), String.valueOf((totalInt * numberInt)))); + redEnvelopeRill.setText(String.format(getContext().getString(R.string.red_envelope_rill), s.toString())); + } else { + ToastUtil.show(String.format(getContext().getString(R.string.range_range_is), "200~10000")); + } + + } + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); + total.addTextChangedListener(new TextWatcher() { + @Override + public void beforeTextChanged(CharSequence s, int start, int count, int after) { + + } + + @Override + public void onTextChanged(CharSequence s, int start, int before, int count) { + String number = s.toString(); + String rillNumber = rill.getText().toString(); + int rillInt = 0; + try { + rillInt = Integer.parseInt(rillNumber); + } catch (NumberFormatException e) { + rillInt = 0; + } + if (TextUtils.isEmpty(number)) { + totalConsumptionOfDrill.setText(String.format(getContext().getString(R.string.total_consumption_of_drill), "0")); + } else { + int numberInt = Integer.parseInt(number); + if (numberInt >= 1 && numberInt <= 100) { + totalConsumptionOfDrill.setText(String.format(getContext().getString(R.string.total_consumption_of_drill), String.valueOf((rillInt * numberInt)))); + } else { + ToastUtil.show(String.format(getContext().getString(R.string.range_range_is), "1~100")); + } + + } + + } + + @Override + public void afterTextChanged(Editable s) { + + } + }); + //红包初始数量 + rill.setText("200"); + total.setText("10"); + } + + private void selectText(TextView textView, boolean select) { + textView.setSelected(select); + if (select) { + textView.setTextColor(Color.parseColor("#E12801")); + } else { + textView.setTextColor(Color.parseColor("#FDD04A")); + } + + } +} diff --git a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java index ae795ffbd..8e2b51bfe 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -50,6 +50,7 @@ import com.bumptech.glide.load.resource.gif.GifDrawable; import com.bumptech.glide.request.RequestListener; import com.bumptech.glide.request.RequestOptions; import com.bumptech.glide.request.target.Target; +import com.lxj.xpopup.XPopup; import com.makeramen.roundedimageview.RoundedImageView; import com.ms.banner.Banner; import com.ms.banner.BannerConfig; @@ -151,6 +152,7 @@ import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveUserAnchorMailBoxWebInfoPopDialog; import com.yunbao.live.dialog.LiveUserDialogFragment; import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience; +import com.yunbao.live.dialog.SendRendPacketPopup; import com.yunbao.live.event.LiveAnchorEvent; import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.event.LiveRoomChangeEvent; @@ -1407,6 +1409,15 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis new LoadDian9TuUtil().loadDian9TuAssets2(mContext, liveWksLayout, "rectangle_new.png", 1); new LoadDian9TuUtil().loadDian9TuAssets2(mContext, wishListLayout2, "rectangle_new.png", 1); + //测试点开红包 + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.red_packet), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + new XPopup.Builder(mContext) + .asCustom(new SendRendPacketPopup(mContext)) + .show(); + } + }); } /** diff --git a/live/src/main/res/drawable/background_red_packet_select.xml b/live/src/main/res/drawable/background_red_packet_select.xml new file mode 100644 index 000000000..c0e03f8b9 --- /dev/null +++ b/live/src/main/res/drawable/background_red_packet_select.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/background_send_red_packet.xml b/live/src/main/res/drawable/background_send_red_packet.xml new file mode 100644 index 000000000..d4c3781c4 --- /dev/null +++ b/live/src/main/res/drawable/background_send_red_packet.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml index 11d8f8c09..9b80802ac 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -701,14 +701,23 @@ android:layout_width="52dp" android:layout_height="76dp" android:layout_below="@+id/live_rank_pk" - android:layout_alignParentRight="true" + android:layout_alignParentEnd="true" android:layout_marginTop="20dp" - android:layout_marginRight="5dp" - android:visibility="gone" + android:layout_marginEnd="5dp" + android:visibility="visible" app:delay_time="5000" app:indicator_height="8dp" app:indicator_width="8dp" /> + + + android:visibility="gone"> - + + + android:layout_alignParentEnd="true" /> - + + diff --git a/live/src/main/res/layout/view_red_packet.xml b/live/src/main/res/layout/view_red_packet.xml new file mode 100644 index 000000000..deedb5761 --- /dev/null +++ b/live/src/main/res/layout/view_red_packet.xml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_send_red_packet.xml b/live/src/main/res/layout/view_send_red_packet.xml new file mode 100644 index 000000000..b2db96da5 --- /dev/null +++ b/live/src/main/res/layout/view_send_red_packet.xml @@ -0,0 +1,219 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +