diff --git a/live/src/main/java/com/yunbao/live/activity/LiveSwAnchorActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveSwAnchorActivity.java index 594a4de35..d7a0bbd62 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveSwAnchorActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveSwAnchorActivity.java @@ -25,7 +25,6 @@ import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.fragment.app.DialogFragment; - import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.GsonUtils; @@ -365,8 +364,17 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl case Constants.LIVE_FUNC_ZG://zg // ToastUtil.show("開發中,敬請期待"); LivePrankDialogFragment fragment = new LivePrankDialogFragment(); + fragment.setOnPrankResultListener(new LivePrankDialogFragment.onPrankResultListener() { + @Override + public void OpenAndCloseListener() { + if(mLiveRoomViewHolder!=null){ + mLiveRoomViewHolder.initPrankProgress(); + } + } + }); fragment.setmLiveUid(mLiveUid); fragment.show(getSupportFragmentManager(), "LivePrankDialogFragment"); + mLiveAnchorViewHolder.closeMenuRed(); break; case Constants.LIVE_FUNC_MIC://語音 //ToastUtil.show("開發中,敬請期待"); @@ -687,6 +695,7 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl bundle.putBoolean("isPk", isDRPK == 1 || PKing || mLivePushViewHolder.isPking()); bundle.putLong("liveTime", mLiveAnchorViewHolder.getmAnchorLiveTime()); bundle.putBoolean(Constants.OPEN_FLASH, mLivePushViewHolder != null && mLivePushViewHolder.isFlashOpen()); + bundle.putBoolean("isShowZgRed",mLiveAnchorViewHolder.isShowMenuRed()); fragment.setArguments(bundle); fragment.setFunctionClickListener(this); fragment.show(getSupportFragmentManager(), "LiveFunctionDialogFragment"); @@ -860,6 +869,11 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl getAiRobotStatus(); MicedUserManager.get().removeAllMicUserList(); MicUserManager.get().removeAllMicUserList(); + //加载整蛊 + if(mLiveRoomViewHolder!=null){ + mLiveRoomViewHolder.initPrankProgress(); + mLiveRoomViewHolder.sendMsgPrank(); + } } /** @@ -1467,6 +1481,13 @@ public class LiveSwAnchorActivity extends LiveActivity implements LiveFunctionCl } } + @Override + public void onUpdatePrankProgress(String prankString) { + if (mLiveRoomViewHolder != null){ + mLiveRoomViewHolder.refreshPrank(prankString); + } + } + /** * 腾讯sdk连麦时候主播混流 diff --git a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java index 76cd96cf1..9e1815217 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java @@ -4,6 +4,7 @@ import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK; import static com.yunbao.common.Constants.SOCKET_LIVE_MSG_TO_USER; import static com.yunbao.live.activity.LiveSwAnchorActivity.isDRPK; import static com.yunbao.live.activity.LiveSwAnchorActivity.DRPKing; +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,12 +15,16 @@ 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; import com.alibaba.fastjson.JSONObject; import com.blankj.utilcode.util.GsonUtils; import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.CommonAppContext; import com.yunbao.common.Constants; @@ -280,6 +285,44 @@ public class SocketSwClient { } } break; + case Constants.PrankSendData: + //整蛊礼物刷新 + L.e("整蛊礼物刷新 整蛊礼物刷新 整蛊礼物刷新"); + if (map.getIntValue("action") == 13 && map.getString("msgtype").equals("4")){ + String ctString = map.getString("ct"); + L.e("整蛊礼物刷新 整蛊礼物刷新 整蛊礼物刷新 "+ctString); + JsonElement jsonElement = JsonParser.parseString(ctString); + if (jsonElement == null) break; +// LogUtils.e("yqw=====>整蛊礼物列表:"+ctString); + JsonObject jsonObject = jsonElement.getAsJsonObject(); + String content = WordUtil.isNewZh() ? jsonObject.get("msg").getAsString() : jsonObject.get("msg_en").getAsString(); + if(jsonObject.get("is_complete")!=null){ + 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); + } + break; case Constants.SOCKET_KICK://踢人 systemChatMessage2(map.getString("ct")); mListener.onKick(map.getString("touid")); 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 0e15015b0..575ceeb91 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -1,6 +1,5 @@ package com.yunbao.live.views; -import static com.yunbao.live.activity.LiveRyAnchorActivity.mLiveAnchorViewHolder; import static com.yunbao.live.bean.LiveChatBean.RECOMMEND_CARD_NOTIFY; import android.app.Activity; @@ -1384,6 +1383,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis liveHDDialogFragment.show(((LiveAudienceActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); }else if(mContext instanceof LiveRyAnchorActivity){ liveHDDialogFragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); + }else if(mContext instanceof LiveSwAnchorActivity){ + liveHDDialogFragment.show(((LiveSwAnchorActivity) mContext).getSupportFragmentManager(), "LiveHDDialogFragment"); } } else if (bean.getType() == RECOMMEND_CARD_NOTIFY) { gotoLive(bean.getMsgModel().getAnchorId()); @@ -1398,8 +1399,16 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } }); fragment.setmLiveUid(mLiveUid); - fragment.show(((LiveRyAnchorActivity)mContext).getSupportFragmentManager(), "LivePrankDialogFragment"); - mLiveAnchorViewHolder.closeMenuRed(); + if(mContext instanceof LiveRyAnchorActivity){ + fragment.show(((LiveRyAnchorActivity)mContext).getSupportFragmentManager(), "LivePrankDialogFragment"); + }else if(mContext instanceof LiveSwAnchorActivity){ + fragment.show(((LiveSwAnchorActivity)mContext).getSupportFragmentManager(), "LivePrankDialogFragment"); + } + if(mContext instanceof LiveRyAnchorActivity){ + com.yunbao.live.activity.LiveRyAnchorActivity.mLiveAnchorViewHolder.closeMenuRed(); + }else if(mContext instanceof LiveSwAnchorActivity){ + com.yunbao.live.activity.LiveSwAnchorActivity.mLiveAnchorViewHolder.closeMenuRed(); + } }else{ showUserDialog(bean.getId()); } @@ -1623,7 +1632,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis findViewById(R.id.btn_follow).setVisibility(View.GONE); findViewById(R.id.live_rank_pk).setVisibility(View.GONE); } - if (mContext instanceof LiveRyAnchorActivity) { + if (mContext instanceof LiveRyAnchorActivity ||mContext instanceof LiveSwAnchorActivity) { findViewById(R.id.open_sidebar).setVisibility(View.GONE); findViewById(R.id.btn_follow).setVisibility(View.GONE); findViewById(R.id.live_rank_pk).setVisibility(View.GONE); @@ -1633,7 +1642,6 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis reloadIM(); // initStarChallengeStatus(); - new LoadDian9TuUtil().loadDian9TuAssets2(mContext, wishListLayout2, "rectangle_new.png", 1); pa_pao_layout = (FrameLayout) findViewById(R.id.pa_pao_layout); combo_layout = (LinearLayout) findViewById(R.id.combo_layout); @@ -1707,10 +1715,13 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis } if(prankAnisShow){ prankAdapter.showAnView(completedList,prankAnisShow); - prank_group_turntable.setText(WordUtil.isNewZh()?"待完成整蠱":"progress"); + prank_group_turntable.setText(WordUtil.isNewZh()?"整蠱進度":"progress"); + prank_group_title.setText(WordUtil.isNewZh()?"待完成整蠱":"To do"); + }else{ prankAdapter.showAnView(prankAndComboList,prankAnisShow); prank_group_turntable.setText(WordUtil.isNewZh()?"待完成整蠱":"To do"); + prank_group_title.setText(WordUtil.isNewZh()?"待完成整蠱":"To do"); } }); @@ -2057,7 +2068,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis layoutParams.topMargin = DpUtil.dp2px(190); dragonImmediateParticipation.setLayoutParams(layoutParams); } - if (dragonImmediateParticipationTime.getVisibility() == View.VISIBLE && mContext instanceof LiveRyAnchorActivity) { + if (dragonImmediateParticipationTime.getVisibility() == View.VISIBLE && mContext instanceof LiveRyAnchorActivity||mContext instanceof LiveSwAnchorActivity) { RelativeLayout.LayoutParams layoutParamsredPacket = (RelativeLayout.LayoutParams) redPacket.getLayoutParams(); layoutParamsredPacket.topMargin = DpUtil.dp2px(110); redPacket.setLayoutParams(layoutParamsredPacket);