红包直播间展示样式构建

This commit is contained in:
18401019693 2023-06-26 18:04:58 +08:00
parent 6889828c00
commit 279575d80b
12 changed files with 483 additions and 9 deletions

View File

@ -1195,4 +1195,14 @@ Limited ride And limited avatar frame</string>
<string name="live_vote_create_error">Create Vote Error</string>
<string name="rebot_config_auto_say_max">Over the maximum value</string>
<string name="insufficient_balance">Insufficient balance, continue to recharge</string>
<string name="save_popular_red_packets">攢人氣紅包</string>
<string name="amount">金額</string>
<string name="drill"></string>
<string name="conditions">條件</string>
<string name="there_is_no"></string>
<string name="following_anchor">關注主播</string>
<string name="red_envelope_rill">紅包%s鑚/個</string>
<string name="total_consumption_of_drill">共計消耗%s鑚</string>
<string name="top_up_now">去充值></string>
<string name="range_range_is">范围区间为[%s]</string>
</resources>

View File

@ -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"));
}
}
}

View File

@ -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();
}
});
}
/**

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true">
<shape android:shape="rectangle">
<corners android:radius="15dp" />
<solid android:color="#FCC438" />
</shape>
</item>
<item android:state_selected="false">
<shape android:shape="rectangle">
<corners android:radius="15dp" />
<stroke android:width="1dp" android:color="#FCC438" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="20dp" />
<gradient
android:angle="90"
android:endColor="#FDCF46"
android:startColor="#FFDB86" />
</shape>

View File

@ -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" />
<include
android:id="@+id/red_packet"
layout="@layout/view_red_packet"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/live_rank_pk"
android:layout_marginStart="12dp"
android:layout_marginTop="15dp" />
<FrameLayout
android:id="@+id/btn_prize_pool_level"
android:layout_width="70dp"
@ -745,7 +754,7 @@
android:layout_below="@id/live_time"
android:layout_marginLeft="12dp"
android:layout_marginTop="-12dp"
android:visibility="visible">
android:visibility="gone">
<ImageView
android:id="@+id/img_hot_gif"
@ -1305,13 +1314,13 @@
android:layout_marginBottom="-30dp"
android:background="@color/white"
android:visibility="invisible" />
<include
android:id="@+id/vote_layout"
layout="@layout/sim_live_room_vote"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
/>
android:layout_alignParentEnd="true" />
<ImageView
android:id="@+id/icon_pk_top"
@ -2078,7 +2087,6 @@
android:orientation="vertical">
<RelativeLayout
android:id="@+id/mic_view2"
android:layout_width="40dp"
@ -2112,6 +2120,7 @@
android:src="@mipmap/voice" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/mic_view1"
android:layout_width="40dp"
@ -2145,6 +2154,7 @@
android:src="@mipmap/voice" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/mic_view"
android:layout_width="40dp"
@ -2203,8 +2213,8 @@
android:layout_height="76dp"
android:layout_marginTop="20dp"
android:layout_marginRight="5dp"
app:delay_time="5000"
android:visibility="gone"
app:delay_time="5000"
app:indicator_height="8dp"
app:indicator_width="8dp" />

View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 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:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="46dp"
app:cardBackgroundColor="#70323232"
app:cardCornerRadius="8dp"
app:cardElevation="0dp">
<TextView
android:layout_width="58dp"
android:layout_height="16dp"
android:gravity="center_vertical"
android:paddingStart="5dp"
android:text="倒計時04:59"
android:visibility="gone"
android:textColor="@color/white"
android:textSize="9sp" />
<LinearLayout
android:layout_width="68dp"
android:layout_height="27dp"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingStart="6dp"
android:visibility="visible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="10/200"
android:textColor="@color/white"
android:textSize="9sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="待開紅包:4"
android:textColor="@color/white"
android:textSize="9sp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<ImageView
android:layout_width="40dp"
android:layout_height="51dp"
android:src="@mipmap/icon_red_packet" />
</FrameLayout>

View File

@ -0,0 +1,219 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@mipmap/background_red_packet"
android:backgroundTintMode="src_over">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="45dp"
android:text="@string/save_popular_red_packets"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<ImageView
android:layout_width="19dp"
android:layout_height="19dp"
android:layout_gravity="end"
android:layout_marginTop="28dp"
android:layout_marginEnd="21dp"
android:src="@mipmap/icon_instructions" />
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="43dp"
android:layout_marginTop="97dp"
android:layout_marginEnd="49dp"
app:cardBackgroundColor="#E82936"
app:cardCornerRadius="8dp"
app:cardElevation="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="23dp"
android:text="@string/amount"
android:textColor="@color/white"
android:textSize="15sp" />
<EditText
android:id="@+id/rill"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:gravity="center"
android:inputType="number"
android:text="0"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:text="@string/drill"
android:textColor="@color/white"
android:textSize="15sp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="43dp"
android:layout_marginTop="149dp"
android:layout_marginEnd="49dp"
app:cardBackgroundColor="#E82936"
app:cardCornerRadius="8dp"
app:cardElevation="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="35dp"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="23dp"
android:text="@string/count"
android:textColor="@color/white"
android:textSize="15sp" />
<EditText
android:id="@+id/total"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="@null"
android:gravity="center"
android:inputType="number"
android:text="0"
android:textColor="@color/white"
android:textColorHint="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:text="@string/live_send_gift_2"
android:textColor="@color/white"
android:textSize="15sp" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="213dp">
<androidx.cardview.widget.CardView
android:layout_width="50dp"
android:layout_height="35dp"
android:layout_marginStart="43dp"
app:cardBackgroundColor="#E82936"
app:cardCornerRadius="8dp"
app:cardElevation="0dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:text="@string/conditions"
android:textColor="@color/white"
android:textSize="15sp" />
</androidx.cardview.widget.CardView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="22dp"
android:layout_marginEnd="49dp">
<Button
android:id="@+id/there_is_no"
android:layout_width="45dp"
android:layout_height="30dp"
android:background="@drawable/background_red_packet_select"
android:gravity="center"
android:text="@string/there_is_no"
android:textColor="#FDD04A"
android:textSize="13sp" />
<Button
android:id="@+id/following_anchor"
android:layout_width="75dp"
android:layout_height="30dp"
android:layout_gravity="end"
android:background="@drawable/background_red_packet_select"
android:gravity="center"
android:text="@string/following_anchor"
android:textColor="#FDD04A"
android:textSize="12sp" />
</FrameLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="43dp"
android:layout_marginTop="266dp"
android:layout_marginEnd="49dp">
<TextView
android:id="@+id/red_envelope_rill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/red_envelope_rill"
android:textColor="@color/white"
android:textSize="12sp" />
<TextView
android:id="@+id/total_consumption_of_drill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:text="@string/total_consumption_of_drill"
android:textColor="@color/white"
android:textSize="12sp" />
</FrameLayout>
<Button
android:layout_width="160dp"
android:layout_height="40dp"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="34dp"
android:background="@drawable/background_send_red_packet"
android:text="@string/red_pack_6"
android:textColor="#8F3B00"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|bottom"
android:layout_marginBottom="13dp"
android:textSize="12sp"
android:textColor="@color/white"
android:text="@string/top_up_now" />
</FrameLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 260 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB