From e874c2ee16030c36b09e8bdaf959455a6326b589 Mon Sep 17 00:00:00 2001 From: Martin <13046765170@163.com> Date: Fri, 14 Jun 2024 15:40:51 +0800 Subject: [PATCH] =?UTF-8?q?add[=E4=BF=AE=E5=BE=A9BUG=EF=BC=8C=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=95=B4=E8=9B=8AIM=E6=B6=88=E6=81=AF=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yunbao/common/http/PDLiveApi.java | 1 + .../common/http/live/LiveNetManager.java | 4 +- .../yunbao/live/adapter/LiveChatAdapter.java | 29 +++++++++++-- .../com/yunbao/live/bean/LiveChatBean.java | 2 +- .../live/dialog/LivePrankDialogFragment.java | 11 +++-- .../yunbao/live/socket/SocketRyClient.java | 28 +++++++++++- .../yunbao/live/views/LiveRoomViewHolder.java | 12 ++++-- live/src/main/res/drawable/prank_msg_goto.xml | 5 +++ live/src/main/res/layout/item_live_chat.xml | 43 +++++++++++++++++++ live/src/main/res/values-en/strings.xml | 1 + live/src/main/res/values/strings.xml | 1 + 11 files changed, 123 insertions(+), 14 deletions(-) create mode 100644 live/src/main/res/drawable/prank_msg_goto.xml diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 5847f02f1..6a6373442 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -525,6 +525,7 @@ public interface PDLiveApi { @Query("anchor_id") String anchor_id, @Query("status") String status, @Query("prank_json") String prank_json, + @Query("is_cleared") String is_cleared, @Query("prank_type") String prank_type ); diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 46a807e22..d1749dcd7 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -922,9 +922,9 @@ public class LiveNetManager { /** * 设置礼物整蛊 */ - public void setPrankGift(String mLiveUid, String status, String prank_json,String prank_type, HttpCallback callback) { + public void setPrankGift(String mLiveUid, String status, String prank_json,String prank_type,String is_cleared, HttpCallback callback) { API.get().pdLiveApi(mContext) - .setPrank(mLiveUid, status, prank_json, prank_type) + .setPrank(mLiveUid, status, prank_json, prank_type,is_cleared) .observeOn(AndroidSchedulers.mainThread()) .subscribeOn(Schedulers.io()) .subscribe(responseModel -> { diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java index cf66de95d..d977b7dee 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveChatAdapter.java @@ -7,6 +7,7 @@ import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY; import static com.yunbao.live.bean.LiveChatBean.STAR_CHALLENGE_UPGRADE_NOTIFY; import static com.yunbao.live.bean.LiveChatBean.SYSTEM3_COLOR; import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_ANCHOR_PRANK; +import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_ANCHOR_PRANK_GIFT; import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_USER_MSG; import static com.yunbao.live.bean.LiveChatBean.WISH_LIST_PROGRESS; import static com.yunbao.live.bean.LiveChatBean.XYD_COMPLETE; @@ -219,6 +220,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter { LinearLayoutCompat attentionLayout; ClipPathCircleImage clipImage2; + LinearLayoutCompat prank_open_live_layout; + TextView prank_open_live_msg; + TextView prank_to_setting; + public Vh(View itemView) { super(itemView); mBg = (LinearLayout) itemView.findViewById(R.id.bg); @@ -245,6 +250,10 @@ public class LiveChatAdapter extends RecyclerView.Adapter { btnAttention = (ImageView) itemView.findViewById(R.id.btn_attention); textLeave = (ImageView) itemView.findViewById(R.id.text_leave); + prank_open_live_layout = itemView.findViewById(R.id.prank_open_live_layout); + prank_open_live_msg = itemView.findViewById(R.id.prank_open_live_msg); + prank_to_setting = itemView.findViewById(R.id.prank_to_setting); + } void setData(final LiveChatBean bean, int position) { @@ -255,9 +264,7 @@ public class LiveChatAdapter extends RecyclerView.Adapter { Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.INPUT_DIALOG) .setOlineUserlistModel(new OlineUserlistModel().setId(bean.getId()).setUserNicename(bean.getUserNiceName()))); - } - Log.e("eqwewqeweq", bean.toString()); return true; } @@ -522,10 +529,26 @@ public class LiveChatAdapter extends RecyclerView.Adapter { new LoadDian9TuUtil().loadDian9Tu(mContext, mBg, bean.getBubble(), 1); } } else if(bean.getType() == TYPE_TO_ANCHOR_PRANK){ - String str1 = "娛樂整蠱"; + /*String str1 = "娛樂整蠱"; String str2 = "全新升級,快去設置整蠱内容,給直播間增加更多趣味吧!"; String str3 = ">>立即前往>>"; mTextView.setText(Html.fromHtml(str1+str2+str3)); + new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1);*/ + + LinearLayout.LayoutParams params3 = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + params3.setMargins(0, 8, DpUtil.dp2px(80), 8); + params3.gravity = Gravity.CENTER_VERTICAL; + mBg.setLayoutParams(params3); + prank_open_live_layout.setVisibility(View.VISIBLE); + + }else if(bean.getType() == TYPE_TO_ANCHOR_PRANK_GIFT){ + StringBuffer stringBuffer = new StringBuffer(); + stringBuffer.append(""+(WordUtil.isNewZh()?"整蠱來了!":"Tricky is coming")+""); + stringBuffer.append(" "+bean.getUserNiceName()+""); + stringBuffer.append(""+(WordUtil.isNewZh()?"送出":"send")+"【"+bean.getGiftName()+"*"+bean.getHot_num()+"】"); + stringBuffer.append(","+(WordUtil.isNewZh()?"主播需完成":",and the anchor needs to complete ")+""); + stringBuffer.append( "【"+bean.getContent()+"】"); + mTextView.setText(Html.fromHtml(stringBuffer.toString())); new LoadDian9TuUtil().loadDian9TuAssets(mContext, mBg, 1); }else{ if (bean.getBubble() != null && !bean.getBubble().equals("")) { diff --git a/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java b/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java index 17378054d..878786d01 100644 --- a/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java +++ b/live/src/main/java/com/yunbao/live/bean/LiveChatBean.java @@ -30,8 +30,8 @@ public class LiveChatBean { public static final int WISH_LIST_PROGRESS = 307;//心愿单进度通知 public static final int BLIND_BOX = 409;//盲盒礼物消息 public static final int TYPE_TO_USER_MSG = 500;//指定信息 - public static final int TYPE_TO_ANCHOR_PRANK = 501;//整蠱-開播提示語 + public static final int TYPE_TO_ANCHOR_PRANK_GIFT = 502;//整蠱-禮物 private String id; private String userNiceName; diff --git a/live/src/main/java/com/yunbao/live/dialog/LivePrankDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LivePrankDialogFragment.java index f390f3c57..99437fdc0 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LivePrankDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LivePrankDialogFragment.java @@ -1,5 +1,7 @@ package com.yunbao.live.dialog; +import static com.yunbao.live.adapter.LivePrankRecyclerAdapter.TYPE_TURNTABLE; + import android.annotation.SuppressLint; import android.app.Dialog; import android.graphics.Color; @@ -239,6 +241,7 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O public void onViewClicks() { if ((int) mPrankBtn.getTag() == 0) { clearPrankConfig(); + setPrankConfig(); } else { giftSwitch1Btn.setTag("false"); giftSwitch1Btn.setImageResource(R.mipmap.special_icon_off); @@ -248,6 +251,7 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O mPrankBtn.setVisibility(View.VISIBLE); mBtnAddGift.setVisibility(View.VISIBLE); mGiftNotDate.setVisibility(View.VISIBLE); + setGiftBean(recyclerAdapter.getList()); } ToastUtil.show(WordUtil.isNewZh()?"清空成功!":"Cleared successfully!"); } @@ -282,7 +286,7 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O mPrankRecyclerView.setVisibility(View.VISIBLE); mBtnAddGift.setVisibility(View.GONE); mGiftNotDate.setVisibility(View.GONE); - recyclerAdapter.setViewType(LivePrankRecyclerAdapter.TYPE_TURNTABLE); + recyclerAdapter.setViewType(TYPE_TURNTABLE); mPrankBtn.setVisibility(View.VISIBLE); mPrankBtn.setBackgroundResource(R.drawable.bg_live_prank_turntable_save); if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { @@ -411,12 +415,12 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O private void setGiftBean(List prankGiftBeans) { JSONArray prankJson = getJsonObjects(prankGiftBeans); - LiveNetManager.get(mContext).setPrankGift(mLiveUid, giftSwitch1Btn.getTag().equals("true") ? "1" : "0", new Gson().toJson(prankJson), giftTypeNowText.getTag().toString(), new HttpCallback() { + LiveNetManager.get(mContext).setPrankGift(mLiveUid, giftSwitch1Btn.getTag().equals("true") ? "1" : "0", new Gson().toJson(prankJson), giftTypeNowText.getTag().toString(),"", new HttpCallback() { @Override public void onSuccess(PrankHttpTurntableBean data) { initGiftData(); if (WordUtil.isNewZh()) { - ToastUtil.show("設置成功"); + ToastUtil.show("保存成功!"); } else { ToastUtil.show("successful"); } @@ -499,6 +503,7 @@ public class LivePrankDialogFragment extends AbsDialogFragment implements View.O list.add(buildBean(4, bean.getTurntable4())); list.add(buildBean(5, bean.getTurntable5())); list.add(buildBean(6, bean.getTurntable6())); + recyclerAdapter.setViewType(TYPE_TURNTABLE); recyclerAdapter.setList(list); recyclerAdapter.notifyDataSetChanged(); if (bean.getStatus() == 1) { diff --git a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java index a8a8ac3c2..ff32b5391 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketRyClient.java @@ -4,6 +4,7 @@ import static com.blankj.utilcode.util.SnackbarUtils.dismiss; import static com.blankj.utilcode.util.ViewUtils.runOnUiThread; import static com.yunbao.common.Constants.SOCKET_LIVE_MSG_TO_USER; import static com.yunbao.live.activity.LiveRyAnchorActivity.isDRPK; +import static com.yunbao.live.bean.LiveChatBean.TYPE_TO_ANCHOR_PRANK_GIFT; import static com.yunbao.live.views.LiveRoomViewHolder.getIsHot; import android.app.Activity; @@ -14,6 +15,7 @@ import android.text.TextUtils; import android.util.Log; import android.view.View; import android.widget.LinearLayout; +import android.widget.Toast; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; @@ -58,6 +60,7 @@ import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.L; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.ToastUtils; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.R; import com.yunbao.live.activity.LiveAudienceActivity; @@ -305,8 +308,29 @@ public class SocketRyClient { // LogUtils.e("yqw=====>整蛊礼物列表:"+ctString); JsonObject jsonObject = jsonElement.getAsJsonObject(); String content = WordUtil.isNewZh() ? jsonObject.get("msg").getAsString() : jsonObject.get("msg_en").getAsString(); - if (!TextUtils.isEmpty(content)){ - systemChatMessage2(content); + + String is_complete = jsonObject.get("is_complete").getAsString(); //0.未达成整蛊需要的数量 1.已达成整蛊 + String user_name = jsonObject.get("user_name").getAsString(); //用户昵称 + String gift_name = WordUtil.isNewZh()?jsonObject.get("gift_name").getAsString():jsonObject.get("gift_name_en").getAsString(); //礼物名称 + String prank_content = jsonObject.get("prank_content").getAsString(); //整蛊内容 + String gift_count = jsonObject.get("gift_count").getAsString(); // 礼物数量 + + if(is_complete.equals("1")){ + LiveChatBean chatBean = new LiveChatBean(); + chatBean.setUserNiceName(user_name); + chatBean.setGiftName(gift_name); + chatBean.setHot_num(gift_count); + chatBean.setContent(prank_content); + chatBean.setType(TYPE_TO_ANCHOR_PRANK_GIFT); + mListener.onChat(chatBean, 1); + }else{ + if (!TextUtils.isEmpty(content)){ + systemChatMessage2(content); + } + if("完成1次!".equals(jsonObject.get("msg").getAsString())){ + Toast toast = Toast.makeText(mContext,WordUtil.isNewZh()?jsonObject.get("msg").getAsString():jsonObject.get("msg_en").getAsString(),Toast.LENGTH_LONG); + toast.show(); + } } mListener.onUpdatePrankProgress(ctString); } 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 c1f0253e9..5727dd396 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1850,7 +1850,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis sortBySendNum(prankAndComboList); prankAdapter.setViewType(PrankAdapter.TYPE_COMBO); prankAdapter.setList(prankAndComboList); -// prank_group_title.setText(R.string.combo_vote); } if(CommonAppConfig.getInstance().getUid().equals(mLiveUid)){ @@ -1864,9 +1863,16 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis prank_group_top_icon.setVisibility(View.VISIBLE); if(mPrankType==1){ prank_group_turntable.setVisibility(View.VISIBLE); + }else{ + prank_group_turntable.setVisibility(View.GONE); } prank_group_bottom_icon.setVisibility(View.GONE); }else{ + if(mPrankType==1){ + prank_group_title.setText(R.string.prank_progress); + }else{ + prank_group_title.setText(R.string.combo_vote); + } prank_group_turntable.setVisibility(View.GONE); prank_group_top_icon.setVisibility(View.GONE); } @@ -2496,7 +2502,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis public void setLiveUid(String liveUid) { mLiveUid = liveUid; - LiveHttpUtil.getAnchorActiveImgStatus(mLiveUid, new HttpCallback() { + /*LiveHttpUtil.getAnchorActiveImgStatus(mLiveUid, new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { if (code == 0 && imgEvent != null) { @@ -2519,7 +2525,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } } } - }); + });*/ } //获取心愿单列表 diff --git a/live/src/main/res/drawable/prank_msg_goto.xml b/live/src/main/res/drawable/prank_msg_goto.xml new file mode 100644 index 000000000..36658498c --- /dev/null +++ b/live/src/main/res/drawable/prank_msg_goto.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/live/src/main/res/layout/item_live_chat.xml b/live/src/main/res/layout/item_live_chat.xml index da2996682..bacd71816 100644 --- a/live/src/main/res/layout/item_live_chat.xml +++ b/live/src/main/res/layout/item_live_chat.xml @@ -232,6 +232,49 @@ + + + + + + + + Quantity + Set other quantity (up to 9999) Trick instructions + Entertainment Tricky has been newly upgraded. Go and set up Tricky content to add more fun to the live broadcast room! \ No newline at end of file diff --git a/live/src/main/res/values/strings.xml b/live/src/main/res/values/strings.xml index b0127a765..d2a5b547c 100644 --- a/live/src/main/res/values/strings.xml +++ b/live/src/main/res/values/strings.xml @@ -141,4 +141,5 @@ 連擊投票 連擊最多優先 整蠱說明 + 娛樂整蠱全新升級,快去設置整蠱内容,給直播間增加更多趣味吧!