diff --git a/common/src/main/java/com/yunbao/common/bean/LiveBean.java b/common/src/main/java/com/yunbao/common/bean/LiveBean.java index f4cec2ec4..11de89a26 100644 --- a/common/src/main/java/com/yunbao/common/bean/LiveBean.java +++ b/common/src/main/java/com/yunbao/common/bean/LiveBean.java @@ -54,7 +54,8 @@ public class LiveBean implements Parcelable { private String recommendCardIconSizeThree = ""; @SerializedName("red_packet_status") private int redPacketStatus; - + @SerializedName("giftId") + private String giftId; private Map params;//用于跳转Activity时扩展参数,例:从首页Banner跳转到直播间时需要根据携带参数判断是否弹出新人特惠对话框 public String getRecommendCardIconSizeTwo() { @@ -66,6 +67,14 @@ public class LiveBean implements Parcelable { return this; } + public String getGiftId() { + return giftId; + } + + public void setGiftId(String giftId) { + this.giftId = giftId; + } + public String getRecommendCardIcon() { if (TextUtils.isEmpty(recommendCardIconSizeThree)) { if (!TextUtils.isEmpty(recommendCardIconSizeTwo)) { @@ -444,6 +453,7 @@ public class LiveBean implements Parcelable { this.recommendCardtype = in.readString(); this.recommendCardIconSizeTwo = in.readString(); this.recommendCardIconSizeThree = in.readString(); + this.giftId = in.readString(); } @Override @@ -488,6 +498,7 @@ public class LiveBean implements Parcelable { dest.writeString(this.recommendCardtype); dest.writeString(this.recommendCardIconSizeTwo); dest.writeString(this.recommendCardIconSizeThree); + dest.writeString(this.giftId); } public static final Creator CREATOR = new Creator() { diff --git a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java index 2b3ef2ea1..fe911bd3b 100644 --- a/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java +++ b/common/src/main/java/com/yunbao/common/utils/JavascriptInterfaceUtils.java @@ -17,13 +17,16 @@ import com.alibaba.fastjson.JSONObject; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.Constants; import com.yunbao.common.bean.IMLoginModel; +import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.ReportCommunityBean; import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.VideoBean; import com.yunbao.common.bean.VideoListBean; import com.yunbao.common.event.JavascriptInterfaceEvent; +import com.yunbao.common.event.LiveRoomChangeEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; +import com.yunbao.common.http.LiveHttpUtil; import com.yunbao.common.interfaces.CommonCallback; 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 public void androidMethodLookToLive(String liveId) { Bus.get().post(new JavascriptInterfaceEvent() @@ -550,28 +596,32 @@ public class JavascriptInterfaceUtils { Bus.get().post(new JavascriptInterfaceEvent() .setMethod("clickLogOffAccount")); } + @JavascriptInterface - public void androidFansGroupBuy(String id){ + public void androidFansGroupBuy(String id) { Bus.get().post(new JavascriptInterfaceEvent() .setMethod("androidFansGroupBuy").setUserId(id)); } + @JavascriptInterface - public void androidFansGroupPack(){ + public void androidFansGroupPack() { Bus.get().post(new JavascriptInterfaceEvent() .setMethod("androidFansGroupPack")); } + @JavascriptInterface - public void androidFansGroupInfo(){ + public void androidFansGroupInfo() { Bus.get().post(new JavascriptInterfaceEvent() .setMethod("androidFansGroupInfo")); } @JavascriptInterface - public void toGiftNamingAlertAllPageView(String mAnchorName, String mLiveUid, String mAvatarUrl,int isAnchor ) { - RouteUtil.forwardGiftWallActivity("", mAnchorName, mLiveUid, mAvatarUrl, 0,isAnchor==1); + public void toGiftNamingAlertAllPageView(String mAnchorName, String mLiveUid, String mAvatarUrl, int isAnchor) { + RouteUtil.forwardGiftWallActivity("", mAnchorName, mLiveUid, mAvatarUrl, 0, isAnchor == 1); } + @JavascriptInterface - public void wearOrCancelFanMedal(){ + public void wearOrCancelFanMedal() { HttpClient.getInstance().get("User.getBaseInfos", "getBaseInfo") .params("uid", IMLoginManager.get(mContext).getUserInfo().getId()) .params("token", IMLoginManager.get(mContext).getUserInfo().getToken()) @@ -587,8 +637,9 @@ public class JavascriptInterfaceUtils { } }); } + @JavascriptInterface - public void androidCancelAnchorAttention(){ + public void androidCancelAnchorAttention() { Bus.get().post(new JavascriptInterfaceEvent() .setMethod("androidCancelAnchorAttention")); } diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index 721fbc339..f75420333 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -107,6 +107,7 @@ import com.yunbao.live.event.LinkMicTxAccEvent; import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.http.ImHttpUtil; import com.yunbao.live.views.LiveRoomPlayViewHolder; +import com.yunbao.live.views.LiveRoomViewHolder; import com.yunbao.live.views.PortraitLiveManager; import com.yunbao.share.ui.SharePopDialog; @@ -393,9 +394,11 @@ public class LiveAudienceActivity extends LiveActivity { mLiveTypeVal = 0; } mLiveType = liveType; + String giftId=mLiveBean.getGiftId(); String json = GsonUtils.toJson(data); mLiveBean = GsonUtils.fromJson(json, LiveBean.class); mLiveBean.setUserNiceName(data.getUserNicename()); + mLiveBean.setGiftId(giftId); mLiveUid = mLiveBean.getUid(); mStream = mLiveBean.getStream(); mAncherName = mLiveBean.getUserNiceName(); @@ -729,6 +732,9 @@ public class LiveAudienceActivity extends LiveActivity { if (e.isLiveEnd()) { manager.removeLiveEnd(); } + if (LiveRoomViewHolder.mHandler != null) { + LiveRoomViewHolder.mHandler.removeCallbacksAndMessages(null); + } if (liveBean != null) { LiveHttpUtil.cancel(LiveHttpConsts.CHECK_LIVE); LiveHttpUtil.cancel(LiveHttpConsts.ENTER_ROOM); diff --git a/live/src/main/java/com/yunbao/live/adapter/GiftTitleAdapter.java b/live/src/main/java/com/yunbao/live/adapter/GiftTitleAdapter.java index 898b9da7c..8fd98d842 100644 --- a/live/src/main/java/com/yunbao/live/adapter/GiftTitleAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/GiftTitleAdapter.java @@ -57,4 +57,9 @@ public class GiftTitleAdapter extends RecyclerView.Adapter { index = -1; notifyDataSetChanged(); } + + public void setTitleIndex(int i) { + index=i; + notifyDataSetChanged(); + } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java index fc77d3e30..df718ade1 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup.java @@ -142,6 +142,7 @@ public class LiveGiftPopup extends AbsDialogFragment { Bus.getOff(this); } + @SuppressLint("ClickableViewAccessibility") private void initView() { gitBackground = mRootView.findViewById(R.id.git_background2); @@ -204,19 +205,19 @@ public class LiveGiftPopup extends AbsDialogFragment { levelingLayout.setVisibility(View.VISIBLE); updateOverlayVisibility(); blindBox.setOnTouchListener((v, event) -> { - if(event.getAction()==MotionEvent.ACTION_UP) { + if (event.getAction() == MotionEvent.ACTION_UP) { v.performClick(); } return true; }); namingLayout.setOnTouchListener((v, event) -> { - if(event.getAction()==MotionEvent.ACTION_UP) { + if (event.getAction() == MotionEvent.ACTION_UP) { v.performClick(); } return true; }); operateImage.setOnTouchListener((v, event) -> { - if(event.getAction()==MotionEvent.ACTION_UP) { + if (event.getAction() == MotionEvent.ACTION_UP) { v.performClick(); } return true; @@ -274,7 +275,7 @@ public class LiveGiftPopup extends AbsDialogFragment { IMLoginModel userInfo = IMLoginManager.get(mContext).getUserInfo(); StringBuffer htmlUrl = new StringBuffer(); htmlUrl.append(CommonAppConfig.HOST) - .append("/h5/info/index.html?uid=") + .append("/h5/blindBoxInfo/index.html?uid=") .append(userInfo.getId()) .append("&token=") .append(userInfo.getToken()) @@ -419,6 +420,8 @@ public class LiveGiftPopup extends AbsDialogFragment { liveGiftList.getJSONObject(i).getString("name"), mStream, mLiveUid, mWishGiftId)); transaction.commit(); + giftTitleAdapter.setTitleIndex(i); + break; } } } @@ -811,7 +814,7 @@ public class LiveGiftPopup extends AbsDialogFragment { if (!TextUtils.isEmpty(liveGiftModel.getOperateImage())) { operateImage.setVisibility(View.VISIBLE); ImgLoader.display(getContext(), liveGiftModel.getOperateImage(), operateImage); - }else { + } else { operateImage.setVisibility(View.GONE); } 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 4e780859d..586f8e8de 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -154,6 +154,7 @@ import com.yunbao.live.dialog.LiveContactDetailsSendGiftDialog; import com.yunbao.live.dialog.LiveFaceUnityDialogFragment; import com.yunbao.live.dialog.LiveFansMedalDialogFragment; import com.yunbao.live.dialog.LiveGameDialogFragment; +import com.yunbao.live.dialog.LiveGiftPopup; import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveUserAnchorMailBoxWebInfoPopDialog; import com.yunbao.live.dialog.LiveUserDialogFragment; @@ -3941,6 +3942,17 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis 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 { diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index d4b8cdb8d..cc249fe40 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -64,6 +64,7 @@ import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.MicStatusManager; import com.yunbao.common.utils.RandomUtil; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.formatBigNum; import com.yunbao.common.views.weight.LiveFloatView; @@ -284,7 +285,6 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe @Override public void run() { try { - Log.e("ImgLoader1", data.getAvatar()); if (mLiveRyLinkMicPkPresenter != null) { mLiveRyLinkMicPkPresenter.clearData(); @@ -447,6 +447,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe mLiveRoomViewHolder.setUserList(data.getEnterRoomInfo().getUserlists()); //设置靓号 mLiveRoomViewHolder.setAnchorGoodNumber(data.getLiveInfo().getGoodnum()); + if(!StringUtil.isEmpty(mLiveBean.getGiftId())){ + mLiveRoomViewHolder.openGiftDialog(mLiveBean.getGiftId()); + } List bannerBeans = new ArrayList<>(); //心愿单 // if (data.getWishList().getWishList().size() > 0) {