diff --git a/common/src/main/java/com/yunbao/common/views/weight/CircleProgress.java b/common/src/main/java/com/yunbao/common/views/weight/CircleProgress.java new file mode 100644 index 000000000..12e059a40 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/weight/CircleProgress.java @@ -0,0 +1,73 @@ +package com.yunbao.common.views.weight; + + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Color; +import android.graphics.Paint; +import android.graphics.RectF; +import android.util.AttributeSet; +import android.view.View; + +public class CircleProgress extends View { + private Paint mPaint; + private RectF mRectF; + private int mCurrent = 1, mMax = 100; + //圆弧(也可以说是圆环)的宽度 + private float mArcWidth =8; + //控件的宽度 + private float mWidth; + + public CircleProgress(Context context) { + this(context, null); + } + + public CircleProgress(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public CircleProgress(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + mPaint = new Paint(); + mPaint.setAntiAlias(true); + mRectF = new RectF(); + } + + public void setCurrent(int mCurrent) { + this.mCurrent = mCurrent; + invalidate(); + } + + public void setMax(int mMax) { + this.mMax = mMax; + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + //getMeasuredWidth获取的是view的原始大小,也就是xml中配置或者代码中设置的大小 + //getWidth获取的是view最终显示的大小,这个大小不一定等于原始大小 + mWidth = getMeasuredWidth(); + } + + @Override + protected void onDraw(Canvas canvas) { + super.onDraw(canvas); + mPaint.setStyle(Paint.Style.STROKE); + //设置圆弧的宽度(圆环的宽度) + mPaint.setStrokeWidth(mArcWidth); + mPaint.setColor(Color.parseColor("#FF98A2")); + //大圆的半径 + float bigCircleRadius = mWidth / 2; + //小圆的半径 + float smallCircleRadius = bigCircleRadius - mArcWidth; + //绘制小圆 + canvas.drawCircle(bigCircleRadius, bigCircleRadius, smallCircleRadius, mPaint); + mPaint.setColor(Color.parseColor("#FFF7CD")); + mRectF.set(mArcWidth, mArcWidth, mWidth - mArcWidth, mWidth - mArcWidth); + //绘制圆弧 + canvas.drawArc(mRectF, -90, mCurrent * 360 / mMax, false, mPaint); + setBackgroundColor(Color.parseColor("#FD2D48")); + } + +} diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 7b352cfcb..dd92b5293 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1205,4 +1205,22 @@ Limited ride And limited avatar frame 共計消耗%s鑚 去充值> 范围区间为[%s] + 价值 + + 隨機可得 + 攢人氣 + 1.在直播間發紅包有什麽好處? + 有紅包的直播間會給新增熱度,吸引更多用戶觀看直播 + 2.紅包發給誰? + 紅包發出后,直播間所有用戶都可搶,包括自己 + 3.紅包怎麽發? + 紅包同爲禮物,20%鑽石獎勵給主播,剩餘70%的鑽石會以【1鑽石=1金豆】的比列兌換成金豆塞進紅包内給直播間觀看領取,剩餘10%隨機包成鑽石禮物包進紅包裹,另平臺設有紅包目標任務,每連成一個目標,平臺將獎勵目標紅包 數總價值的2%開設超級獎池供所有目標用戶抽取 + 4.未被領取的紅包如何處理? + 紅包打開后未被領取,以及主播下播后未打開的紅包,會退回您的賬戶 + 5.搶到的紅包能幹嘛? + 搶到紅包所得金豆可用於平臺一切金豆行爲,不轉增,不可體現 + 恭喜搶到紅包 + 獲得%s + 查看幸運觀衆> + 贈送主播禮物表達心意 diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java index b2709add5..a5d9c37c1 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveGiftAdapter.java @@ -1,13 +1,8 @@ package com.yunbao.live.adapter; import android.content.Context; - -import androidx.annotation.NonNull; -import androidx.recyclerview.widget.RecyclerView; - import android.graphics.Color; import android.text.TextUtils; -import android.util.Log; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -20,7 +15,10 @@ import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; -import com.alibaba.fastjson.JSONObject; +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.lxj.xpopup.XPopup; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.bean.LiveGiftBean; @@ -31,9 +29,10 @@ import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.GiftCacheUtil; import com.yunbao.common.utils.ToastUtil; -import com.yunbao.common.utils.WordUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.R; import com.yunbao.live.custom.GiftMarkView; +import com.yunbao.live.dialog.SendRendPacketPopup; import java.io.File; import java.util.List; @@ -54,7 +53,7 @@ public class LiveGiftAdapter extends RecyclerView.Adapter { private ScaleAnimation mAnimation; private View mAnimView; private String mName1, mName2; - boolean isTouch=true; + boolean isTouch = true; public void setTouch(boolean touch) { isTouch = touch; @@ -70,14 +69,14 @@ public class LiveGiftAdapter extends RecyclerView.Adapter { mOnClickListener = new View.OnClickListener() { @Override public void onClick(View v) { - if(!isTouch){ + if (!isTouch) { return; } Object tag = v.getTag(); if (tag != null) { int position = (int) tag; LiveGiftBean bean = mList.get(position); - if (!bean.isChecked()) { + if (!bean.isChecked() && bean.getType() != 9999999) { if (!cancelChecked()) { if (mActionListener != null) { mActionListener.onCancel(); @@ -196,7 +195,7 @@ public class LiveGiftAdapter extends RecyclerView.Adapter { tvRedpoint = (TextView) itemView.findViewById(R.id.tvRedpoint); mPayico = (ImageView) itemView.findViewById(R.id.pay_ico); expire = (TextView) itemView.findViewById(R.id.expire); - mRadioButton.setOnClickListener(mOnClickListener); + mLoading = itemView.findViewById(R.id.gift_loading); mLoadingLayout = itemView.findViewById(R.id.gift_loading_layout); mLoadingLayout.setOnClickListener(v -> { @@ -208,20 +207,20 @@ public class LiveGiftAdapter extends RecyclerView.Adapter { mLoading.startAnimation(animation); LiveGiftBean bean = mList.get((Integer) v.getTag()); GiftCacheUtil.getInstance().pause(); - GiftCacheUtil.getInstance().downloadGiftForId(mContext,bean, new CommonCallback() { + GiftCacheUtil.getInstance().downloadGiftForId(mContext, bean, new CommonCallback() { @Override public void callback(File bean) { - if(bean==null){ + if (bean == null) { ToastUtil.show(mContext.getString(R.string.load_failure_2)); mLoading.setImageResource(R.mipmap.icon_download_gift); animation.setRepeatCount(0); animation.setDuration(0); animation.cancel(); mLoading.setAnimation(animation); - }else { + } else { mLoadingLayout.setVisibility(View.GONE); } - GiftCacheUtil.getInstance().restart(); + GiftCacheUtil.getInstance().restart(); } }); }); @@ -235,16 +234,33 @@ public class LiveGiftAdapter extends RecyclerView.Adapter { } if (payload == null) { ImgLoader.display(mContext, bean.getIcon(), mIcon); - bean.setView(mIcon); mName.setText(bean.getName()); - if (bean.getSendType() != null && bean.getSendType().equals("1")) { -// mCoinName = mName2; - mPayico.setImageResource(R.mipmap.gold_coin); + if (bean.getType() == 9999999) { + mPayico.setVisibility(View.GONE); + mPrice.setText(mContext.getString(R.string.build_up_popularity)); + mPrice.setTextColor(Color.parseColor("#db8c4a")); + ViewClicksAntiShake.clicksAntiShake(mRadioButton, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + new XPopup.Builder(mContext) + .asCustom(new SendRendPacketPopup(mContext)) + .show(); + } + }); } else { + mRadioButton.setOnClickListener(mOnClickListener); + mPrice.setTextColor(Color.parseColor("#c8c8c8")); + mPayico.setVisibility(View.VISIBLE); + bean.setView(mIcon); + if (bean.getSendType() != null && bean.getSendType().equals("1")) { +// mCoinName = mName2; + mPayico.setImageResource(R.mipmap.gold_coin); + } else { // mCoinName = mName1; - mPayico.setImageResource(R.mipmap.diamond); + mPayico.setImageResource(R.mipmap.diamond); + } + mPrice.setText(bean.getPrice()); } - mPrice.setText(bean.getPrice()); if (IMLoginManager.get(mContext).isNewUserGif() && position == 0 && bean.getTag() != null) { mPayico.setVisibility(View.GONE); @@ -295,10 +311,11 @@ public class LiveGiftAdapter extends RecyclerView.Adapter { } } + } mRadioButton.setTag(position); mRadioButton.doChecked(bean.isChecked()); - if (bean.getSwf()!=null&&bean.getSwf().isEmpty()) { + if (bean.getSwf() != null && bean.getSwf().isEmpty()) { mLoadingLayout.setVisibility(View.GONE); return; } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java index bf6ed4058..aa5d65639 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftDialogFragment.java @@ -41,6 +41,7 @@ import com.alibaba.android.arouter.launcher.ARouter; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import com.lxj.xpopup.XPopup; import com.opensource.svgaplayer.SVGACallback; import com.opensource.svgaplayer.SVGADrawable; import com.opensource.svgaplayer.SVGAImageView; @@ -728,8 +729,10 @@ public class LiveGiftDialogFragment extends AbsDialogFragment implements View.On } mBeanFromWish = null; } + if (bean.getType() != 9999999) { + itemCheckOp(bean); - itemCheckOp(bean); + } } private void itemCheckOp(LiveGiftBean bean) { diff --git a/live/src/main/java/com/yunbao/live/dialog/ReceiveRendPacketPopup.java b/live/src/main/java/com/yunbao/live/dialog/ReceiveRendPacketPopup.java new file mode 100644 index 000000000..6f6f8ce7e --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/ReceiveRendPacketPopup.java @@ -0,0 +1,76 @@ +package com.yunbao.live.dialog; + +import android.content.Context; +import android.os.Handler; +import android.widget.Button; +import android.widget.FrameLayout; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.XPopup; +import com.lxj.xpopup.core.CenterPopupView; +import com.yunbao.common.views.weight.CircleProgress; +import com.yunbao.common.views.weight.ViewClicksAntiShake; +import com.yunbao.live.R; + +public class ReceiveRendPacketPopup extends CenterPopupView { + private CircleProgress circleProgress; + private int time = 10; + private Button redPacketOpen; + private TextView redPacketTimeText; + private FrameLayout redPacketTimeLayout; + + public ReceiveRendPacketPopup(@NonNull Context context) { + super(context); + } + + // 返回自定义弹窗的布局离开 + @Override + protected int getImplLayoutId() { + return R.layout.view_receive_red_packet; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + initView(); + } + + private Handler timeHandler = new Handler(); + + private Runnable timeRunnable = new Runnable() { + @Override + public void run() { + if (time > 0) { + circleProgress.setCurrent(time--); + timeHandler.postDelayed(timeRunnable, 1000); + redPacketTimeText.setText(String.valueOf(time)); + } else { + redPacketTimeLayout.setVisibility(GONE); + redPacketOpen.setVisibility(VISIBLE); + + } + + } + }; + + private void initView() { + circleProgress = findViewById(R.id.circleProgress); + redPacketOpen = findViewById(R.id.red_packet_open); + redPacketTimeText = findViewById(R.id.red_packet_time_text); + redPacketTimeLayout = findViewById(R.id.red_packet_time_layout); + circleProgress.setMax(time); + circleProgress.setCurrent(time); + redPacketTimeText.setText(String.valueOf(time)); + timeHandler.postDelayed(timeRunnable, 1000); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.red_packet_open), () -> { + dismiss(); + new XPopup.Builder(getContext()) + .asCustom(new ResultRendPacketPopup(getContext())) + .show(); + }); + } + +} diff --git a/live/src/main/java/com/yunbao/live/dialog/ResultRendPacketPopup.java b/live/src/main/java/com/yunbao/live/dialog/ResultRendPacketPopup.java new file mode 100644 index 000000000..bef6d0c21 --- /dev/null +++ b/live/src/main/java/com/yunbao/live/dialog/ResultRendPacketPopup.java @@ -0,0 +1,46 @@ +package com.yunbao.live.dialog; + +import android.content.Context; +import android.os.Bundle; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.core.CenterPopupView; +import com.yunbao.common.Constants; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.views.weight.ViewClicksAntiShake; +import com.yunbao.live.R; +import com.yunbao.live.activity.LiveAudienceActivity; +import com.yunbao.live.event.LiveAudienceEvent; + +public class ResultRendPacketPopup extends CenterPopupView { + + + public ResultRendPacketPopup(@NonNull Context context) { + super(context); + } + + // 返回自定义弹窗的布局离开 + @Override + protected int getImplLayoutId() { + return R.layout.view_result_red_packet; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + initView(); + } + + + private void initView() { + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.illustrate_close), () -> dismiss()); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.anchor_his_heart), () -> { + dismiss(); + Bus.get().post(new LiveAudienceEvent() + .setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP)); + }); + } + +} diff --git a/live/src/main/java/com/yunbao/live/dialog/SendRendPacketPopup.java b/live/src/main/java/com/yunbao/live/dialog/SendRendPacketPopup.java index 35d9e9023..637581850 100644 --- a/live/src/main/java/com/yunbao/live/dialog/SendRendPacketPopup.java +++ b/live/src/main/java/com/yunbao/live/dialog/SendRendPacketPopup.java @@ -1,15 +1,21 @@ package com.yunbao.live.dialog; +import static com.yunbao.common.utils.RouteUtil.PATH_COIN; + import android.content.Context; import android.graphics.Color; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; +import android.view.View; import android.widget.Button; +import android.widget.FrameLayout; +import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; +import com.alibaba.android.arouter.launcher.ARouter; import com.lxj.xpopup.core.CenterPopupView; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; @@ -19,6 +25,8 @@ public class SendRendPacketPopup extends CenterPopupView { private Button thereIsNo, followingAnchor; private TextView redEnvelopeRill, totalConsumptionOfDrill; private TextView rill, total; + private FrameLayout redPacketIllustrate; + private ImageView iconInstructions, illustrateClose; public SendRendPacketPopup(@NonNull Context context) { super(context); @@ -42,6 +50,9 @@ public class SendRendPacketPopup extends CenterPopupView { followingAnchor = findViewById(R.id.following_anchor); redEnvelopeRill = findViewById(R.id.red_envelope_rill); totalConsumptionOfDrill = findViewById(R.id.total_consumption_of_drill); + redPacketIllustrate = findViewById(R.id.red_packet_illustrate); + illustrateClose = findViewById(R.id.illustrate_close); + iconInstructions = findViewById(R.id.icon_instructions); rill = findViewById(R.id.rill); total = findViewById(R.id.total); selectText(thereIsNo, true); @@ -132,6 +143,12 @@ public class SendRendPacketPopup extends CenterPopupView { //红包初始数量 rill.setText("200"); total.setText("10"); + ViewClicksAntiShake.clicksAntiShake(iconInstructions, () -> redPacketIllustrate.setVisibility(VISIBLE)); + ViewClicksAntiShake.clicksAntiShake(illustrateClose, () -> redPacketIllustrate.setVisibility(GONE)); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.top_up_now), () -> { + //我们的 + ARouter.getInstance().build(PATH_COIN).withInt("p", 0).navigation(); + }); } private void selectText(TextView textView, boolean select) { 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 8e2b51bfe..ad71c7aad 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -152,7 +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.dialog.ReceiveRendPacketPopup; import com.yunbao.live.event.LiveAnchorEvent; import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.event.LiveRoomChangeEvent; @@ -1414,7 +1414,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis @Override public void onViewClicks() { new XPopup.Builder(mContext) - .asCustom(new SendRendPacketPopup(mContext)) + .asCustom(new ReceiveRendPacketPopup(mContext)) .show(); } }); diff --git a/live/src/main/res/drawable/background_open_red_packet.xml b/live/src/main/res/drawable/background_open_red_packet.xml new file mode 100644 index 000000000..f2960d078 --- /dev/null +++ b/live/src/main/res/drawable/background_open_red_packet.xml @@ -0,0 +1,8 @@ + + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/background_red_packet_list.xml b/live/src/main/res/drawable/background_red_packet_list.xml new file mode 100644 index 000000000..ee77abdb0 --- /dev/null +++ b/live/src/main/res/drawable/background_red_packet_list.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/live/src/main/res/drawable/background_send_red_packet_illustrate.xml b/live/src/main/res/drawable/background_send_red_packet_illustrate.xml new file mode 100644 index 000000000..15df95357 --- /dev/null +++ b/live/src/main/res/drawable/background_send_red_packet_illustrate.xml @@ -0,0 +1,5 @@ + + + + + \ 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 9b80802ac..c1db541e4 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -746,7 +746,7 @@ android:translationX="-48dp" /> - + + + + + + + + + + + + + + + + + + +