展示红包,领取红包接口逻辑对接
This commit is contained in:
parent
e68d20252a
commit
5736265388
@ -41,11 +41,15 @@ public class RedPacketInfoModel extends BaseModel {
|
||||
private String userExists;
|
||||
@SerializedName("is_attention")
|
||||
private String isAttention;
|
||||
//0.未领取到 1.领取但是没抢过东西 2.已经领抢到东西
|
||||
@SerializedName("receive_status")
|
||||
private String receiveStatus;
|
||||
|
||||
public String getIsAttention() {
|
||||
return isAttention;
|
||||
}
|
||||
|
||||
|
||||
public RedPacketInfoModel setIsAttention(String isAttention) {
|
||||
this.isAttention = isAttention;
|
||||
return this;
|
||||
@ -56,6 +60,26 @@ public class RedPacketInfoModel extends BaseModel {
|
||||
|
||||
@SerializedName("red_packet_gift")
|
||||
private List<RedPacketGiftModel> packetGiftModels;
|
||||
@SerializedName("gift")
|
||||
private List<RedPacketGiftModel> giftModels;
|
||||
|
||||
public String getReceiveStatus() {
|
||||
return receiveStatus;
|
||||
}
|
||||
|
||||
public RedPacketInfoModel setReceiveStatus(String receiveStatus) {
|
||||
this.receiveStatus = receiveStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<RedPacketGiftModel> getGiftModels() {
|
||||
return giftModels;
|
||||
}
|
||||
|
||||
public RedPacketInfoModel setGiftModels(List<RedPacketGiftModel> giftModels) {
|
||||
this.giftModels = giftModels;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<RedPacketGiftModel> getPacketGiftModels() {
|
||||
return packetGiftModels;
|
||||
|
@ -751,4 +751,16 @@ public interface PDLiveApi {
|
||||
@Query("liveuid") String liveUid,
|
||||
@Query("red_packet_id") String redPacketId
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取盲盒礼物当前数据
|
||||
*/
|
||||
@GET("/api/public/?service=Live.getRedPacket")
|
||||
Observable<ResponseModel<RedPacketInfoModel>> getRedPacket(
|
||||
@Query("liveuid") String liveUid,
|
||||
@Query("stream") String stream,
|
||||
@Query("red_packet_id") String redPacketId
|
||||
);
|
||||
}
|
||||
|
@ -1603,6 +1603,28 @@ public class LiveNetManager {
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 领取红包
|
||||
*
|
||||
* @param liveUid 直播间id
|
||||
* @param redPacketId 红包id
|
||||
*/
|
||||
public void getRedPacket(String liveUid,String stream, String redPacketId, HttpCallback<RedPacketInfoModel> callback) {
|
||||
API.get().pdLiveApi(mContext)
|
||||
.getRedPacket(liveUid, stream,redPacketId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(redPacketInfoModelResponseModel -> {
|
||||
if (callback != null) {
|
||||
callback.onSuccess(redPacketInfoModelResponseModel.getData().getInfo());
|
||||
}
|
||||
}, throwable -> {
|
||||
if (callback != null) {
|
||||
callback.onError(mContext.getString(R.string.net_error));
|
||||
}
|
||||
}).isDisposed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 直播间取消网络请求
|
||||
*/
|
||||
|
@ -1226,4 +1226,6 @@ Limited ride And limited avatar frame</string>
|
||||
<string name="red_packet_countdown">倒計時:%s</string>
|
||||
<string name="open_red_packet">待開紅包:%s</string>
|
||||
<string name="together_to_achieve_goal">來自%s的獎勵,齊心協力連成目標</string>
|
||||
<string name="red_too_bad">很遺憾</string>
|
||||
<string name="red_too_bad2">與紅包擦肩而過</string>
|
||||
</resources>
|
||||
|
@ -24,7 +24,6 @@ import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.utils.TimeUtils;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.views.weight.CircleProgress;
|
||||
import com.yunbao.common.views.weight.ClipPathCircleImage;
|
||||
import com.yunbao.common.views.weight.ViewClicksAntiShake;
|
||||
@ -37,18 +36,24 @@ public class ReceiveRendPacketPopup extends CenterPopupView {
|
||||
private Button redPacketOpen;
|
||||
private TextView redPacketTimeText, receiveRed, redPacketValue;
|
||||
private FrameLayout redPacketTimeLayout;
|
||||
private String mLiveUid, redPacketId, userID;
|
||||
private String mLiveUid,stream, redPacketId, userID;
|
||||
private ClipPathCircleImage headPortrait;
|
||||
private RecyclerView redPacketGiftList;
|
||||
private RedPacketGiftAdapter redPacketGiftAdapter;
|
||||
private ImageView isAttention;
|
||||
private RedPacketInfoModel redPacketInfoModel;
|
||||
|
||||
public ReceiveRendPacketPopup(@NonNull Context context, int time, String mLiveUid, String redPacketId) {
|
||||
|
||||
public ReceiveRendPacketPopup(@NonNull Context context, int time, String mLiveUid,String stream,
|
||||
String redPacketId, RedPacketInfoModel redPacketInfoModel) {
|
||||
|
||||
super(context);
|
||||
this.time = time;
|
||||
this.mLiveUid = mLiveUid;
|
||||
this.stream = stream;
|
||||
this.redPacketId = redPacketId;
|
||||
this.redPacketInfoModel = redPacketInfoModel;
|
||||
|
||||
}
|
||||
|
||||
// 返回自定义弹窗的布局离开
|
||||
@ -66,31 +71,20 @@ public class ReceiveRendPacketPopup extends CenterPopupView {
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
LiveNetManager.get(getContext())
|
||||
.redPacketInfo(mLiveUid, redPacketId, new HttpCallback<RedPacketInfoModel>() {
|
||||
@Override
|
||||
public void onSuccess(RedPacketInfoModel data) {
|
||||
ImgLoader.displayAvatar(getContext(), data.getAvatar(), headPortrait);
|
||||
ImgLoader.displayAvatar(getContext(), redPacketInfoModel.getAvatar(), headPortrait);
|
||||
receiveRed.setText(String.format(getContext()
|
||||
.getString(R.string.together_to_achieve_goal),
|
||||
data.getUserNicename()));
|
||||
redPacketValue.setText(data.getAmountDiamond());
|
||||
redPacketGiftAdapter.addData(data.getPacketGiftModels());
|
||||
redPacketInfoModel.getUserNicename()));
|
||||
redPacketValue.setText(redPacketInfoModel.getAmountDiamond());
|
||||
redPacketGiftAdapter.addData(redPacketInfoModel.getPacketGiftModels());
|
||||
IMLoginModel userInfo = IMLoginManager.get(getContext()).getUserInfo();
|
||||
if (TextUtils.equals(String.valueOf(userInfo.getId()), data.getUid())) {
|
||||
if (TextUtils.equals(String.valueOf(userInfo.getId()), redPacketInfoModel.getUid())) {
|
||||
isAttention.setVisibility(GONE);
|
||||
} else {
|
||||
isAttention.setVisibility(TextUtils.equals(data.getIsAttention(), "0") ? VISIBLE : GONE);
|
||||
isAttention.setVisibility(TextUtils.equals(redPacketInfoModel.getIsAttention(), "0") ? VISIBLE : GONE);
|
||||
}
|
||||
|
||||
userID = data.getUserId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
userID = redPacketInfoModel.getUserId();
|
||||
}
|
||||
|
||||
private Handler timeHandler = new Handler();
|
||||
@ -147,10 +141,25 @@ public class ReceiveRendPacketPopup extends CenterPopupView {
|
||||
}
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.red_packet_open), () -> {
|
||||
LiveNetManager.get(getContext())
|
||||
.getRedPacket(mLiveUid, stream,redPacketId, new HttpCallback<RedPacketInfoModel>() {
|
||||
@Override
|
||||
public void onSuccess(RedPacketInfoModel data) {
|
||||
dismiss();
|
||||
new XPopup.Builder(getContext())
|
||||
.asCustom(new ResultRendPacketPopup(getContext()))
|
||||
.asCustom(new ResultRendPacketPopup(getContext(), false, data))
|
||||
.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
dismiss();
|
||||
new XPopup.Builder(getContext())
|
||||
.asCustom(new ResultRendPacketPopup(getContext(), true, null))
|
||||
.show();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(isAttention, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
@ -166,6 +175,7 @@ public class ReceiveRendPacketPopup extends CenterPopupView {
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,30 +1,40 @@
|
||||
package com.yunbao.live.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.lxj.xpopup.core.CenterPopupView;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.bean.RedPacketInfoModel;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
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 {
|
||||
|
||||
private boolean noData;
|
||||
private RedPacketInfoModel redPacketInfoModel;
|
||||
|
||||
public ResultRendPacketPopup(@NonNull Context context) {
|
||||
public ResultRendPacketPopup(@NonNull Context context, boolean noData, RedPacketInfoModel redPacketInfoModel) {
|
||||
super(context);
|
||||
this.redPacketInfoModel = redPacketInfoModel;
|
||||
this.noData = noData;
|
||||
}
|
||||
|
||||
// 返回自定义弹窗的布局离开
|
||||
@Override
|
||||
protected int getImplLayoutId() {
|
||||
if (noData) {
|
||||
return R.layout.view_no_red_packet;
|
||||
} else {
|
||||
return R.layout.view_result_red_packet;
|
||||
}
|
||||
}
|
||||
|
||||
// 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑
|
||||
@Override
|
||||
@ -35,12 +45,46 @@ public class ResultRendPacketPopup extends CenterPopupView {
|
||||
|
||||
|
||||
private void initView() {
|
||||
if (noData) {
|
||||
|
||||
} else {
|
||||
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));
|
||||
});
|
||||
LinearLayout goldenLayout = findViewById(R.id.golden_layout);
|
||||
TextView goldenName = findViewById(R.id.golden_name);
|
||||
LinearLayout giftLayout = findViewById(R.id.gift_layout);
|
||||
TextView giftTitle = findViewById(R.id.gift_title);
|
||||
ImageView giftImage = findViewById(R.id.gift_image);
|
||||
ImageView goldenIconBeans = findViewById(R.id.golden_icon_beans);
|
||||
if (redPacketInfoModel.getGiftModels() != null) {
|
||||
if (redPacketInfoModel.getGiftModels().size() > 1) {
|
||||
goldenLayout.setVisibility(VISIBLE);
|
||||
giftLayout.setVisibility(VISIBLE);
|
||||
giftTitle.setText(redPacketInfoModel.getGiftModels().get(0).getGiftname());
|
||||
ImgLoader.displayAvatar(getContext(), redPacketInfoModel.getGiftModels().get(0).getGifticon(), giftImage);
|
||||
ImgLoader.displayAvatar(getContext(), redPacketInfoModel.getGiftModels().get(1).getGifticon(), goldenIconBeans);
|
||||
goldenName.setText(redPacketInfoModel.getGiftModels().get(1).getGiftname());
|
||||
} else {
|
||||
if (redPacketInfoModel.getGiftModels().size() > 0) {
|
||||
ImgLoader.displayAvatar(getContext(), redPacketInfoModel.getGiftModels().get(0).getGifticon(), goldenIconBeans);
|
||||
goldenName.setText(redPacketInfoModel.getGiftModels().get(0).getGiftname());
|
||||
}
|
||||
goldenLayout.setVisibility(VISIBLE);
|
||||
giftLayout.setVisibility(GONE);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.view_lucky_viewers), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -83,6 +83,7 @@ import com.yunbao.common.bean.MsgModel;
|
||||
import com.yunbao.common.bean.NewPeopleTaskModel;
|
||||
import com.yunbao.common.bean.PkRankBean;
|
||||
import com.yunbao.common.bean.RankHourModel;
|
||||
import com.yunbao.common.bean.RedPacketInfoModel;
|
||||
import com.yunbao.common.bean.RedPacketModel;
|
||||
import com.yunbao.common.bean.RewardAllModel;
|
||||
import com.yunbao.common.bean.StarChallengeStatusModel;
|
||||
@ -155,6 +156,7 @@ import com.yunbao.live.dialog.LiveUserAnchorMailBoxWebInfoPopDialog;
|
||||
import com.yunbao.live.dialog.LiveUserDialogFragment;
|
||||
import com.yunbao.live.dialog.LiveWishListDialogFragment4Audience;
|
||||
import com.yunbao.live.dialog.ReceiveRendPacketPopup;
|
||||
import com.yunbao.live.dialog.ResultRendPacketPopup;
|
||||
import com.yunbao.live.event.LiveAnchorEvent;
|
||||
import com.yunbao.live.event.LiveAudienceEvent;
|
||||
import com.yunbao.live.event.LiveRoomChangeEvent;
|
||||
@ -1413,7 +1415,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
redPacketQueue.setVisibility(View.GONE);
|
||||
redPacketCountdown.setVisibility(View.VISIBLE);
|
||||
redTimeCountdown = redPacketModel.getCountdown() - 180;
|
||||
redPacketCountdown.setText(TimeUtils.getTime(redTimeCountdown));
|
||||
redPacketCountdown.setText(String.format(mContext.getString(R.string.red_packet_countdown), TimeUtils.getTime(redTimeCountdown)));
|
||||
timeHandler.postDelayed(timeRunnable, 1000);
|
||||
} else {
|
||||
redPacketQueue.setVisibility(View.VISIBLE);
|
||||
@ -1426,9 +1428,35 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.red_packet), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
LiveNetManager.get(mContext)
|
||||
.redPacketInfo(mLiveUid, redPacketModel.getRedPacketId(), new com.yunbao.common.http.base.HttpCallback<RedPacketInfoModel>() {
|
||||
@Override
|
||||
public void onSuccess(RedPacketInfoModel data) {
|
||||
if (TextUtils.equals(data.getReceiveStatus(), "0")) {
|
||||
new XPopup.Builder(mContext)
|
||||
.asCustom(new ReceiveRendPacketPopup(mContext, redTimeCountdown, mLiveUid, redPacketModel.getRedPacketId()))
|
||||
.asCustom(new ReceiveRendPacketPopup(mContext, redTimeCountdown, mLiveUid, mStream, redPacketModel.getRedPacketId(), data))
|
||||
.show();
|
||||
} else if (TextUtils.equals(data.getReceiveStatus(), "1")) {
|
||||
new XPopup.Builder(mContext)
|
||||
.asCustom(new ResultRendPacketPopup(mContext, true, null))
|
||||
.show();
|
||||
} else {
|
||||
new XPopup.Builder(mContext)
|
||||
.asCustom(new ResultRendPacketPopup(mContext, false, data))
|
||||
.show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
new XPopup.Builder(mContext)
|
||||
.asCustom(new ResultRendPacketPopup(mContext, true, null))
|
||||
.show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
49
live/src/main/res/layout/view_no_red_packet.xml
Normal file
49
live/src/main/res/layout/view_no_red_packet.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:animateLayoutChanges="true"
|
||||
android:background="@mipmap/background_red_packet"
|
||||
android:backgroundTintMode="src_over">
|
||||
<!--伤心-->
|
||||
<ImageView
|
||||
android:layout_width="74dp"
|
||||
android:layout_height="106dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="89dp"
|
||||
android:src="@mipmap/icon_grieved_red_packet" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal|bottom"
|
||||
android:layout_marginBottom="80dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="15dp"
|
||||
android:text="@string/red_too_bad"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/red_too_bad2"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="18sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_lucky_viewers"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="30dp"
|
||||
android:text="@string/view_lucky_viewers"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp" />
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
@ -30,7 +30,21 @@
|
||||
android:textSize="18sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/gift_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="31dp"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/gift_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="34dp"
|
||||
@ -39,12 +53,40 @@
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/gift_image"
|
||||
android:layout_width="75dp"
|
||||
android:layout_height="75dp"
|
||||
android:layout_marginTop="13dp"
|
||||
android:src="@mipmap/hide" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/golden_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/golden_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="34dp"
|
||||
android:text="@string/cred_envelope_obtained"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/golden_icon_beans"
|
||||
android:layout_width="75dp"
|
||||
android:layout_height="75dp"
|
||||
android:layout_marginTop="13dp"
|
||||
android:src="@mipmap/icon_beans" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/view_lucky_viewers"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="40dp"
|
||||
|
BIN
live/src/main/res/mipmap-xhdpi/icon_grieved_red_packet.png
Normal file
BIN
live/src/main/res/mipmap-xhdpi/icon_grieved_red_packet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.8 KiB |
Loading…
Reference in New Issue
Block a user