From a036e5eff604dc57ac9aa50bb1ae6279dacadce3 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 11 Jan 2024 15:15:21 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=AD=E9=9F=B3=E6=88=BF=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/main/AndroidManifest.xml | 4 +- .../adapter/SudGameUserListAdapter.java | 66 ++++- .../yunbao/common/bean/SudGameUserModel.java | 57 ++++ .../common/dialog/CreateSudGamePopup.java | 6 +- .../dialog/SudGameSmallPopupPindow.java | 73 +++++ .../yunbao/common/event/SudGameUserEvent.java | 17 ++ .../com/yunbao/common/http/PDLiveApi.java | 25 +- .../common/http/live/LiveNetManager.java | 120 ++++++++- .../manager/imrongcloud/GameMicManager.java | 103 ++++++- .../com/yunbao/common/utils/RouteUtil.java | 6 + .../common/views/SudGameListViewHolder.java | 10 +- .../views/SudGameUserListViewHolder.java | 74 +++++ .../bg_live_sud_list_select_item2.xml | 16 ++ .../main/res/layout/view_sud_game_small.xml | 29 ++ .../layout/view_sud_game_user_list_holder.xml | 27 +- .../backgroud_sud_game_small_window.png | Bin 0 -> 4404 bytes .../icon_game_close_wheat_mute.png | Bin 0 -> 2137 bytes common/src/main/res/values/strings.xml | 3 + live/src/main/AndroidManifest.xml | 3 + .../live}/activity/SudGameActivity.java | 255 ++++++++++++++++-- .../live/dialog/LiveUserDialogFragment.java | 21 +- .../yunbao/main/activity/MainActivity.java | 11 + .../main/views/MainHomeGameViewHolder.java | 2 +- 23 files changed, 880 insertions(+), 48 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/dialog/SudGameSmallPopupPindow.java create mode 100644 common/src/main/java/com/yunbao/common/event/SudGameUserEvent.java create mode 100644 common/src/main/res/drawable/bg_live_sud_list_select_item2.xml create mode 100644 common/src/main/res/layout/view_sud_game_small.xml create mode 100644 common/src/main/res/mipmap-xxhdpi/backgroud_sud_game_small_window.png create mode 100644 common/src/main/res/mipmap-xxhdpi/icon_game_close_wheat_mute.png rename {common/src/main/java/com/yunbao/common => live/src/main/java/com/yunbao/live}/activity/SudGameActivity.java (61%) diff --git a/common/src/main/AndroidManifest.xml b/common/src/main/AndroidManifest.xml index d9bf690aa..5b9ff7982 100644 --- a/common/src/main/AndroidManifest.xml +++ b/common/src/main/AndroidManifest.xml @@ -56,9 +56,7 @@ - + gameUserModels = new ArrayList<>(); + private boolean micMax = false; public SudGameUserListAdapter(List gameUserModels) { @@ -42,6 +43,34 @@ public class SudGameUserListAdapter extends RecyclerView.Adapter { } + public void refreshSudGameUserList(List gameUserModels) { + this.gameUserModels.clear(); + if (gameUserModels.size() < 7) { + micMax = false; + this.gameUserModels.addAll(gameUserModels); + for (int i = 0; i < this.gameUserModels.size(); i++) { + this.gameUserModels.get(i).setNullUser(false); + } + int size = 7 - gameUserModels.size(); + for (int i = 0; i < size; i++) { + this.gameUserModels.add(new SudGameUserModel().setNullUser(true)); + } + } else if (gameUserModels.size() == 7) { + micMax = true; + this.gameUserModels.addAll(gameUserModels); + for (int i = 0; i < this.gameUserModels.size(); i++) { + this.gameUserModels.get(i).setNullUser(false); + } + } else { + micMax = true; + + for (int i = 0; i < 7; i++) { + this.gameUserModels.add(gameUserModels.get(i).setNullUser(false)); + } + } + notifyDataSetChanged(); + } + @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { @@ -51,11 +80,44 @@ public class SudGameUserListAdapter extends RecyclerView.Adapter { @Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { - + SudGameUserListViewHolder sudGameUserListViewHolder = (SudGameUserListViewHolder) holder; + sudGameUserListViewHolder.upData(gameUserModels.get(position), sudGameSmallCallBack,position); } @Override public int getItemCount() { return gameUserModels.size(); } + + public boolean isMicMax() { + return micMax; + } + + public void muteUser(String userID, boolean mute, int position) { + for (int i = 0; i < gameUserModels.size(); i++) { + SudGameUserModel sudGameUserModel = gameUserModels.get(i); + if (!sudGameUserModel.isNullUser()) { + if (TextUtils.equals(userID, String.valueOf(sudGameUserModel.getId()))) { + gameUserModels.get(i).setMicStatus(mute ? 1 : 3); + + } + } + } + notifyItemChanged(position); + } + + private SudGameSmallCallBack sudGameSmallCallBack; + + public SudGameUserListAdapter setSudGameSmallCallBack(SudGameSmallCallBack sudGameSmallCallBack) { + this.sudGameSmallCallBack = sudGameSmallCallBack; + return this; + } + + public interface SudGameSmallCallBack { + void unMute(String userID, int position); + + void mute(String userID, int position); + + void viewInformation(SudGameUserModel sudGameUserModel); + } } diff --git a/common/src/main/java/com/yunbao/common/bean/SudGameUserModel.java b/common/src/main/java/com/yunbao/common/bean/SudGameUserModel.java index e7b45af68..2a55fac19 100644 --- a/common/src/main/java/com/yunbao/common/bean/SudGameUserModel.java +++ b/common/src/main/java/com/yunbao/common/bean/SudGameUserModel.java @@ -1,7 +1,19 @@ package com.yunbao.common.bean; +import com.google.gson.annotations.SerializedName; + public class SudGameUserModel extends BaseModel { private boolean nullUser; + @SerializedName("user_nicename") + private String userNicename; + @SerializedName("avatar") + private String avatar; + @SerializedName("sex") + private int sex; + @SerializedName("id") + private int id; + @SerializedName("mic_status") + private int micStatus; //麦克风状态 2.打开麦克风 3.关闭麦克风 public boolean isNullUser() { return nullUser; @@ -11,4 +23,49 @@ public class SudGameUserModel extends BaseModel { this.nullUser = nullUser; return this; } + + public String getUserNicename() { + return userNicename; + } + + public SudGameUserModel setUserNicename(String userNicename) { + this.userNicename = userNicename; + return this; + } + + public String getAvatar() { + return avatar; + } + + public SudGameUserModel setAvatar(String avatar) { + this.avatar = avatar; + return this; + } + + public int getSex() { + return sex; + } + + public SudGameUserModel setSex(int sex) { + this.sex = sex; + return this; + } + + public int getId() { + return id; + } + + public SudGameUserModel setId(int id) { + this.id = id; + return this; + } + + public int getMicStatus() { + return micStatus; + } + + public SudGameUserModel setMicStatus(int micStatus) { + this.micStatus = micStatus; + return this; + } } diff --git a/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java b/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java index 6b6026048..d265f74ea 100644 --- a/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java @@ -21,7 +21,6 @@ import com.lxj.xpopup.XPopup; import com.lxj.xpopup.core.BottomPopupView; import com.lxj.xpopup.enums.PopupPosition; import com.yunbao.common.R; -import com.yunbao.common.activity.SudGameActivity; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarChildModel; import com.yunbao.common.event.CheckCurrencyModel; @@ -33,6 +32,7 @@ import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; @@ -279,9 +279,7 @@ public class CreateSudGamePopup extends BottomPopupView { public void onSuccess(CreateSudRoomModel data) { if (isHome) { dialog.dismiss(); - Intent intent = new Intent(getContext(), SudGameActivity.class); - intent.putExtra("CreateSudRoom", new Gson().toJson(data)); - getContext().startActivity(intent); + RouteUtil.forwardSudGameActivity(new Gson().toJson(data)); } else { Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(0).setCreateSudRoomModel(data)); diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameSmallPopupPindow.java b/common/src/main/java/com/yunbao/common/dialog/SudGameSmallPopupPindow.java new file mode 100644 index 000000000..089e34caa --- /dev/null +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameSmallPopupPindow.java @@ -0,0 +1,73 @@ +package com.yunbao.common.dialog; + +import android.content.Context; +import android.widget.TextView; + +import androidx.annotation.NonNull; + +import com.lxj.xpopup.core.AttachPopupView; +import com.yunbao.common.R; +import com.yunbao.common.bean.SudGameUserModel; +import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.WordUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +public class SudGameSmallPopupPindow extends AttachPopupView { + private TextView viewUnMute; + private boolean mute; + private SudGameUserModel sudGameUserModel; + private SudGameSmallCallBack sudGameSmallCallBack; + + public SudGameSmallPopupPindow(@NonNull Context context, SudGameUserModel sudGameUserModel, boolean mute, SudGameSmallCallBack sudGameSmallCallBack) { + super(context); + this.mute = mute; + this.sudGameUserModel = sudGameUserModel; + this.sudGameSmallCallBack = sudGameSmallCallBack; + } + + @Override + protected int getImplLayoutId() { + return R.layout.view_sud_game_small; + } + + @Override + protected void onCreate() { + viewUnMute = findViewById(R.id.view_un_mute); + if (mute) { + viewUnMute.setText(WordUtil.isNewZh() ? "取消靜音" : "Unmute"); + } else { + viewUnMute.setText(WordUtil.isNewZh() ? "靜音" : "Mute"); + } + ViewClicksAntiShake.clicksAntiShake(viewUnMute, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + if (sudGameUserModel.getMicStatus() == 3) { + ToastUtil.show("对方未开麦!"); + return; + } + if (!mute) { + sudGameSmallCallBack.mute(); + } else { + sudGameSmallCallBack.unMute(); + } + dismiss(); + } + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.view_information), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + sudGameSmallCallBack.viewInformation(sudGameUserModel); + dismiss(); + } + }); + + } + + public interface SudGameSmallCallBack { + void unMute(); + + void mute(); + + void viewInformation(SudGameUserModel sudGameUserModel); + } +} diff --git a/common/src/main/java/com/yunbao/common/event/SudGameUserEvent.java b/common/src/main/java/com/yunbao/common/event/SudGameUserEvent.java new file mode 100644 index 000000000..af9fae6f1 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/SudGameUserEvent.java @@ -0,0 +1,17 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; +import com.yunbao.common.bean.SudGameUserModel; + +public class SudGameUserEvent extends BaseModel { + private SudGameUserModel sudGameUserModel; + + public SudGameUserModel getSudGameUserModel() { + return sudGameUserModel; + } + + public SudGameUserEvent setSudGameUserModel(SudGameUserModel sudGameUserModel) { + this.sudGameUserModel = sudGameUserModel; + return this; + } +} 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 b6e092d7e..6d0c57c72 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -62,6 +62,7 @@ import com.yunbao.common.bean.SearchModel; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.SlideInBannerModel; import com.yunbao.common.bean.StarChallengeStatusModel; +import com.yunbao.common.bean.SudGameUserModel; import com.yunbao.common.bean.SudRoomListModel; import com.yunbao.common.bean.SudgameCodeModel; import com.yunbao.common.bean.UserAreaBean; @@ -1115,24 +1116,42 @@ public interface PDLiveApi { @Query("battle_pass_points_id") String battlePassPointsId, @Query("count") String count ); + @GET("/api/public/?service=Livebattlepass.getBattlePassUserInfo") Observable> getBattlePassUserInfo(); @GET("/api/public/?service=Livebattlepass.getLiveBattlePassRewards") Observable> getLiveBattlePassRewards(); + @GET("/api/public/?service=Livebattlepass.getRewards") Observable>> getRewards( - @Query("live_battle_pass_level_id")String rewardLevelId, - @Query("live_battle_pass_rewards_id")String rewardId + @Query("live_battle_pass_level_id") String rewardLevelId, + @Query("live_battle_pass_rewards_id") String rewardId ); + @GET("/api/public/?service=Livebattlepass.getBattlePassTask") Observable> getBattlePassTask(); + @GET("/api/public/?service=Livebattlepass.getTask") - Observable>> getTask(@Query("task_id")String taskId); + Observable>> getTask(@Query("task_id") String taskId); + @GET("/api/public/?service=Livebattlepass.getBattlePassPoints") Observable>> getBattlePassPoints(); + @GET("/api/public/?service=Livebattlepass.battlePassRule") Observable> battlePassRule(); + @GET("/api/public/?service=Livebattlepass.addChatCount") Observable>> addChatCount(); + + @GET("/api/public/?service=Sudgameserver.joinMic") + Observable>> joinMic(@Query("room_id") String roomId); + @GET("/api/public/?service=Sudgameserver.onMic") + Observable>> onMic(@Query("room_id") String roomId); + @GET("/api/public/?service=Sudgameserver.offMic") + Observable>> offMic(@Query("room_id") String roomId); + @GET("/api/public/?service=Sudgameserver.leaveMic") + Observable>> leaveMic(@Query("room_id") String roomId); + @GET("/api/public/?service=Sudgameserver.getRoomMicData") + Observable>> getRoomMicData(@Query("room_id") String roomId); } 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 ba14573fa..2a27a2328 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 @@ -58,6 +58,7 @@ import com.yunbao.common.bean.RedPacketInfoModel; import com.yunbao.common.bean.RedPacketListBean; import com.yunbao.common.bean.SetAttentsModel; import com.yunbao.common.bean.StarChallengeStatusModel; +import com.yunbao.common.bean.SudGameUserModel; import com.yunbao.common.bean.SudRoomListModel; import com.yunbao.common.bean.SudgameCodeModel; import com.yunbao.common.bean.UserAreaBean; @@ -485,7 +486,7 @@ public class LiveNetManager { * @param liveUid */ public void leaveRoomNew(String stream, String liveUid, HttpCallback callback) { - Log.e("观看时长","leaveRoomNew-----------------------"+liveUid); + Log.e("观看时长", "leaveRoomNew-----------------------" + liveUid); API.get().pdLiveApi(mContext) .leaveRoomNew("g" + liveUid, stream) .subscribeOn(Schedulers.io()) @@ -2769,6 +2770,7 @@ public class LiveNetManager { } }).isDisposed(); } + public void addChatCount(HttpCallback callback) { API.get().pdLiveApi(mContext) .addChatCount() @@ -2790,6 +2792,122 @@ public class LiveNetManager { } }).isDisposed(); } + + public void joinMic(String roomId, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .joinMic(roomId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(new HttpCallbackModel(listResponseModel.getData().getCode(), listResponseModel.getData().getMsg())); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void onMic(String roomId, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .onMic(roomId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(new HttpCallbackModel(listResponseModel.getData().getCode(), listResponseModel.getData().getMsg())); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void offMic(String roomId, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .offMic(roomId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(new HttpCallbackModel(listResponseModel.getData().getCode(), listResponseModel.getData().getMsg())); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void leaveMic(String roomId, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .leaveMic(roomId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(new HttpCallbackModel(listResponseModel.getData().getCode(), listResponseModel.getData().getMsg())); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + + public void getRoomMicData(String roomId, HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .getRoomMicData(roomId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>>() { + @Override + public void accept(ResponseModel> listResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(listResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + /** * 直播间取消网络请求 */ diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameMicManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameMicManager.java index abd8b6d7f..357197f1a 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameMicManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/GameMicManager.java @@ -5,9 +5,11 @@ import android.text.TextUtils; import android.util.Log; import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; import com.yunbao.common.CommonAppContext; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.SudGameChatImModel; +import com.yunbao.common.bean.SudGameUserModel; import com.yunbao.common.event.SudGameSocketImEvent; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.ToastUtil; @@ -24,6 +26,7 @@ import cn.rongcloud.rtc.api.callback.IRCRTCResultCallback; import cn.rongcloud.rtc.api.callback.IRCRTCResultDataCallback; import cn.rongcloud.rtc.api.callback.IRCRTCRoomEventsListener; import cn.rongcloud.rtc.api.stream.RCRTCInputStream; +import cn.rongcloud.rtc.base.RCRTCParamsType; import cn.rongcloud.rtc.base.RCRTCRoomType; import cn.rongcloud.rtc.base.RTCErrorCode; import io.rong.imlib.IRongCallback; @@ -50,7 +53,7 @@ public class GameMicManager { */ @Override public void onRemoteUserPublishResource(RCRTCRemoteUser rcrtcRemoteUser, final List list) { - subscribeAVStream(); +// subscribeAVStream(); } @Override @@ -147,6 +150,7 @@ public class GameMicManager { } inputStreams.addAll(remoteUser.getStreams()); + } if (inputStreams.size() == 0) { @@ -175,6 +179,88 @@ public class GameMicManager { }); } + + public void refreshStreams(List personList) { + final List inputStreams = new ArrayList<>(); + + for (SudGameUserModel sudGameUserModel : personList) { + List rcrtcRemoteUsers = mRtcRoom.getRemoteUsers(); + + for (RCRTCRemoteUser rcrtcRemoteUser : rcrtcRemoteUsers) { + if (TextUtils.equals(rcrtcRemoteUser.getUserId(), String.valueOf(sudGameUserModel.getId()))) { + for (RCRTCInputStream rcrtcInputStream : rcrtcRemoteUser.getStreams()) { + rcrtcInputStream.mute(sudGameUserModel.getMicStatus() == 3); + } + inputStreams.addAll(rcrtcRemoteUser.getStreams()); + } + } + } + if (inputStreams.size() == 0) { + return; + } + mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() { + @Override + public void onSuccess() { + + + try { + getView().onSubscribeSuccess(inputStreams); + } catch (IllegalStateException e) { + e.printStackTrace(); + } + } + + @Override + public void onFailed(RTCErrorCode errorCode) { + try { + getView().onSubscribeFailed(); + } catch (IllegalStateException e) { + e.printStackTrace(); + } + } + }); + } + + public void refreshStreams(String userID, boolean mute, int position) { + + final List inputStreams = new ArrayList<>(); + + List rcrtcRemoteUsers = mRtcRoom.getRemoteUsers(); + + for (RCRTCRemoteUser rcrtcRemoteUser : rcrtcRemoteUsers) { + if (TextUtils.equals(rcrtcRemoteUser.getUserId(), String.valueOf(userID))) { + for (RCRTCInputStream rcrtcInputStream : rcrtcRemoteUser.getStreams()) { + rcrtcInputStream.mute(mute); + } + inputStreams.addAll(rcrtcRemoteUser.getStreams()); + } + } + if (inputStreams.size() == 0) { + return; + } + mRtcRoom.getLocalUser().subscribeStreams(inputStreams, new IRCRTCResultCallback() { + @Override + public void onSuccess() { + + + try { + getView().onSubscribeSuccess(userID,mute,position); + } catch (IllegalStateException e) { + e.printStackTrace(); + } + } + + @Override + public void onFailed(RTCErrorCode errorCode) { + try { + getView().onSubscribeFailed(userID); + } catch (IllegalStateException e) { + e.printStackTrace(); + } + } + }); + } + public void unPublishStreams() { if (mRtcRoom == null) { return; @@ -263,8 +349,9 @@ public class GameMicManager { //打开扬声器。 RCRTCEngine.getInstance().enableSpeaker(true); // 启用耳返功能 -// RCRTCEngine.getInstance().getDefaultAudioStream().enableEarMonitoring(true); + RCRTCEngine.getInstance().getDefaultAudioStream().enableEarMonitoring(true); RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(false); + RCRTCEngine.getInstance().getDefaultAudioStream().setAudioQuality(RCRTCParamsType.AudioQuality.MUSIC_HIGH, RCRTCParamsType.AudioScenario.MUSIC_CHATROOM); } public void joinRoom(String roomId) { @@ -272,6 +359,7 @@ public class GameMicManager { RCRTCRoomConfig roomConfig = RCRTCRoomConfig.Builder.create() // 根据实际场景,选择音视频直播:LIVE_AUDIO_VIDEO 或音频直播:LIVE_AUDIO .setRoomType(RCRTCRoomType.MEETING) + .build(); RCRTCEngine.getInstance().joinRoom("v" + roomId, roomConfig, new IRCRTCResultDataCallback() { @Override @@ -348,6 +436,13 @@ public class GameMicManager { //正常文字消息 if (TextUtils.equals(msgDTO.getMethod(), "SendMsg")) { getView().insertItem(new SudGameChatImModel().setNickname(msgDTO.getUname()).setTextMessage(msgDTO.getCt())); + } else if (TextUtils.equals(msgDTO.getMethod(), "sudGameRoomVoiceList")) { + List personList = new Gson().fromJson(msgDTO.getCt(), new TypeToken>() { + }.getType()); + getView().refreshSudGameUserList(personList); + + refreshStreams(personList); + } } @@ -419,11 +514,15 @@ public class GameMicManager { void onSubscribeSuccess(List inputStreamList); void onSubscribeFailed(); + void onSubscribeSuccess(String userID,boolean mute, int position); + void onSubscribeFailed(String userID); void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser); void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser); void insertItem(SudGameChatImModel sudGameChatImModel); + + void refreshSudGameUserList(List personList); } } diff --git a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java index 014623583..2b2f138e9 100644 --- a/common/src/main/java/com/yunbao/common/utils/RouteUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/RouteUtil.java @@ -46,12 +46,18 @@ public class RouteUtil { public static final String PATH_RED_PACKET_USER = "/main/RedPacketUsersActivity"; public static final String PATH_SELECT_AVATAR="/main/UserAvatarSelectActivity"; public static final String PATH_BattlePassActivity="/main/BattlePassActivity"; + public static final String PATH_SudGameActivity="/live/SudGameActivity"; public static void forwardFansActivity(String uid) { ARouter.getInstance().build(PATH_FANSACTIVITY) .withString(Constants.TO_UID, uid) .navigation(); } + public static void forwardSudGameActivity(String CreateSudRoom) { + ARouter.getInstance().build(PATH_SudGameActivity) + .withString("CreateSudRoom", CreateSudRoom) + .navigation(); + } public static void forwardMyWebViewActivity2(String url) { ARouter.getInstance().build(PATH_MYWEBVIEWACTIVTITY2) diff --git a/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java b/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java index f5832bad5..c87f93e08 100644 --- a/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/SudGameListViewHolder.java @@ -15,7 +15,6 @@ import com.google.gson.Gson; import com.lxj.xpopup.XPopup; import com.makeramen.roundedimageview.RoundedImageView; import com.yunbao.common.R; -import com.yunbao.common.activity.SudGameActivity; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.SudRoomListModel; @@ -107,9 +106,8 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder { createSudRoomModel.setSudGameName(model.getSudGameName()); if (isHome) { if (TextUtils.equals(model.getLiveUid(), "0")) { - Intent intent = new Intent(itemView.getContext(), SudGameActivity.class); - intent.putExtra("CreateSudRoom", new Gson().toJson(createSudRoomModel)); - itemView.getContext().startActivity(intent); + RouteUtil.forwardSudGameActivity(new Gson().toJson(createSudRoomModel)); + } else { String yes = "是"; if (IMLoginManager.get(itemView.getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { @@ -158,9 +156,7 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder { @Override public void onCancel() { - Intent intent = new Intent(itemView.getContext(), SudGameActivity.class); - intent.putExtra("CreateSudRoom", new Gson().toJson(createSudRoomModel)); - itemView.getContext().startActivity(intent); + RouteUtil.forwardSudGameActivity(new Gson().toJson(createSudRoomModel)); } })).show(); diff --git a/common/src/main/java/com/yunbao/common/views/SudGameUserListViewHolder.java b/common/src/main/java/com/yunbao/common/views/SudGameUserListViewHolder.java index 4a8511d0e..6dce6f6ef 100644 --- a/common/src/main/java/com/yunbao/common/views/SudGameUserListViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/SudGameUserListViewHolder.java @@ -1,12 +1,86 @@ package com.yunbao.common.views; import android.view.View; +import android.widget.FrameLayout; +import android.widget.ImageView; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; +import com.lxj.xpopup.XPopup; +import com.lxj.xpopup.enums.PopupPosition; +import com.makeramen.roundedimageview.RoundedImageView; +import com.yunbao.common.R; +import com.yunbao.common.adapter.SudGameUserListAdapter; +import com.yunbao.common.bean.SudGameUserModel; +import com.yunbao.common.dialog.SudGameSmallPopupPindow; +import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + public class SudGameUserListViewHolder extends RecyclerView.ViewHolder { + private ImageView vacancy_sud_game, mic_status; + private FrameLayout user_layout; + private RoundedImageView sud_game_user; + public SudGameUserListViewHolder(@NonNull View itemView) { super(itemView); + vacancy_sud_game = itemView.findViewById(R.id.vacancy_sud_game); + sud_game_user = itemView.findViewById(R.id.sud_game_user); + user_layout = itemView.findViewById(R.id.user_layout); + mic_status = itemView.findViewById(R.id.mic_status); + } + + public void upData(SudGameUserModel sudGameUserModel, SudGameUserListAdapter.SudGameSmallCallBack sudGameSmallCallBack, int position) { + if (sudGameUserModel.isNullUser()) { + vacancy_sud_game.setVisibility(View.VISIBLE); + user_layout.setVisibility(View.GONE); + ViewClicksAntiShake.clicksAntiShake(vacancy_sud_game, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + Bus.get().post(sudGameUserModel); + } + }); + } else { + vacancy_sud_game.setVisibility(View.GONE); + user_layout.setVisibility(View.VISIBLE); + ImgLoader.display2(itemView.getContext(), sudGameUserModel.getAvatar(), sud_game_user); + if (sudGameUserModel.getMicStatus() == 2) { + ImgLoader.display2(itemView.getContext(), R.mipmap.icon_game_open_wheat, mic_status); + } else if (sudGameUserModel.getMicStatus() == 3) { + ImgLoader.display2(itemView.getContext(), R.mipmap.icon_game_close_wheat, mic_status); + } else if (sudGameUserModel.getMicStatus() == 1) { + ImgLoader.display2(itemView.getContext(), R.mipmap.icon_game_close_wheat_mute, mic_status); + } + ViewClicksAntiShake.clicksAntiShake(user_layout, new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + XPopup.Builder builder = new XPopup.Builder(itemView.getContext()).atView(user_layout); + builder.hasShadowBg(false) + .isDestroyOnDismiss(true) + .isLightStatusBar(false) + .popupPosition(PopupPosition.Bottom) + .asCustom(new SudGameSmallPopupPindow(itemView.getContext(), + sudGameUserModel, + sudGameUserModel.getMicStatus() == 1, + new SudGameSmallPopupPindow.SudGameSmallCallBack() { + @Override + public void unMute() { + sudGameSmallCallBack.unMute(sudGameUserModel.getId() + "",position); + } + + @Override + public void mute() { + sudGameSmallCallBack.mute(sudGameUserModel.getId() + "",position); + } + + @Override + public void viewInformation(SudGameUserModel sudGameUserModel) { + sudGameSmallCallBack.viewInformation(sudGameUserModel); + } + })).show(); + } + }); + } } } diff --git a/common/src/main/res/drawable/bg_live_sud_list_select_item2.xml b/common/src/main/res/drawable/bg_live_sud_list_select_item2.xml new file mode 100644 index 000000000..b18c8a2d6 --- /dev/null +++ b/common/src/main/res/drawable/bg_live_sud_list_select_item2.xml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_sud_game_small.xml b/common/src/main/res/layout/view_sud_game_small.xml new file mode 100644 index 000000000..8c8d2aae6 --- /dev/null +++ b/common/src/main/res/layout/view_sud_game_small.xml @@ -0,0 +1,29 @@ + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_sud_game_user_list_holder.xml b/common/src/main/res/layout/view_sud_game_user_list_holder.xml index 197037ea2..4f6049b06 100644 --- a/common/src/main/res/layout/view_sud_game_user_list_holder.xml +++ b/common/src/main/res/layout/view_sud_game_user_list_holder.xml @@ -1,5 +1,6 @@ + android:src="@mipmap/icon_vacancy_sud_game" + android:visibility="visible" /> + android:visibility="visible"> + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/backgroud_sud_game_small_window.png b/common/src/main/res/mipmap-xxhdpi/backgroud_sud_game_small_window.png new file mode 100644 index 0000000000000000000000000000000000000000..fed69cb327fead1103316311670bd94e439edc6a GIT binary patch literal 4404 zcmeHL`#Tf*A0J6l?iGow+)^i(LoP8xa&ImvcdFG??#Fdz#wnFs!eQ22O2vs#VH;yp zPPCL+llwMz;n-ZpFt+c`fARgH&+~kq&*ynQ&*%Mop7-;9z22|aC({GsC?l;Z4FCXS zoSp2wL~92CAf_xODcbR$xN3mdt}EU*E^7cHA)f>QQId6bK3ET@OkP1qDTU*?i$0u+lv-K&SK8;1yJOZ(Xy) z@XROWkerl_;m`wn(mMiKJf9T7)*J%*&ez57(n26m;!V}s?a0Xb{SxAG8ldF3$k5Qx z*@fB$+2nG(ULmE;+s6m*dD*8mP(`9&s&8n>9IPe_-kz_n2yVUJDM`lT2M;MLW3f>r z3&V(!CT6%P-_uYfr3QyfU}dD2H}=`s1g4z}8?Y~=OjBc9#*iEmKazus7uCv$K|yXSpTL?SVu zB55*{y%r^@>Z)K~EpBq|+-{#gpN_-f_K)JDsM?DAm83IzH^+=IZi3uZ?mT@-G`ow6 zi`j0kyuygBt--UqAC5xX|4v;lmFny3i@pPt_s#E_frSsfJuyV1P4G#mtG13O6=J7y z%|`qhVXtzH9)6$ae%apM#`oTp+D9ChD#ZavoYA>*gns|!lSAa ziHPM|9qO8c6+Z4fXmb5R6l!O4C1s|vvQi-`gdiAt2fYVb>WQpy({Z$dn5e49A$@#& z1W6Yf5(f_}EAvgv_2j~n%eN_KRe_Xw~?UFOeHf%2c%L7Fo{7NfT;gk>@9-ppCt!OEd0 zQoE2#q@z+2t9bPeE!4rpV~GL0b`oi8iWk2eM7?HM66+=@2xsvQbSHLGgr%0n2=eq} zvvI=Kzjo+!*5cw{WaNa`XSOBP7HswsB_L#!K4+Z?1asT=ZKy;u;Uvwt#W}BQAphX& z%IGNqA)9}c#cLcG$)nG6Q^S@7jv7d=u&Qht67MB87RsHE+YTKVLF5=cNAfq|-H+AR zl9Q8j`2Db^Y@(9d`M6VN-2BL<3d>`xM2|840p9nYaRyMmJGLL`OWp*e?X2I;bh};u-D}r0x7(rh+s_kAZ4vTXo?nOR%;5wA5tDeRR4~2q|St z7>t%}IjAIxdbkLUHUPy;{xex-nW)2KGZu-KB%)?)s5RnV%*%J0`N?SVV?2v z>&4~e<<;o30UI>uy^lWKc)q&23f5B0jB0Lb^5q$6CvLwxmZh0@Hl4(~%SKn>s;Xw6 z@C&gb1j$KO$tFwQzI!)$JKKP?$vo50_PuuHPGopY4EI1$8e*?;Xs?>32=VSBGIL*8 zSP;;K!PUzbq0p&&uf6Zi*EWzw=s$kkf=`n@II_wdI3tz6l&^QWs;xb4{=1{({{Ik7 zC&Wyt2Kf7DQK#LN^n+iPZf)6jtXVZ)`|#)6IrxgUYw->x9?w>)$jZtJIc^?(E!EXE z8@%kEPpvL|aYn*Hb6gMyoBfJ`ZTvgzD54xr49X1V(+~_gf&E5mi)6G;YC1m7*&b!k z>^7|>Oq8N4iS>^2UHXidB@tK)%Kc+I3z6~ zvPIi4Y~YPgU9Zx}ouR?$rmJ3pRh+`1xUi2+`O1v=@#VZ b z8Uk?PnD=3W`aH9?(!t|S-PQ~ zIGfWs`wi>k<>j@iuG@iIUmQHfThXNgyb7Nn^!F3o&vOV+Q=rme7 zVD68-@Bfh^kdKSXATn-snj&{HZRntctAY(cZ*{r`mg(6CtI zgz z^caxGmYoE%0CA`@u#i&H5<4eZ-@Y+Iw%S?l zq>lXO?U1afU~=m2S2^&`6P_5Il#^P!Go;cOH;RiG<}nde!r&#gPj?_N+FBtxF@?vesjXj~`--`& zmg^wIxV$QV)6f9^ec4J9wC50sCQ4+iK054t>J9-Pzc>(%KoDgz>>fp1Gxq3zuV+Il zAl2V)p@U#BYI#}hn>SpMi!?rb`0(P9v;HRk#tIbnsw@}$%zN(fbCJPdXd`&+=B1@2 z_R$ZCRA~|?vd` z0?)mt)H-%Q{-$#9h)C)?oi2LM&fTjlbsH#>=+Kk-k65FlSPHC>a;v9U`%QB-S8;}X Z;lZP-sFRE~(KiUd`69%=-tO9;{{vV5ri}mq literal 0 HcmV?d00001 diff --git a/common/src/main/res/mipmap-xxhdpi/icon_game_close_wheat_mute.png b/common/src/main/res/mipmap-xxhdpi/icon_game_close_wheat_mute.png new file mode 100644 index 0000000000000000000000000000000000000000..8f78bc3f8541268df1f2667da21649a4f25650f4 GIT binary patch literal 2137 zcmV-f2&VUmP)Px-6G=otR9HuySbuO-R~0_z-uK?V_coiP0V2gh0!>327_%D!BdwiU6=xisPCB+) zi`sFjqtqFzj?};uai&vf#o88X$yf%*jul3#Q!Rfuv?@%iGY*km6J#`vHK7w4(ndna z?!F)U?vbk;vT zybKYI1Hd}~FeZd}!*QI^bUK|G9UXOQHG?${l!-*57XUtrh^rU`0OSB5Ktv)U#p@uV zAR=B<0)WQgi0C8{{VA17y~5+G*{cdD9*=JjLOeu7ix82GCd)l%ugEpw7_v_1Q#C7X2+_{0RRC2qf*KTj~_oi5gvaTptiQQNGulHfrxhifLbPm@s3iyKQCrD zGOt6FFWUBp8l@B-T?#1!5vGGcZOmi_&k+S2*%cn4lsY;+J-szd-(`T}@i@oK133Wa zi-yts6~nmU55E8IPRBVN2~oi`?X~Up9$jz96~Gh?Yltx5`{y@hGQ&(?6>mk9Qu|V= z)HB6#bAWn!dNwGfc5ym8MCw3YU1yt=QJ)Cj@csWioX!5n7-FOwM_QYupepuC_alS$UOyof*f|sv)FKvJ_8Zkgs^^W+wF~rde~D8Xj>-p=HG)L zT??Q>)*YRhnc0Ht)~#ER%jFJnXp~dna`gECs$0ssA6iyhJ)%|wbq#VA^O;*Oy3Ve^j!lWHqB&g#6%+TEkyhp0JxP>ltIN1@mb62 zxJlFOaQ4loFMIWrv1wNDpW&J{Yn~*cj~A+URgq=mdu@AVs}NE4b20nE^yvU%TQ)m< z6*0tiHAMU)c6WClB%+mwSh6+nh=_$yB0?RaBmn9XBKkx$+8zOrT>gvMSETRzrrG+G zstS=SNE|J<8i8SA57)z#<@-}BOBj*5e z%Y}&Sw(X8+K^WOWIQyw436+g>pn1nT}w=Hyu-pR4-8Xmm9TV_5RT;#pMP1&G@7w%yq*rT%m_JNBaIO>!A3 z;iWl12ZRtEM05pZ{6{0AJQ9n=d4bKD%$vt@xf!2GajpBVWwkg&bKP2zzQ-Nsv{9&i zD}*qARadu4Ai|w9GlOS{Jn?>on8U@Qtd#l}d*~TNyuDmdbNuYL?T)yv$HsCw=Toz@ z|7a2-uQ|QCzTi8i*~$f#-vgq&vcB&7Q+?U&TkMH?MESI3we#=0W@m>g6kM)p$5@B9 z2qC@z0A9&p1Ax_Tc zu6u^Zv*P9?Do}AAdG^MBtIU%Z)dZ4D#!64Yxdn~KHUDKj25lkuN9P<5%!@hrR>e9~h zo4-fb7d~W~tqhdkk9ywJR>ygZTbBwVmoFWfrrlF4u8#u%$5Gjql|gamxW~5Jx}d$9~C277E~W~MK{i+DWVi-=po z?MJ!YuoQeo*PCwB^~O~~#1>1bv&VQLZecGdr3QlF{9kgp>Cfx>2bLFV-)~)a;zzFg zb}3JBhR?MhMZ<|i;w3~}Udx$_cgn%c8Fa5{+yh#?%G?8La+-KXJ zEmE2sXJzPP{TWRrlb;QDjO?Xbq?A7`rAOtw#lY@1j76Iwk!3t)uj`(E$@AU~2X7Qn zJZIY-ONFrVS$c`S@lb4NN~s4^snlOD1H>=g-Q8aYfNz$Qfcd~!I6r3?3%^kS)bBWB zzxMs9@M(iV-+*X5W?5~;*5$D0O+I$%;J_9BxnwfgA6EQ1JDr`KhG7_w3L!RB3h?5D z`GD9%T&w0Ee~PUO)3;Je^99$P*yXz8I?=1H>ux`F>eQSDUZGQK*REY01VK#)MK*M& zu3z`1NF;yz@e9`-XBjAW9tu+S2{{>7D9ZIh$=R2 zoOMn?E=+*3?FAdsEjN;x(;IhnqiE4}{%RthGQ^xH-o P00000NkvXXu0mjf(Sr;G literal 0 HcmV?d00001 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 584af597c..dfea3feca 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1429,4 +1429,7 @@ Limited ride And limited avatar frame Successfully opened You have purchased the BattlePass 評論 + 查看信息 + 取消靜音 + 靜音 diff --git a/live/src/main/AndroidManifest.xml b/live/src/main/AndroidManifest.xml index dd65fbe2a..8aa914b19 100644 --- a/live/src/main/AndroidManifest.xml +++ b/live/src/main/AndroidManifest.xml @@ -84,6 +84,9 @@ + diff --git a/common/src/main/java/com/yunbao/common/activity/SudGameActivity.java b/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java similarity index 61% rename from common/src/main/java/com/yunbao/common/activity/SudGameActivity.java rename to live/src/main/java/com/yunbao/live/activity/SudGameActivity.java index f059a0103..c0cff3132 100644 --- a/common/src/main/java/com/yunbao/common/activity/SudGameActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java @@ -1,6 +1,10 @@ -package com.yunbao.common.activity; +package com.yunbao.live.activity; +import android.Manifest; import android.app.Activity; +import android.os.Bundle; +import android.os.Handler; +import android.text.TextUtils; import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView; @@ -10,19 +14,25 @@ import androidx.lifecycle.Observer; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import com.alibaba.android.arouter.facade.annotation.Route; import com.google.gson.Gson; import com.lxj.xpopup.XPopup; +import com.yunbao.common.Constants; import com.yunbao.common.R; +import com.yunbao.common.activity.AbsActivity; import com.yunbao.common.adapter.SudGameChatAdapter; import com.yunbao.common.adapter.SudGameUserListAdapter; import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarChildModel; import com.yunbao.common.bean.CustomSidebarInfoModel; +import com.yunbao.common.bean.HttpCallbackModel; import com.yunbao.common.bean.SudGameChatImModel; +import com.yunbao.common.bean.SudGameUserModel; import com.yunbao.common.dialog.SudGameInputPopupWindow; import com.yunbao.common.event.CheckRemainingBalanceEvent; import com.yunbao.common.event.SudGameSocketImEvent; +import com.yunbao.common.event.SudGameUserEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.base.HttpCallback; import com.yunbao.common.http.live.LiveNetManager; @@ -34,11 +44,16 @@ import com.yunbao.common.sud.model.GameViewInfoModel; import com.yunbao.common.sud.state.SudMGPMGState; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DpUtil; +import com.yunbao.common.utils.ProcessResultUtil; +import com.yunbao.common.utils.RouteUtil; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.LiveSudGameHistoryPopup; import com.yunbao.common.views.TopGradual; import com.yunbao.common.views.weight.ViewClicksAntiShake; +import com.yunbao.live.dialog.LiveUserDialogFragment; +import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; @@ -51,7 +66,7 @@ import cn.rongcloud.rtc.api.RCRTCRemoteUser; import cn.rongcloud.rtc.api.RCRTCRoom; import cn.rongcloud.rtc.api.stream.RCRTCInputStream; import cn.rongcloud.rtc.base.RTCErrorCode; - +@Route(path = RouteUtil.PATH_SudGameActivity) public class SudGameActivity extends AbsActivity implements GameMicManager.MeetingCallback { private FrameLayout gameContainer; private long mInteractionID; @@ -67,6 +82,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti private RecyclerView chatList, userList; private SudGameChatAdapter mLiveChatAdapter; private SudGameUserListAdapter sudGameUserListAdapter; + private ProcessResultUtil mProcessResultUtil; @Override protected int getLayoutId() { @@ -84,6 +100,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti private List customSidebarChildModels = new ArrayList<>(); private void initDate() { + LiveNetManager.get(mContext) .getCustomSidebarInfo("1", new HttpCallback>() { @Override @@ -109,10 +126,51 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable); ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat); gameCloseWheat.setVisibility(View.INVISIBLE); + LiveNetManager.get(mContext).getRoomMicData(mLiveUid, new HttpCallback>() { + @Override + public void onSuccess(List data) { + gameMicManager.refreshStreams(data); + sudGameUserListAdapter.refreshSudGameUserList(data); + } + + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + if (!mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) { + ToastUtil.show("拒绝权限将无法使用上麦功能"); + mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() { + @Override + public void run() { + + } + }); + } + } + }, 1500); + mProcessResultUtil = new ProcessResultUtil(this); + + } @Override protected void onDestroy() { + LiveNetManager.get(mContext) + .leaveMic(mLiveUid, new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + + } + + @Override + public void onError(String error) { + + } + }); Bus.getOff(this); gameMicManager.leaveRoom(); gameMicManager.detachView(); @@ -120,6 +178,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti } private void initView() { + String createSudRoomJson = getIntent().getStringExtra("CreateSudRoom"); mCreateSudRoomModel = new Gson().fromJson(createSudRoomJson, CreateSudRoomModel.class); mInteractionID = mCreateSudRoomModel.getLongSudGameId(); @@ -148,6 +207,38 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti mLiveChatAdapter = new SudGameChatAdapter(mContext); chatList.setAdapter(mLiveChatAdapter); sudGameUserListAdapter = new SudGameUserListAdapter(new ArrayList<>()); + sudGameUserListAdapter.setSudGameSmallCallBack(new SudGameUserListAdapter.SudGameSmallCallBack() { + @Override + public void unMute(String userID, int position) { + if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) { + gameMicManager.refreshStreams(userID, false, position); + } else { + ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself"); + } + + } + + @Override + public void mute(String userID, int position) { + if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) { + gameMicManager.refreshStreams(userID, true, position); + } else { + ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself"); + } + + } + + @Override + public void viewInformation(SudGameUserModel sudGameUserModel) { + LiveUserDialogFragment fragment = new LiveUserDialogFragment(); + Bundle bundle = new Bundle(); + bundle.putString(Constants.LIVE_UID, "uid"); + bundle.putString(Constants.STREAM, ""); + bundle.putString(Constants.TO_UID, sudGameUserModel.getId() + ""); + fragment.setArguments(bundle); + fragment.show(((SudGameActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment"); + } + }); userList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false)); userList.setAdapter(sudGameUserListAdapter); if (mCreateSudRoomModel != null) { @@ -173,32 +264,82 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_seat), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - if (publishDefault) { - disable = true; - // 设置禁用麦克风采集 - RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable); - ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat); - gameMicManager.unPublishStreams(); + if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) { + if (publishDefault) { + disable = true; + // 设置禁用麦克风采集 + RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable); + ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat); + gameMicManager.unPublishStreams(); + } else { + if (sudGameUserListAdapter.isMicMax()) { + ToastUtil.show(WordUtil.isNewZh() ? "上麥人數最大7人" : "The maximum number of people on the microphone is 7"); + } else { + gameMicManager.publishDefaultAVStream(); + } + + } } else { - gameMicManager.publishDefaultAVStream(); + mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() { + @Override + public void run() { + + } + }); } + } }); ViewClicksAntiShake.clicksAntiShake(gameCloseWheat, new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - if (disable) { - disable = false; - // 设置禁用麦克风采集 - RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable); - ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat); + if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) { + if (disable) { + disable = false; + // 设置禁用麦克风采集 + RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable); + ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat); + LiveNetManager.get(mContext) + .onMic(mLiveUid, new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + + } + + @Override + public void onError(String error) { + + } + }); + } else { + disable = true; + // 设置禁用麦克风采集 + RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable); + ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat); + LiveNetManager.get(mContext) + .offMic(mLiveUid, new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + + } + + @Override + public void onError(String error) { + + } + }); + } + } else { - disable = true; - // 设置禁用麦克风采集 - RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable); - ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat); + mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() { + @Override + public void run() { + + } + }); } + } }); ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_review_input), new ViewClicksAntiShake.ViewClicksCallBack() { @@ -327,7 +468,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti public void onJoinRoomSuccess(RCRTCRoom rcrtcRoom) { // 主动订阅远端用户发布的资源 - gameMicManager.subscribeAVStream(); +// gameMicManager.subscribeAVStream(); } @Override @@ -350,16 +491,28 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti } }); + LiveNetManager.get(mContext) + .joinMic(mLiveUid, new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + + } + + @Override + public void onError(String error) { + + } + }); } @Override public void onPublishFailed() { - ToastUtil.show("发布失败 "); + ToastUtil.show(WordUtil.isNewZh() ? "語音加入失敗" : "Voice joining failed"); } @Override public void onSubscribeSuccess(List inputStreamList) { - ToastUtil.show("订阅成功 "); +// ToastUtil.show("订阅成功 "); } @Override @@ -367,6 +520,22 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti ToastUtil.show("订阅失败 "); } + @Override + public void onSubscribeSuccess(String userID, boolean mute, int position) { + runOnUiThread(new Runnable() { + @Override + public void run() { + sudGameUserListAdapter.muteUser(userID, mute, position); + } + }); + + } + + @Override + public void onSubscribeFailed(String userID) { + ToastUtil.show("订阅失败 "); + } + @Override public void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser) { @@ -382,6 +551,11 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti mLiveChatAdapter.insertItem(sudGameChatImModel); } + @Override + public void refreshSudGameUserList(List personList) { + sudGameUserListAdapter.refreshSudGameUserList(personList); + } + @Override public void onUnPublishStreamsSuccess() { runOnUiThread(new Runnable() { @@ -392,6 +566,18 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti gameCloseWheat.setVisibility(View.INVISIBLE); } }); + LiveNetManager.get(mContext) + .leaveMic(mLiveUid, new HttpCallback() { + @Override + public void onSuccess(HttpCallbackModel data) { + + } + + @Override + public void onError(String error) { + + } + }); } @@ -404,4 +590,31 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti public void onSudGameSocketImEvent(SudGameSocketImEvent event) { gameMicManager.processingMessage(event); } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSudGameUserModel(SudGameUserModel model) { + if (model.isNullUser()) { + if (!publishDefault) { + if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) { + if (sudGameUserListAdapter.isMicMax()) { + ToastUtil.show(WordUtil.isNewZh() ? "上麥人數最大7人" : "The maximum number of people on the microphone is 7"); + } else { + gameMicManager.publishDefaultAVStream(); + } + + } else { + mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() { + @Override + public void run() { + + } + }); + } + + } else { + ToastUtil.show(WordUtil.isNewZh() ? "已經是上麥狀態" : "It is already in the wheat state"); + } + + } + } } diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java index 800802944..8c1c4ed6f 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveUserDialogFragment.java @@ -554,6 +554,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.ai_te), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { + if (TextUtils.equals(mLiveUid, "uid")) return; if (!TextUtils.isEmpty(mUserBean.getId()) && !TextUtils.isEmpty(mUserBean.getUserNiceName())) { Bus.get().post(new LiveAudienceEvent() .setType(LiveAudienceEvent.LiveAudienceType.INPUT_DIALOG) @@ -630,7 +631,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On * 跳转到个人主页 */ private void forwardHomePage() { - + if (TextUtils.equals(mLiveUid, "uid")) return; dismiss(); Constants.mStream = mStream; RouteUtil.forwardUserHome(mContext, mToUid, true, mLiveUid, 0); @@ -640,11 +641,13 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On * 举报 */ private void report() { + if (TextUtils.equals(mLiveUid, "uid")) return; LiveReportActivity.forward(mContext, mToUid); } private void gotoLive(String live_id) { + if (TextUtils.equals(mLiveUid, "uid")) return; dismiss(); DialogUitl.showSimpleDialog(mContext, mContext.getString(R.string.party_studio), new DialogUitl.SimpleCallback() { @Override @@ -698,6 +701,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On } setAttention(); } else if (i == R.id.btn_home_page) { + if (TextUtils.equals(mLiveUid, "uid")) return; if (isAnchor) { MobclickAgent.onEvent(mContext, "anchor_avatar_index", "点主播主页"); } else { @@ -705,18 +709,22 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On } forwardHomePage(); } else if (i == R.id.btn_report) { + if (TextUtils.equals(mLiveUid, "uid")) return; report(); } else if (i == R.id.avatar) { + if (TextUtils.equals(mLiveUid, "uid")) return; if (isAnchor) { MobclickAgent.onEvent(mContext, "anchor_avatar_btn", "点主播头像"); } forwardHomePage(); } else if (i == R.id.btn_guard) { + if (TextUtils.equals(mLiveUid, "uid")) return; MobclickAgent.onEvent(mContext, "anchor_avatar_guard", "守护按钮"); ((LiveActivity) mContext).openNewGuardListWindow(mContext instanceof LiveRyAnchorActivity, mToUid); } else if (i == R.id.btn_live) { gotoLive(mToUid); } else if (i == R.id.noble_icon_layout) { + if (TextUtils.equals(mLiveUid, "uid")) return; if (isAnchor) { dismiss(); ((LiveActivity) mContext).openFansWindow(mToUid); @@ -726,6 +734,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On .setType(LiveAudienceEvent.LiveAudienceType.NOBLE)); } } else if (i == R.id.btn_setting) { + if (TextUtils.equals(mLiveUid, "uid")) return; setting(); } } @@ -782,6 +791,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On private DialogUitl.StringArrayDialogCallback mArrayDialogCallback = new DialogUitl.StringArrayDialogCallback() { @Override public void onItemClick(String text, int tag) { + if (TextUtils.equals(mLiveUid, "uid")) return; if (tag == R.string.live_setting_kick) { kick(); @@ -815,6 +825,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On * 查看管理员列表 */ private void adminList() { + if (TextUtils.equals(mLiveUid, "uid")) return; dismiss(); ((LiveActivity) mContext).openAdminListWindow(); } @@ -823,6 +834,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On * 踢人 */ private void kick() { + if (TextUtils.equals(mLiveUid, "uid")) return; LiveHttpUtil.kicking(mLiveUid, mToUid, new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { @@ -839,6 +851,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On * 永久禁言->改成三天禁言 */ private void setShutUp() { + if (TextUtils.equals(mLiveUid, "uid")) return; LiveHttpUtil.setShutUp(mLiveUid, "0", 0, mToUid, new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { @@ -855,6 +868,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On * 本场禁言 */ private void setShutUp2() { + if (TextUtils.equals(mLiveUid, "uid")) return; LiveHttpUtil.setShutUp(mLiveUid, mStream, 1, mToUid, new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { @@ -872,6 +886,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On * 设置或取消管理员 */ private void setAdmin() { + if (TextUtils.equals(mLiveUid, "uid")) return; LiveHttpUtil.setAdmin(mLiveUid, mToUid, new HttpCallback() { @Override public void onSuccess(int code, String msg, String[] info) { @@ -893,6 +908,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On * 超管关闭直播间 */ private void closeLive() { + if (TextUtils.equals(mLiveUid, "uid")) return; dismiss(); LiveHttpUtil.superCloseRoom(mLiveUid, 0, mSuperCloseRoomCallback); } @@ -901,11 +917,13 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On * 超管关闭直播间并禁止主播直播 */ private void closeLive2() { + if (TextUtils.equals(mLiveUid, "uid")) return; dismiss(); LiveHttpUtil.superCloseRoom(mLiveUid, 1, mSuperCloseRoomCallback); } private void setShutUp3() { + if (TextUtils.equals(mLiveUid, "uid")) return; new LiveSettingSilenceDialog(mContext) .setItemClickListener((bean, position) -> { LiveHttpUtil.setShutUp(mLiveUid, mStream, 1, mToUid, bean + "", new HttpCallback() { @@ -927,6 +945,7 @@ public class LiveUserDialogFragment extends AbsDialogFragment implements View.On * 超管关闭直播间并禁用主播账户 */ private void forbidAccount() { + if (TextUtils.equals(mLiveUid, "uid")) return; dismiss(); LiveHttpUtil.superCloseRoom(mLiveUid, 2, mSuperCloseRoomCallback); } diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index 2f1f5ce7d..eaa40cc4e 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -74,6 +74,7 @@ import com.yunbao.common.event.MainHomeCommunityToChatEvent; import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.event.NoviceInstructorEvent; import com.yunbao.common.event.RongIMConnectionStatusEvent; +import com.yunbao.common.event.SudGameUserEvent; import com.yunbao.common.event.UpdateTablePointMe; import com.yunbao.common.http.CommonHttpConsts; import com.yunbao.common.http.CommonHttpUtil; @@ -103,7 +104,9 @@ import com.yunbao.common.views.APKUpdateCustomPopup; import com.yunbao.common.views.AbsMainViewHolder; import com.yunbao.common.views.floatingview.APPEasyFloat; import com.yunbao.common.views.weight.LiveFloatView; +import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAudienceActivity; +import com.yunbao.live.dialog.LiveUserDialogFragment; import com.yunbao.live.utils.LiveStorge; import com.yunbao.main.R; import com.yunbao.main.adapter.FullAdToBannerTransition; @@ -1426,6 +1429,11 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene findViewById(R.id.banner_click).setVisibility(View.VISIBLE); } + @Subscribe(threadMode = ThreadMode.MAIN) + public void onSudGameUserEvent(SudGameUserEvent event) { + + } + @Subscribe(threadMode = ThreadMode.MAIN) public void onLiveFloatEvent(LiveFloatEvent event) { if (event != null && event.getmLiveBean() != null && !TextUtils.isEmpty(event.getmLiveBean().getPull())) { @@ -1444,5 +1452,8 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene MobclickAgent.onEvent(mContext, "home_page_to_redpk", "首页点击右下角去红包专区"); mainHomeViewHolder.setCurPosition(3); }); + } + + } diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java index 11bf76eb6..97345b408 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java @@ -17,7 +17,7 @@ import com.google.gson.Gson; import com.lxj.xpopup.XPopup; import com.lxj.xpopup.enums.PopupPosition; import com.yunbao.common.activity.AbsActivity; -import com.yunbao.common.activity.SudGameActivity; +import com.yunbao.live.activity.SudGameActivity; import com.yunbao.common.adapter.RefreshAdapter; import com.yunbao.common.adapter.SudGameListAdapter; import com.yunbao.common.bean.CreateSudRoomModel;