diff --git a/common/src/main/java/com/yunbao/common/adapter/SudGameUserListAdapter.java b/common/src/main/java/com/yunbao/common/adapter/SudGameUserListAdapter.java index f20aeea94..e8893b9f1 100644 --- a/common/src/main/java/com/yunbao/common/adapter/SudGameUserListAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/SudGameUserListAdapter.java @@ -43,12 +43,18 @@ public class SudGameUserListAdapter extends RecyclerView.Adapter { } - public void refreshSudGameUserList(List gameUserModels) { + public void refreshSudGameUserList(List gameUserModels, List muteUser) { this.gameUserModels.clear(); if (gameUserModels.size() < 7) { micMax = false; this.gameUserModels.addAll(gameUserModels); for (int i = 0; i < this.gameUserModels.size(); i++) { + for (String userID : muteUser) { + if (TextUtils.equals(userID, String.valueOf(this.gameUserModels.get(i).getId()))) { + this.gameUserModels.get(i).setMute(true); + } + + } this.gameUserModels.get(i).setNullUser(false); } int size = 7 - gameUserModels.size(); @@ -65,6 +71,12 @@ public class SudGameUserListAdapter extends RecyclerView.Adapter { micMax = true; for (int i = 0; i < 7; i++) { + for (String userID : muteUser) { + if (TextUtils.equals(userID, String.valueOf(this.gameUserModels.get(i).getId()))) { + this.gameUserModels.get(i).setMute(true); + } + + } this.gameUserModels.add(gameUserModels.get(i).setNullUser(false)); } } @@ -81,7 +93,7 @@ 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); + sudGameUserListViewHolder.upData(gameUserModels.get(position), sudGameSmallCallBack, position); } @Override @@ -98,7 +110,7 @@ public class SudGameUserListAdapter extends RecyclerView.Adapter { SudGameUserModel sudGameUserModel = gameUserModels.get(i); if (!sudGameUserModel.isNullUser()) { if (TextUtils.equals(userID, String.valueOf(sudGameUserModel.getId()))) { - gameUserModels.get(i).setMicStatus(mute ? 1 : 3); + gameUserModels.get(i).setMute(mute); } } 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 2a55fac19..a614ee9d7 100644 --- a/common/src/main/java/com/yunbao/common/bean/SudGameUserModel.java +++ b/common/src/main/java/com/yunbao/common/bean/SudGameUserModel.java @@ -15,6 +15,17 @@ public class SudGameUserModel extends BaseModel { @SerializedName("mic_status") private int micStatus; //麦克风状态 2.打开麦克风 3.关闭麦克风 + private boolean mute = false; + + public boolean isMute() { + return mute; + } + + public SudGameUserModel setMute(boolean mute) { + this.mute = mute; + return this; + } + public boolean isNullUser() { return nullUser; } diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameInputPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/SudGameInputPopupWindow.java index 6cac0cc25..08c1f08d5 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameInputPopupWindow.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameInputPopupWindow.java @@ -1,7 +1,10 @@ package com.yunbao.common.dialog; +import static android.content.Context.INPUT_METHOD_SERVICE; + import android.content.Context; import android.text.TextUtils; +import android.view.inputmethod.InputMethodManager; import android.widget.EditText; import androidx.annotation.NonNull; @@ -18,7 +21,7 @@ import com.yunbao.common.views.weight.ViewClicksAntiShake; public class SudGameInputPopupWindow extends BottomPopupView { private EditText textMessage; private SudGameInputCallBack sudGameInputCallBack; - + private InputMethodManager imm; public SudGameInputPopupWindow(@NonNull Context context, SudGameInputCallBack sudGameInputCallBack) { super(context); this.sudGameInputCallBack = sudGameInputCallBack; @@ -40,6 +43,7 @@ public class SudGameInputPopupWindow extends BottomPopupView { } private void initView() { + imm = (InputMethodManager) getContext().getSystemService(INPUT_METHOD_SERVICE); textMessage = findViewById(R.id.text_message); ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.send), new ViewClicksAntiShake.ViewClicksCallBack() { @Override @@ -60,7 +64,11 @@ public class SudGameInputPopupWindow extends BottomPopupView { } } }); - + textMessage.postDelayed(() -> { + //软键盘弹出 + imm.showSoftInput(textMessage, InputMethodManager.SHOW_FORCED); + textMessage.requestFocus(); + }, 200); } private void initDate() { diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameSmallPopupPindow.java b/common/src/main/java/com/yunbao/common/dialog/SudGameSmallPopupPindow.java index 089e34caa..5c2d527d8 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameSmallPopupPindow.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameSmallPopupPindow.java @@ -1,6 +1,7 @@ package com.yunbao.common.dialog; import android.content.Context; +import android.text.TextUtils; import android.widget.TextView; import androidx.annotation.NonNull; @@ -8,6 +9,7 @@ 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.manager.IMLoginManager; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; @@ -41,6 +43,10 @@ public class SudGameSmallPopupPindow extends AttachPopupView { ViewClicksAntiShake.clicksAntiShake(viewUnMute, new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { + if (TextUtils.equals(String.valueOf(IMLoginManager.get(getContext()).getUserInfo().getId()), String.valueOf(sudGameUserModel.getId()))) { + ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself"); + return; + } if (sudGameUserModel.getMicStatus() == 3) { ToastUtil.show("对方未开麦!"); return; 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 357197f1a..efd2497e3 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 @@ -181,6 +181,7 @@ public class GameMicManager { public void refreshStreams(List personList) { + final List inputStreams = new ArrayList<>(); for (SudGameUserModel sudGameUserModel : personList) { 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 6dce6f6ef..98ba77a66 100644 --- a/common/src/main/java/com/yunbao/common/views/SudGameUserListViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/SudGameUserListViewHolder.java @@ -1,8 +1,11 @@ package com.yunbao.common.views; +import android.app.Activity; import android.view.View; +import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.LinearLayout; import androidx.annotation.NonNull; import androidx.recyclerview.widget.RecyclerView; @@ -16,12 +19,14 @@ 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.utils.DeviceUtils; 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; + private LinearLayout layout; public SudGameUserListViewHolder(@NonNull View itemView) { super(itemView); @@ -29,9 +34,18 @@ public class SudGameUserListViewHolder extends RecyclerView.ViewHolder { 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); + layout = itemView.findViewById(R.id.layout); } public void upData(SudGameUserModel sudGameUserModel, SudGameUserListAdapter.SudGameSmallCallBack sudGameSmallCallBack, int position) { +// layout.post(new Runnable() { +// @Override +// public void run() { +// RecyclerView.LayoutParams params = new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); +// params.width = DeviceUtils.getScreenWidth((Activity) itemView.getContext()) / 7; +// layout.setLayoutParams(params); +// } +// }); if (sudGameUserModel.isNullUser()) { vacancy_sud_game.setVisibility(View.VISIBLE); user_layout.setVisibility(View.GONE); @@ -49,7 +63,8 @@ public class SudGameUserListViewHolder extends RecyclerView.ViewHolder { 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) { + } + if (sudGameUserModel.isMute()) { ImgLoader.display2(itemView.getContext(), R.mipmap.icon_game_close_wheat_mute, mic_status); } ViewClicksAntiShake.clicksAntiShake(user_layout, new ViewClicksAntiShake.ViewClicksCallBack() { @@ -62,16 +77,16 @@ public class SudGameUserListViewHolder extends RecyclerView.ViewHolder { .popupPosition(PopupPosition.Bottom) .asCustom(new SudGameSmallPopupPindow(itemView.getContext(), sudGameUserModel, - sudGameUserModel.getMicStatus() == 1, + sudGameUserModel.isMute(), new SudGameSmallPopupPindow.SudGameSmallCallBack() { @Override public void unMute() { - sudGameSmallCallBack.unMute(sudGameUserModel.getId() + "",position); + sudGameSmallCallBack.unMute(sudGameUserModel.getId() + "", position); } @Override public void mute() { - sudGameSmallCallBack.mute(sudGameUserModel.getId() + "",position); + sudGameSmallCallBack.mute(sudGameUserModel.getId() + "", position); } @Override 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 4f6049b06..2d86b7c83 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 @@ The quantity of goods exchanged has reached the upper limit Successfully opened You have purchased the BattlePass + Comment + See Information + Unmute + Mute diff --git a/common/src/main/res/values-zh-rHK/strings.xml b/common/src/main/res/values-zh-rHK/strings.xml index 315906b80..55086a50c 100644 --- a/common/src/main/res/values-zh-rHK/strings.xml +++ b/common/src/main/res/values-zh-rHK/strings.xml @@ -1423,4 +1423,8 @@ 商品兌換數量已達到上限 開通成功 您已購買該戰令 + 評論 + 查看信息 + 取消靜音 + 靜音 diff --git a/common/src/main/res/values-zh-rTW/strings.xml b/common/src/main/res/values-zh-rTW/strings.xml index b8d60456c..3aa31fb72 100644 --- a/common/src/main/res/values-zh-rTW/strings.xml +++ b/common/src/main/res/values-zh-rTW/strings.xml @@ -1422,4 +1422,8 @@ 商品兌換數量已達到上限 開通成功 您已購買該戰令 + 評論 + 查看信息 + 取消靜音 + 靜音 diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index da10bc513..a4f2e870a 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1421,4 +1421,8 @@ 商品兌換數量已達到上限 開通成功 您已購買該戰令 + 評論 + 查看信息 + 取消靜音 + 靜音 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index dfea3feca..a1ea01a49 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -666,7 +666,7 @@ ReceiveAwards One free gift privilege! - Send out + Send I am sorry video myname.pdlive.shayu.fileprovider @@ -1428,8 +1428,8 @@ Limited ride And limited avatar frame The quantity of goods exchanged has reached the upper limit Successfully opened You have purchased the BattlePass - 評論 - 查看信息 - 取消靜音 - 靜音 + Comment + See Information + Unmute + Mute diff --git a/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java b/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java index c0cff3132..5ffbe0506 100644 --- a/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java @@ -32,7 +32,6 @@ 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; @@ -53,7 +52,6 @@ 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; @@ -66,6 +64,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; @@ -83,6 +82,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti private SudGameChatAdapter mLiveChatAdapter; private SudGameUserListAdapter sudGameUserListAdapter; private ProcessResultUtil mProcessResultUtil; + private List muteUser = new ArrayList<>(); @Override protected int getLayoutId() { @@ -126,18 +126,7 @@ 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() { @@ -215,11 +204,12 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti } else { ToastUtil.show(WordUtil.isNewZh() ? "無法對本人靜音" : "Unable to mute myself"); } - + muteUser.remove(userID); } @Override public void mute(String userID, int position) { + muteUser.add(userID); if (!TextUtils.equals(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()), userID)) { gameMicManager.refreshStreams(userID, true, position); } else { @@ -245,6 +235,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti roomName.setText(mCreateSudRoomModel.getRoomName()); roomNumber.setText(mCreateSudRoomModel.getSudGameRoomId()); } + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.exit), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { @@ -312,6 +303,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti } }); + ToastUtil.show(WordUtil.isNewZh() ? "麥克風已開啟" : "Microphone turned on"); } else { disable = true; // 设置禁用麦克风采集 @@ -329,6 +321,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti } }); + ToastUtil.show(WordUtil.isNewZh() ? "麥克風已關閉" : "Microphone turned off"); } } else { @@ -466,7 +459,18 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti @Override public void onJoinRoomSuccess(RCRTCRoom rcrtcRoom) { + LiveNetManager.get(mContext).getRoomMicData(mLiveUid, new HttpCallback>() { + @Override + public void onSuccess(List data) { + gameMicManager.refreshStreams(data); + sudGameUserListAdapter.refreshSudGameUserList(data, muteUser); + } + @Override + public void onError(String error) { + ToastUtil.show(error); + } + }); // 主动订阅远端用户发布的资源 // gameMicManager.subscribeAVStream(); } @@ -525,6 +529,11 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti runOnUiThread(new Runnable() { @Override public void run() { + if (mute) { + ToastUtil.show(WordUtil.isNewZh() ? "已靜音該用戶" : "The user has been muted"); + } else { + ToastUtil.show(WordUtil.isNewZh() ? "已取消該用戶靜音" : "The user has been unmuted"); + } sudGameUserListAdapter.muteUser(userID, mute, position); } }); @@ -553,7 +562,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti @Override public void refreshSudGameUserList(List personList) { - sudGameUserListAdapter.refreshSudGameUserList(personList); + sudGameUserListAdapter.refreshSudGameUserList(personList, muteUser); } @Override