diff --git a/common/src/main/java/com/yunbao/common/adapter/GiftWallAchieveAdapter.java b/common/src/main/java/com/yunbao/common/adapter/GiftWallAchieveAdapter.java index 68a6779a4..0331ea3c5 100644 --- a/common/src/main/java/com/yunbao/common/adapter/GiftWallAchieveAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/GiftWallAchieveAdapter.java @@ -58,23 +58,27 @@ public class GiftWallAchieveAdapter extends RecyclerView.Adapter { private TextView achieveName; private ImageView achieveImg; + private ImageView achieveImgLock; + public GiftWallAchieveViewHolder(@NonNull View itemView) { super(itemView); itemView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - if(onItemClickListener!=null){ + if (onItemClickListener != null) { onItemClickListener.onItemClick(getAdapterPosition()); } } }); achieveName = itemView.findViewById(R.id.achieveName); achieveImg = itemView.findViewById(R.id.achieve_img); + achieveImgLock = itemView.findViewById(R.id.achieve_img_lock); } public void showData(UserMedalListModel quantityModel) { achieveName.setText(quantityModel.getDressName()); - ImgLoader.display(mContext,quantityModel.getDisplaySrc(),achieveImg); + ImgLoader.display(mContext, quantityModel.getDisplaySrc(), achieveImg); + achieveImgLock.setVisibility(quantityModel.getDressStatus().equals("1") ? View.VISIBLE : View.GONE); } } diff --git a/common/src/main/java/com/yunbao/common/dialog/GiftWallAchieveWearDialog.java b/common/src/main/java/com/yunbao/common/dialog/GiftWallAchieveWearDialog.java index e86d86c7b..5db59225a 100644 --- a/common/src/main/java/com/yunbao/common/dialog/GiftWallAchieveWearDialog.java +++ b/common/src/main/java/com/yunbao/common/dialog/GiftWallAchieveWearDialog.java @@ -14,6 +14,7 @@ import com.stx.xhb.androidx.transformers.Transformer; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.R; import com.yunbao.common.bean.HttpCallbackModel; +import com.yunbao.common.bean.UserBean; import com.yunbao.common.bean.UserMedalModel; import com.yunbao.common.custom.LiveGuardScalePageTransformer; import com.yunbao.common.glide.ImgLoader; @@ -105,6 +106,9 @@ public class GiftWallAchieveWearDialog extends AbsDialogPopupWindow { public void onSuccess(HttpCallbackModel data) { ToastUtil.show(data.getMsg()); if (data.getCode() == 0) { + UserBean u = CommonAppConfig.getInstance().getUserBean(); + u.setMedal_no_display_src(achieveWearModels.get(selectPosition).getDisplaySrc()); + CommonAppConfig.getInstance().setUserBean(u); if(userUseDressSuccess!=null){ userUseDressSuccess.onSuccess(); } diff --git a/common/src/main/res/layout/view_gift_wall_achieve_item.xml b/common/src/main/res/layout/view_gift_wall_achieve_item.xml index d71b3fa12..cb60b5eed 100644 --- a/common/src/main/res/layout/view_gift_wall_achieve_item.xml +++ b/common/src/main/res/layout/view_gift_wall_achieve_item.xml @@ -1,23 +1,33 @@ - + android:paddingTop="10dp"> + android:layout_height="90dp" + android:layout_centerHorizontal="true" /> + + - \ No newline at end of file + \ No newline at end of file diff --git a/common/src/main/res/mipmap-mdpi/achieve_img_lock.png b/common/src/main/res/mipmap-mdpi/achieve_img_lock.png new file mode 100644 index 000000000..d8135a841 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/achieve_img_lock.png differ diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java index 6b502f695..ccd32ba92 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveLinkMicPkPresenter.java @@ -28,6 +28,7 @@ import com.yunbao.common.Constants; import com.yunbao.common.bean.UserBean; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; +import com.yunbao.common.manager.RandomPkManager; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.L; import com.yunbao.common.utils.StringUtil; @@ -44,6 +45,7 @@ import com.yunbao.live.momo.GenerateTestUserSig; import com.yunbao.live.socket.SocketClient; import com.yunbao.live.socket.SocketLinkMicPkUtil; import com.yunbao.live.socket.SocketSendBean; +import com.yunbao.live.socket.SocketSwClient; import com.yunbao.live.views.LiveLinkMicPkViewHolder; import com.yunbao.live.views.LivePushTxViewHolder; @@ -53,10 +55,16 @@ import java.util.List; import static com.lzy.okgo.utils.HttpUtils.runOnUiThread; import static com.tencent.trtc.TRTCCloudDef.TRTC_APP_SCENE_LIVE; +import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK; import static com.yunbao.live.activity.LiveAnchorActivity.isDRPK; import static com.yunbao.live.views.AbsLivePushViewHolder.mPreView; import static com.yunbao.live.views.LivePushTxViewHolder.dr_pk_view; +import io.rong.imlib.IRongCallback; +import io.rong.imlib.RongIMClient; +import io.rong.imlib.model.Conversation; +import io.rong.message.TextMessage; + /** * Created by cxf on 2018/11/16. * 主播与主播PK逻辑 @@ -389,20 +397,39 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener { } //接受PK回调 - private void pkAccept() { - /*mTRTCCloud1 = LivePushTxViewHolder.mTRTCCloud.createSubCloud(); - mTRTCParams1 = new TRTCCloudDef.TRTCParams(); - mTRTCParams1.sdkAppId = GenerateTestUserSig.SDKAPPID; - mTRTCParams1.userId = CommonAppConfig.getInstance().getUid() + "pk"; - mTRTCParams1.roomId = Integer.parseInt(mApplyUid); - mTRTCParams1.userSig = GenerateTestUserSig.genTestUserSig(mTRTCParams1.userId); - mTRTCParams1.role = TRTCCloudDef.TRTCRoleAudience; - mTRTCCloud1.enterRoom(mTRTCParams1, TRTC_APP_SCENE_LIVE); - mTRTCCloud1.startRemoteView(mApplyUid, LivePushTxViewHolder.mPreView1); - mTRTCCloud1.setListener(new TRTCCloudImplListener(mContext));*/ - LivePushTxViewHolder.btn_close.setVisibility(View.VISIBLE); - SocketLinkMicPkUtil.linkMicPkAccept(mSocketClient, mApplyUid, mApplyUrl, mApplyNmae); - onLinkMicPkStart(mApplyUid, mApplyUrl, mApplyNmae); + private void pkAccept(String uid) { + if(RandomPkManager.getInstance().getStatus()==RandomPkManager.PK_STATUS_START){ + final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 8); + msg1.create(); + + Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; + TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); + io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(uid, conversationType, messageContent); + + RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() { + @Override + public void onAttached(io.rong.imlib.model.Message message) { + + } + + @Override + public void onSuccess(io.rong.imlib.model.Message message) { + Log.e("ry", "发送成功"); + if (SocketSwClient.mSocketHandler != null) { + SocketSwClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + ""); + } + } + + @Override + public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) { + Log.e("ry", "发送失敗" + mApplyUid); + } + }); + }else{ + LivePushTxViewHolder.btn_close.setVisibility(View.VISIBLE); + SocketLinkMicPkUtil.linkMicPkAccept(mSocketClient, mApplyUid, mApplyUrl, mApplyNmae); + onLinkMicPkStart(mApplyUid, mApplyUrl, mApplyNmae); + } } /** @@ -423,7 +450,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener { showApplyDialog(u); } } else { - pkAccept(); + pkAccept(u.getId()); } } @@ -690,7 +717,7 @@ public class LiveLinkMicPkPresenter implements View.OnClickListener { // public void onSuccess(int code, String msg, String[] info) { // if (code == 0) { - pkAccept(); + pkAccept(u.getId()); } else { if (mPkWaitCount < 0) { SocketLinkMicPkUtil.linkMicPkNotResponse(mSocketClient, mApplyUid); 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 5da4fae24..cc71f3842 100644 --- a/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java +++ b/live/src/main/java/com/yunbao/live/socket/SocketSwClient.java @@ -1349,18 +1349,42 @@ public class SocketSwClient { break; case 2://收到对方主播PK回调 L.eSw("收到对方主播PK回调"); - /*if("1".equals(map.getString("random_pk"))){ + if(RandomPkManager.getInstance().getStatus()==RandomPkManager.PK_STATUS_START){ + final SocketSendBean msg1 = new SocketSendBean().param("_method_", SOCKET_LINK_MIC_PK).param("action", 8); + msg1.create(); + Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE; + TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); + io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(map.getString("uid"), conversationType, messageContent); - }*/ - RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START); - mListener.onLinkMicToPk(map.getString("uid"), map.getString("uhead"), map.getString("uhead")); - mListener.onLinkMicPkStart(map.getString("uid"), map.getString("uhead"), map.getString("uname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid")); - if (livePushSwViewHolder != null) { - UserBean userBean = new UserBean(); - userBean.setId(map.getString("uid")); - userBean.setAvatar(map.getString("uhead")); - userBean.setUserNiceName(map.getString("uname")); - livePushSwViewHolder.setAnPkRtc(userBean); + RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() { + @Override + public void onAttached(io.rong.imlib.model.Message message) { + + } + + @Override + public void onSuccess(io.rong.imlib.model.Message message) { + Log.e("ry", "发送成功"); + if (SocketSwClient.mSocketHandler != null) { + SocketSwClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + ""); + } + } + + @Override + public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) { + } + }); + }else{ + RandomPkManager.getInstance().setPkStatus(RandomPkManager.PK_STATUS_START); + mListener.onLinkMicToPk(map.getString("uid"), map.getString("uhead"), map.getString("uhead")); + mListener.onLinkMicPkStart(map.getString("uid"), map.getString("uhead"), map.getString("uname"), map.getString("is_ladders"));// mListener.onLinkMicPkStart(map.getString("uid")); + if (livePushSwViewHolder != null) { + UserBean userBean = new UserBean(); + userBean.setId(map.getString("uid")); + userBean.setAvatar(map.getString("uhead")); + userBean.setUserNiceName(map.getString("uname")); + livePushSwViewHolder.setAnPkRtc(userBean); + } } break; case 3://对方主播拒绝PK的回调