新增H5网页跳转直播间并打开礼物栏选中礼物功能

This commit is contained in:
zlzw 2023-09-05 13:52:45 +08:00
parent e89e82483b
commit a5b0ee757c
7 changed files with 105 additions and 14 deletions

View File

@ -54,7 +54,8 @@ public class LiveBean implements Parcelable {
private String recommendCardIconSizeThree = ""; private String recommendCardIconSizeThree = "";
@SerializedName("red_packet_status") @SerializedName("red_packet_status")
private int redPacketStatus; private int redPacketStatus;
@SerializedName("giftId")
private String giftId;
private Map<String,String> params;//用于跳转Activity时扩展参数从首页Banner跳转到直播间时需要根据携带参数判断是否弹出新人特惠对话框 private Map<String,String> params;//用于跳转Activity时扩展参数从首页Banner跳转到直播间时需要根据携带参数判断是否弹出新人特惠对话框
public String getRecommendCardIconSizeTwo() { public String getRecommendCardIconSizeTwo() {
@ -66,6 +67,14 @@ public class LiveBean implements Parcelable {
return this; return this;
} }
public String getGiftId() {
return giftId;
}
public void setGiftId(String giftId) {
this.giftId = giftId;
}
public String getRecommendCardIcon() { public String getRecommendCardIcon() {
if (TextUtils.isEmpty(recommendCardIconSizeThree)) { if (TextUtils.isEmpty(recommendCardIconSizeThree)) {
if (!TextUtils.isEmpty(recommendCardIconSizeTwo)) { if (!TextUtils.isEmpty(recommendCardIconSizeTwo)) {
@ -444,6 +453,7 @@ public class LiveBean implements Parcelable {
this.recommendCardtype = in.readString(); this.recommendCardtype = in.readString();
this.recommendCardIconSizeTwo = in.readString(); this.recommendCardIconSizeTwo = in.readString();
this.recommendCardIconSizeThree = in.readString(); this.recommendCardIconSizeThree = in.readString();
this.giftId = in.readString();
} }
@Override @Override
@ -488,6 +498,7 @@ public class LiveBean implements Parcelable {
dest.writeString(this.recommendCardtype); dest.writeString(this.recommendCardtype);
dest.writeString(this.recommendCardIconSizeTwo); dest.writeString(this.recommendCardIconSizeTwo);
dest.writeString(this.recommendCardIconSizeThree); dest.writeString(this.recommendCardIconSizeThree);
dest.writeString(this.giftId);
} }
public static final Creator<LiveBean> CREATOR = new Creator<LiveBean>() { public static final Creator<LiveBean> CREATOR = new Creator<LiveBean>() {

View File

@ -17,13 +17,16 @@ import com.alibaba.fastjson.JSONObject;
import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants; import com.yunbao.common.Constants;
import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.ReportCommunityBean; import com.yunbao.common.bean.ReportCommunityBean;
import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserBean;
import com.yunbao.common.bean.VideoBean; import com.yunbao.common.bean.VideoBean;
import com.yunbao.common.bean.VideoListBean; import com.yunbao.common.bean.VideoListBean;
import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.event.JavascriptInterfaceEvent;
import com.yunbao.common.event.LiveRoomChangeEvent;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.interfaces.CommonCallback; import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
@ -253,6 +256,49 @@ public class JavascriptInterfaceUtils {
} }
/**
* 跳转直播并打开礼物栏选中礼物
* @param liveId 直播间id
* @param giftId 礼物id
*/
@JavascriptInterface
public void androidMethodLookToLiveGift(String liveId,String giftId){
LiveHttpUtil.getLiveInfo(liveId, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
if (liveBean == null) {
return;
}
liveBean.setGiftId(giftId);
new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
if (!"".endsWith(Constants.mStream)) {
if (MicStatusManager.getInstance().isMic(liveUid)) {
MicStatusManager.getInstance().showDownMicDialog(mContext);
return;
}
EventBus.getDefault().post(new LiveRoomChangeEvent(liveBean, liveType, Integer.parseInt(liveTypeVal)).setLiveEnd(true));
} else {
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveTypeVal), Integer.parseInt(liveSdk));
}
androidGoBack();
}
@Override
public void onCheckError(String contextError) {
}
});
}
}
});
}
@JavascriptInterface @JavascriptInterface
public void androidMethodLookToLive(String liveId) { public void androidMethodLookToLive(String liveId) {
Bus.get().post(new JavascriptInterfaceEvent() Bus.get().post(new JavascriptInterfaceEvent()
@ -550,28 +596,32 @@ public class JavascriptInterfaceUtils {
Bus.get().post(new JavascriptInterfaceEvent() Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("clickLogOffAccount")); .setMethod("clickLogOffAccount"));
} }
@JavascriptInterface @JavascriptInterface
public void androidFansGroupBuy(String id){ public void androidFansGroupBuy(String id) {
Bus.get().post(new JavascriptInterfaceEvent() Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("androidFansGroupBuy").setUserId(id)); .setMethod("androidFansGroupBuy").setUserId(id));
} }
@JavascriptInterface @JavascriptInterface
public void androidFansGroupPack(){ public void androidFansGroupPack() {
Bus.get().post(new JavascriptInterfaceEvent() Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("androidFansGroupPack")); .setMethod("androidFansGroupPack"));
} }
@JavascriptInterface @JavascriptInterface
public void androidFansGroupInfo(){ public void androidFansGroupInfo() {
Bus.get().post(new JavascriptInterfaceEvent() Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("androidFansGroupInfo")); .setMethod("androidFansGroupInfo"));
} }
@JavascriptInterface @JavascriptInterface
public void toGiftNamingAlertAllPageView(String mAnchorName, String mLiveUid, String mAvatarUrl,int isAnchor ) { public void toGiftNamingAlertAllPageView(String mAnchorName, String mLiveUid, String mAvatarUrl, int isAnchor) {
RouteUtil.forwardGiftWallActivity("", mAnchorName, mLiveUid, mAvatarUrl, 0,isAnchor==1); RouteUtil.forwardGiftWallActivity("", mAnchorName, mLiveUid, mAvatarUrl, 0, isAnchor == 1);
} }
@JavascriptInterface @JavascriptInterface
public void wearOrCancelFanMedal(){ public void wearOrCancelFanMedal() {
HttpClient.getInstance().get("User.getBaseInfos", "getBaseInfo") HttpClient.getInstance().get("User.getBaseInfos", "getBaseInfo")
.params("uid", IMLoginManager.get(mContext).getUserInfo().getId()) .params("uid", IMLoginManager.get(mContext).getUserInfo().getId())
.params("token", IMLoginManager.get(mContext).getUserInfo().getToken()) .params("token", IMLoginManager.get(mContext).getUserInfo().getToken())
@ -587,8 +637,9 @@ public class JavascriptInterfaceUtils {
} }
}); });
} }
@JavascriptInterface @JavascriptInterface
public void androidCancelAnchorAttention(){ public void androidCancelAnchorAttention() {
Bus.get().post(new JavascriptInterfaceEvent() Bus.get().post(new JavascriptInterfaceEvent()
.setMethod("androidCancelAnchorAttention")); .setMethod("androidCancelAnchorAttention"));
} }

View File

@ -107,6 +107,7 @@ import com.yunbao.live.event.LinkMicTxAccEvent;
import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.event.LiveAudienceEvent;
import com.yunbao.live.http.ImHttpUtil; import com.yunbao.live.http.ImHttpUtil;
import com.yunbao.live.views.LiveRoomPlayViewHolder; import com.yunbao.live.views.LiveRoomPlayViewHolder;
import com.yunbao.live.views.LiveRoomViewHolder;
import com.yunbao.live.views.PortraitLiveManager; import com.yunbao.live.views.PortraitLiveManager;
import com.yunbao.share.ui.SharePopDialog; import com.yunbao.share.ui.SharePopDialog;
@ -393,9 +394,11 @@ public class LiveAudienceActivity extends LiveActivity {
mLiveTypeVal = 0; mLiveTypeVal = 0;
} }
mLiveType = liveType; mLiveType = liveType;
String giftId=mLiveBean.getGiftId();
String json = GsonUtils.toJson(data); String json = GsonUtils.toJson(data);
mLiveBean = GsonUtils.fromJson(json, LiveBean.class); mLiveBean = GsonUtils.fromJson(json, LiveBean.class);
mLiveBean.setUserNiceName(data.getUserNicename()); mLiveBean.setUserNiceName(data.getUserNicename());
mLiveBean.setGiftId(giftId);
mLiveUid = mLiveBean.getUid(); mLiveUid = mLiveBean.getUid();
mStream = mLiveBean.getStream(); mStream = mLiveBean.getStream();
mAncherName = mLiveBean.getUserNiceName(); mAncherName = mLiveBean.getUserNiceName();
@ -729,6 +732,9 @@ public class LiveAudienceActivity extends LiveActivity {
if (e.isLiveEnd()) { if (e.isLiveEnd()) {
manager.removeLiveEnd(); manager.removeLiveEnd();
} }
if (LiveRoomViewHolder.mHandler != null) {
LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null);
}
if (liveBean != null) { if (liveBean != null) {
LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE); LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE);
LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM); LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM);

View File

@ -57,4 +57,9 @@ public class GiftTitleAdapter extends RecyclerView.Adapter {
index = -1; index = -1;
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void setTitleIndex(int i) {
index=i;
notifyDataSetChanged();
}
} }

View File

@ -142,6 +142,7 @@ public class LiveGiftPopup extends AbsDialogFragment {
Bus.getOff(this); Bus.getOff(this);
} }
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
private void initView() { private void initView() {
gitBackground = mRootView.findViewById(R.id.git_background2); gitBackground = mRootView.findViewById(R.id.git_background2);
@ -204,19 +205,19 @@ public class LiveGiftPopup extends AbsDialogFragment {
levelingLayout.setVisibility(View.VISIBLE); levelingLayout.setVisibility(View.VISIBLE);
updateOverlayVisibility(); updateOverlayVisibility();
blindBox.setOnTouchListener((v, event) -> { blindBox.setOnTouchListener((v, event) -> {
if(event.getAction()==MotionEvent.ACTION_UP) { if (event.getAction() == MotionEvent.ACTION_UP) {
v.performClick(); v.performClick();
} }
return true; return true;
}); });
namingLayout.setOnTouchListener((v, event) -> { namingLayout.setOnTouchListener((v, event) -> {
if(event.getAction()==MotionEvent.ACTION_UP) { if (event.getAction() == MotionEvent.ACTION_UP) {
v.performClick(); v.performClick();
} }
return true; return true;
}); });
operateImage.setOnTouchListener((v, event) -> { operateImage.setOnTouchListener((v, event) -> {
if(event.getAction()==MotionEvent.ACTION_UP) { if (event.getAction() == MotionEvent.ACTION_UP) {
v.performClick(); v.performClick();
} }
return true; return true;
@ -274,7 +275,7 @@ public class LiveGiftPopup extends AbsDialogFragment {
IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo(); IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo();
StringBuffer htmlUrl = new StringBuffer(); StringBuffer htmlUrl = new StringBuffer();
htmlUrl.append(CommonAppConfig.HOST) htmlUrl.append(CommonAppConfig.HOST)
.append("/h5/info/index.html?uid=") .append("/h5/blindBoxInfo/index.html?uid=")
.append(userInfo.getId()) .append(userInfo.getId())
.append("&token=") .append("&token=")
.append(userInfo.getToken()) .append(userInfo.getToken())
@ -419,6 +420,8 @@ public class LiveGiftPopup extends AbsDialogFragment {
liveGiftList.getJSONObject(i).getString("name"), liveGiftList.getJSONObject(i).getString("name"),
mStream, mLiveUid, mWishGiftId)); mStream, mLiveUid, mWishGiftId));
transaction.commit(); transaction.commit();
giftTitleAdapter.setTitleIndex(i);
break;
} }
} }
} }
@ -811,7 +814,7 @@ public class LiveGiftPopup extends AbsDialogFragment {
if (!TextUtils.isEmpty(liveGiftModel.getOperateImage())) { if (!TextUtils.isEmpty(liveGiftModel.getOperateImage())) {
operateImage.setVisibility(View.VISIBLE); operateImage.setVisibility(View.VISIBLE);
ImgLoader.display(getContext(), liveGiftModel.getOperateImage(), operateImage); ImgLoader.display(getContext(), liveGiftModel.getOperateImage(), operateImage);
}else { } else {
operateImage.setVisibility(View.GONE); operateImage.setVisibility(View.GONE);
} }

View File

@ -154,6 +154,7 @@ import com.yunbao.live.dialog.LiveContactDetailsSendGiftDialog;
import com.yunbao.live.dialog.LiveFaceUnityDialogFragment; import com.yunbao.live.dialog.LiveFaceUnityDialogFragment;
import com.yunbao.live.dialog.LiveFansMedalDialogFragment; import com.yunbao.live.dialog.LiveFansMedalDialogFragment;
import com.yunbao.live.dialog.LiveGameDialogFragment; import com.yunbao.live.dialog.LiveGameDialogFragment;
import com.yunbao.live.dialog.LiveGiftPopup;
import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveHDDialogFragment;
import com.yunbao.live.dialog.LiveUserAnchorMailBoxWebInfoPopDialog; import com.yunbao.live.dialog.LiveUserAnchorMailBoxWebInfoPopDialog;
import com.yunbao.live.dialog.LiveUserDialogFragment; import com.yunbao.live.dialog.LiveUserDialogFragment;
@ -3941,6 +3942,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
voteManager.setCreateVoteModel(voteModel); voteManager.setCreateVoteModel(voteModel);
} }
public void openGiftDialog(String giftId) {
Bus.get().post(new LiveAudienceEvent()
.setType(LiveAudienceEvent.LiveAudienceType.GIFT_POPUP)
.setmLiveUid(mLiveUid)
.setmStream(mStream)
.setPk(false)
.setLiveGuardInfo(null)
.setmWishGiftId(giftId)
.setUname("0"));//setUname==by
}
private static class LiveRoomHandler extends Handler { private static class LiveRoomHandler extends Handler {

View File

@ -64,6 +64,7 @@ import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.MicStatusManager;
import com.yunbao.common.utils.RandomUtil; import com.yunbao.common.utils.RandomUtil;
import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.formatBigNum; import com.yunbao.common.utils.formatBigNum;
import com.yunbao.common.views.weight.LiveFloatView; import com.yunbao.common.views.weight.LiveFloatView;
@ -284,7 +285,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
@Override @Override
public void run() { public void run() {
try { try {
Log.e("ImgLoader1", data.getAvatar()); Log.e("ImgLoader1", data.getAvatar());
if (mLiveRyLinkMicPkPresenter != null) { if (mLiveRyLinkMicPkPresenter != null) {
mLiveRyLinkMicPkPresenter.clearData(); mLiveRyLinkMicPkPresenter.clearData();
@ -447,6 +447,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
mLiveRoomViewHolder.setUserList(data.getEnterRoomInfo().getUserlists()); mLiveRoomViewHolder.setUserList(data.getEnterRoomInfo().getUserlists());
//设置靓号 //设置靓号
mLiveRoomViewHolder.setAnchorGoodNumber(data.getLiveInfo().getGoodnum()); mLiveRoomViewHolder.setAnchorGoodNumber(data.getLiveInfo().getGoodnum());
if(!StringUtil.isEmpty(mLiveBean.getGiftId())){
mLiveRoomViewHolder.openGiftDialog(mLiveBean.getGiftId());
}
List<BannerBean> bannerBeans = new ArrayList<>(); List<BannerBean> bannerBeans = new ArrayList<>();
//心愿单 //心愿单
// if (data.getWishList().getWishList().size() > 0) { // if (data.getWishList().getWishList().size() > 0) {