diff --git a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java index 054cb050d..17a430889 100644 --- a/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java +++ b/live/src/main/java/com/yunbao/live/presenter/LiveRyLinkMicPkPresenter.java @@ -1,7 +1,5 @@ package com.yunbao.live.presenter; -import android.app.Dialog; - import static com.lzy.okgo.utils.HttpUtils.runOnUiThread; import static com.yunbao.common.Constants.SOCKET_LINK_MIC_PK; import static com.yunbao.common.Constants.SOCKET_LIVE_DRPK; @@ -13,6 +11,7 @@ import static com.yunbao.live.views.LivePushRyViewHolder.rcrtcLiveInfo; import static com.yunbao.live.views.LivePushRyViewHolder.rtcRoom; import static cn.rongcloud.rtc.core.RendererCommon.ScalingType.SCALE_ASPECT_FILL; +import android.app.Dialog; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; @@ -30,26 +29,20 @@ import android.view.Gravity; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.PopupWindow; -import android.widget.RelativeLayout; import android.widget.TextView; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.tencent.trtc.TRTCCloud; import com.yunbao.common.CommonAppConfig; -import com.yunbao.common.bean.LiveInfoModel; import com.yunbao.common.bean.UserBean; -import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMRTCManager; import com.yunbao.common.manager.RandomPkManager; -import com.yunbao.common.http.live.LiveNetManager; -import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DialogUitl; import com.yunbao.common.utils.DpUtil; @@ -69,8 +62,6 @@ import com.yunbao.live.socket.SocketRyLinkMicPkUtil; import com.yunbao.live.socket.SocketSendBean; import com.yunbao.live.views.LiveLinkMicPkViewHolder; import com.yunbao.live.views.LivePushRyViewHolder; -import com.yunbao.live.views.LiveRoomPlayViewHolder; -import com.yunbao.live.views.PortraitLiveManager; import org.greenrobot.eventbus.EventBus; @@ -1313,107 +1304,113 @@ public class LiveRyLinkMicPkPresenter implements View.OnClickListener { @Override public void onSuccess(int code, String msg, String[] info) { Log.i(TAG, "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info)); - JSONObject datas = JSONObject.parseObject(info[0]); - boolean agree = true; - if (datas.getIntValue("pk_num_day") <= 0) { - ToastUtil.show("多人PK次数已用完"); - agree = false; - } - boolean finalAgree = agree; - IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, agree, SOCKET_LIVE_DRPK, new IRCRTCResultCallback() { - @Override - public void onSuccess() { - if (finalAgree == true) { - HttpClient.getInstance().get("live.joinDRPKroom", "live.joinDRPKroom") - .params("uid", CommonAppConfig.getInstance().getUid()) - .params("roomid", u.getId()) - .execute(new HttpCallback() { + if (info.length > 0) { - @Override - public void onSuccess(int code, String msg, String[] info) { - Log.i("多人PK", "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info)); + JSONObject datas = JSONObject.parseObject(info[0]); + boolean agree = true; + if (datas.getIntValue("pk_num_day") <= 0) { + ToastUtil.show("多人PK次数已用完"); + agree = false; + } + boolean finalAgree = agree; + IMRTCManager.getInstance().responseJoinOtherRoom(mApplyUid, agree, SOCKET_LIVE_DRPK, new IRCRTCResultCallback() { + @Override + public void onSuccess() { + if (finalAgree == true) { + HttpClient.getInstance().get("live.joinDRPKroom", "live.joinDRPKroom") + .params("uid", CommonAppConfig.getInstance().getUid()) + .params("roomid", u.getId()) + .execute(new HttpCallback() { - final SocketSendBean msg1 = new SocketSendBean() - .param("_method_", SOCKET_LIVE_DRPK) - .param("action", 10) - .param("uid", CommonAppConfig.getInstance().getUid()); - msg1.create(); - String targetId = "g" + CommonAppConfig.getInstance().getUid(); - Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; - TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); - io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, conversationType, messageContent); + @Override + public void onSuccess(int code, String msg, String[] info) { + Log.i("多人PK", "code = " + code + ", msg = " + msg + ", info = " + Arrays.deepToString(info)); - RongIMClient.getInstance().sendMessage(message, null, null, new IRongCallback.ISendMessageCallback() { - @Override - public void onAttached(io.rong.imlib.model.Message message) { + final SocketSendBean msg1 = new SocketSendBean() + .param("_method_", SOCKET_LIVE_DRPK) + .param("action", 10) + .param("uid", CommonAppConfig.getInstance().getUid()); + msg1.create(); + String targetId = "g" + CommonAppConfig.getInstance().getUid(); + Conversation.ConversationType conversationType = Conversation.ConversationType.CHATROOM; + TextMessage messageContent = TextMessage.obtain(msg1.mResult.toString()); + io.rong.imlib.model.Message message = io.rong.imlib.model.Message.obtain(targetId, 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 (SocketRyClient.mSocketHandler != null) { - SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + ""); } - } - @Override - public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) { - Log.e("ry", "发送失敗"); - } - }); - if (info.length == 0) { - return; - } - JSONObject obj = JSONObject.parseObject(info[0]); - JSONArray users = obj.getJSONArray("userlist"); + @Override + public void onSuccess(io.rong.imlib.model.Message message) { + Log.e("ry", "发送成功"); + if (SocketRyClient.mSocketHandler != null) { + SocketRyClient.mSocketHandler.processBroadcast(msg1.mResult.toString() + ""); + } + } - //添加水印 + @Override + public void onError(io.rong.imlib.model.Message message, RongIMClient.ErrorCode errorCode) { + Log.e("ry", "发送失敗"); + } + }); + if (info.length == 0) { + return; + } + JSONObject obj = JSONObject.parseObject(info[0]); + JSONArray users = obj.getJSONArray("userlist"); + + //添加水印 // RCRTCRect rect = new RCRTCRect(0.5f, 0.5f, 0.2f); // RCRTCEngine.getInstance().getDefaultVideoStream().setWatermark(fromText(50, mNameText), rect); - dRjoinOtherRoom(u.getId(), 1); + dRjoinOtherRoom(u.getId(), 1); - for (int i = 0; i < users.size(); i++) { - JSONObject user = users.getJSONObject(i); - Log.e("ry", mApplyUid + "VS" + user.getString("id") + "列表"); - if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid())) { - if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid()) && !user.getString("id").equals(u.getId())) { - /** - * 向指定用户发送跨房间连麦请求 - *

- * 1: inviterAutoMix为true时: - * - * 1.1:如果被邀请方在加入邀请方房间之前发布了资源,当被邀请方加入邀请者房间成功后,服务器会把被邀请方流资源合并到邀请方视图 ·(默认仅悬浮布局合流)上。 - * - * 1.2:如果被邀请方在加入邀请方房间之前没有发布过资源,将会在被邀请方发布资源成功后,服务器会把被邀请方流资源合并到邀请方视图(默认仅悬浮布局合流)上。 - * - * 2:无论为true或false,双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局。一旦主动设置过合流布局,后续音视频直播过程中设置的自动合流参数将失效。 - *

- */ - IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() { - @Override - public void onSuccess() { - } + for (int i = 0; i < users.size(); i++) { + JSONObject user = users.getJSONObject(i); + Log.e("ry", mApplyUid + "VS" + user.getString("id") + "列表"); + if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid())) { + if (!user.getString("id").equals(CommonAppConfig.getInstance().getUid()) && !user.getString("id").equals(u.getId())) { + /** + * 向指定用户发送跨房间连麦请求 + *

+ * 1: inviterAutoMix为true时: + * + * 1.1:如果被邀请方在加入邀请方房间之前发布了资源,当被邀请方加入邀请者房间成功后,服务器会把被邀请方流资源合并到邀请方视图 ·(默认仅悬浮布局合流)上。 + * + * 1.2:如果被邀请方在加入邀请方房间之前没有发布过资源,将会在被邀请方发布资源成功后,服务器会把被邀请方流资源合并到邀请方视图(默认仅悬浮布局合流)上。 + * + * 2:无论为true或false,双方都可以使用{@link RCRTCLiveInfo#setMixConfig(RCRTCMixConfig, IRCRTCResultCallback)} 方法主动设置合流布局。一旦主动设置过合流布局,后续音视频直播过程中设置的自动合流参数将失效。 + *

+ */ + IMRTCManager.getInstance().requestJoinOtherRoom(user.getString("id"), false, "LiveDRPK1", new IRCRTCResultCallback() { + @Override + public void onSuccess() { + } - @Override - public void onFailed(RTCErrorCode errorCode) { + @Override + public void onFailed(RTCErrorCode errorCode) { - } - }); + } + }); + } } } } - } - }); + }); + } } - } - @Override - public void onFailed(RTCErrorCode errorCode) { - ToastUtil.show("接受失败"); - } - }); + @Override + public void onFailed(RTCErrorCode errorCode) { + ToastUtil.show("接受失败"); + } + }); + }else { + ToastUtil.show(msg); + } } + }); 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 52f6b28f9..d79f48edf 100644 --- a/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java +++ b/live/src/main/java/com/yunbao/live/views/LiveRoomViewHolder.java @@ -644,6 +644,8 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis img.setImageResource(R.mipmap.icon_no4); } else if (j == 5) { img.setImageResource(R.mipmap.icon_no5); + }else { + img.setImageResource(R.mipmap.icon_no1); }