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 000000000..fed69cb32 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/backgroud_sud_game_small_window.png differ 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 000000000..8f78bc3f8 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_game_close_wheat_mute.png differ 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;