diff --git a/common/src/main/java/com/yunbao/common/bean/SudGameChatImModel.java b/common/src/main/java/com/yunbao/common/bean/SudGameChatImModel.java index e55ee691d..3caf0159e 100644 --- a/common/src/main/java/com/yunbao/common/bean/SudGameChatImModel.java +++ b/common/src/main/java/com/yunbao/common/bean/SudGameChatImModel.java @@ -6,6 +6,17 @@ public class SudGameChatImModel extends BaseModel { //文字消息 private String textMessage; + private boolean welcomMessage; + + public boolean isWelcomMessage() { + return welcomMessage; + } + + public SudGameChatImModel setWelcomMessage(boolean welcomMessage) { + this.welcomMessage = welcomMessage; + return this; + } + public String getNickname() { return nickname; } 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 a614ee9d7..78aefaed9 100644 --- a/common/src/main/java/com/yunbao/common/bean/SudGameUserModel.java +++ b/common/src/main/java/com/yunbao/common/bean/SudGameUserModel.java @@ -1,5 +1,7 @@ package com.yunbao.common.bean; +import android.text.TextUtils; + import com.google.gson.annotations.SerializedName; public class SudGameUserModel extends BaseModel { @@ -14,6 +16,21 @@ public class SudGameUserModel extends BaseModel { private int id; @SerializedName("mic_status") private int micStatus; //麦克风状态 2.打开麦克风 3.关闭麦克风 + @SerializedName("game_status") + private String gameStatus;// 游戏状态 1.未在游戏状态 2.游戏中; + + public String getGameStatus() { + return gameStatus; + } + + public boolean isGameIng() { + return TextUtils.equals(getGameStatus(), "2") ; + } + + public SudGameUserModel setGameStatus(String gameStatus) { + this.gameStatus = gameStatus; + return this; + } private boolean mute = false; 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 09da6f188..eecc6647f 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 @@ -392,6 +392,7 @@ public class GameMicManager { @Override public void onSuccess() { Log.i("tx", "加入成功"); + enterRoom(); } @@ -440,7 +441,18 @@ public class GameMicManager { SudGameSocketImEvent.MsgDTO msgDTO = msgDTOS.get(0); //正常文字消息 if (TextUtils.equals(msgDTO.getMethod(), "SendMsg")) { - getView().insertItem(new SudGameChatImModel().setNickname(msgDTO.getUname()).setTextMessage(msgDTO.getCt())); + getView().insertItem(new SudGameChatImModel().setWelcomMessage(false).setNickname(msgDTO.getUname()).setTextMessage(msgDTO.getCt())); + } else if (TextUtils.equals(msgDTO.getMethod(), "welcomMessage")) { + // 欢迎(用户名)进入房间 Welcome (username) to the room + + StringBuffer stringBuffer = new StringBuffer(); + if (WordUtil.isNewZh()) { + stringBuffer.append("歡迎 ").append(msgDTO.getUname()).append(" 進入房間"); + } else { + stringBuffer.append("Welcome ").append(msgDTO.getUname()).append(" to enter the room"); + } + + getView().insertItem(new SudGameChatImModel().setWelcomMessage(true).setNickname(msgDTO.getUname()).setTextMessage(stringBuffer.toString())); } else if (TextUtils.equals(msgDTO.getMethod(), "sudGameRoomVoiceList")) { List personList = new Gson().fromJson(msgDTO.getCt(), new TypeToken>() { }.getType()); @@ -451,12 +463,7 @@ public class GameMicManager { } } - /** - * 发送聊天信息 - * - * @param textMessage - */ - public void sendMessage(String textMessage) { + private void sendChatMessage(String textMessage, String method) { IMLoginModel loginModel = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo(); SudGameSocketImEvent sudGameSocketImEvent = new SudGameSocketImEvent(); sudGameSocketImEvent.setRetcode("000000"); @@ -467,7 +474,7 @@ public class GameMicManager { .setCt(textMessage) .setEquipment("app") .setUid(String.valueOf(loginModel.getId())) - .setMethod("SendMsg") + .setMethod(method) .setUname(loginModel.getUserNicename()) .setRoomnum(mRoomID); @@ -494,11 +501,28 @@ public class GameMicManager { @Override public void onError(Message message, RongIMClient.ErrorCode errorCode) { - Log.i("tx", "发送成功"+errorCode.toString()); + Log.i("tx", "发送成功" + errorCode.toString()); } }); } + /** + * 发送聊天信息 + * + * @param textMessage + */ + public void sendMessage(String textMessage) { + sendChatMessage(textMessage, "SendMsg"); + } + + /** + * 进房间 + */ + public void enterRoom() { + IMLoginModel loginModel = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo(); + sendChatMessage(loginModel.getUserNicename(), "welcomMessage"); + } + /** * activity相关回调 */ diff --git a/common/src/main/java/com/yunbao/common/views/SudGameChatViewHolder.java b/common/src/main/java/com/yunbao/common/views/SudGameChatViewHolder.java index a76cbc058..bc7214618 100644 --- a/common/src/main/java/com/yunbao/common/views/SudGameChatViewHolder.java +++ b/common/src/main/java/com/yunbao/common/views/SudGameChatViewHolder.java @@ -32,18 +32,29 @@ public class SudGameChatViewHolder extends RecyclerView.ViewHolder { public void sudGameChat(SudGameChatImModel msgModel) { new LoadDian9TuUtilSud().loadDian9TuAssets(itemView.getContext(), mBg, 1); StringBuffer buffer = new StringBuffer(); - String userName = msgModel.getNickname() + ":"; - buffer.append(userName) - .append(" ") - .append(msgModel.getTextMessage()); - - String msg = buffer.toString(); - - int unameIndexOf = msg.indexOf(userName); - int unameSize = userName.length(); SpannableStringBuilder builder = new SpannableStringBuilder(); - builder.append(msg); - builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFBD0D")), unameIndexOf, unameIndexOf + unameSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + if (msgModel.isWelcomMessage()) { + String userName = msgModel.getNickname(); + buffer.append(msgModel.getTextMessage()); + String msg = buffer.toString(); + int unameIndexOf = msg.indexOf(userName); + int unameSize = userName.length(); + builder.append(msg); + builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFBD0D")), unameIndexOf, unameIndexOf + unameSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + } else { + + String userName = msgModel.getNickname() + ":"; + buffer.append(userName) + .append(" ") + .append(msgModel.getTextMessage()); + String msg = buffer.toString(); + + int unameIndexOf = msg.indexOf(userName); + int unameSize = userName.length(); + + builder.append(msg); + builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFBD0D")), unameIndexOf, unameIndexOf + unameSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + } chatMessage.setText(builder); } } 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 98ba77a66..0ba2aa016 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,6 @@ 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; @@ -19,11 +17,11 @@ 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.utils.DpUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; public class SudGameUserListViewHolder extends RecyclerView.ViewHolder { - private ImageView vacancy_sud_game, mic_status; + private ImageView vacancy_sud_game, mic_status, game_status; private FrameLayout user_layout; private RoundedImageView sud_game_user; private LinearLayout layout; @@ -35,6 +33,7 @@ public class SudGameUserListViewHolder extends RecyclerView.ViewHolder { user_layout = itemView.findViewById(R.id.user_layout); mic_status = itemView.findViewById(R.id.mic_status); layout = itemView.findViewById(R.id.layout); + game_status = itemView.findViewById(R.id.game_status); } public void upData(SudGameUserModel sudGameUserModel, SudGameUserListAdapter.SudGameSmallCallBack sudGameSmallCallBack, int position) { @@ -67,13 +66,19 @@ public class SudGameUserListViewHolder extends RecyclerView.ViewHolder { if (sudGameUserModel.isMute()) { ImgLoader.display2(itemView.getContext(), R.mipmap.icon_game_close_wheat_mute, mic_status); } + if (sudGameUserModel.isGameIng()) { + game_status.setVisibility(View.VISIBLE); + } else { + game_status.setVisibility(View.GONE); + } ViewClicksAntiShake.clicksAntiShake(user_layout, new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - XPopup.Builder builder = new XPopup.Builder(itemView.getContext()).atView(user_layout); + XPopup.Builder builder = new XPopup.Builder(itemView.getContext()).atView(sud_game_user); builder.hasShadowBg(false) .isDestroyOnDismiss(true) .isLightStatusBar(false) + .maxHeight(DpUtil.dp2px(70)) .popupPosition(PopupPosition.Bottom) .asCustom(new SudGameSmallPopupPindow(itemView.getContext(), sudGameUserModel, diff --git a/common/src/main/res/layout/activity_sud_game.xml b/common/src/main/res/layout/activity_sud_game.xml index e358ac494..509fdd08c 100644 --- a/common/src/main/res/layout/activity_sud_game.xml +++ b/common/src/main/res/layout/activity_sud_game.xml @@ -23,20 +23,20 @@ android:layout_marginStart="23dp" android:layout_marginTop="25dp" android:background="@drawable/bg_live_sud_game_top_new" - android:gravity="center"> + android:gravity="start|center_vertical"> diff --git a/common/src/main/res/layout/item_home_sud_game_list.xml b/common/src/main/res/layout/item_home_sud_game_list.xml index 93aeb12d2..266e1d844 100644 --- a/common/src/main/res/layout/item_home_sud_game_list.xml +++ b/common/src/main/res/layout/item_home_sud_game_list.xml @@ -5,7 +5,7 @@ android:layout_width="match_parent" android:layout_height="88dp" android:layout_marginStart="15dp" - android:layout_marginTop="14dp" + android:layout_marginEnd="15dp" android:background="@mipmap/background_home_sud_game_list" android:orientation="horizontal"> @@ -76,14 +76,14 @@ diff --git a/common/src/main/res/layout/view_sud_game_small.xml b/common/src/main/res/layout/view_sud_game_small.xml index 8c8d2aae6..95146fa4a 100644 --- a/common/src/main/res/layout/view_sud_game_small.xml +++ b/common/src/main/res/layout/view_sud_game_small.xml @@ -1,7 +1,7 @@ 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 2d86b7c83..d1cf29387 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,7 +1,7 @@ + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/icon_game_review_input.png b/common/src/main/res/mipmap-xxhdpi/icon_game_review_input.png new file mode 100644 index 000000000..3f3af8b80 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_game_review_input.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_game_status.png b/common/src/main/res/mipmap-xxhdpi/icon_game_status.png new file mode 100644 index 000000000..3ada94753 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_game_status.png differ diff --git a/config.gradle b/config.gradle index dbecffd33..7f16e5253 100644 --- a/config.gradle +++ b/config.gradle @@ -9,9 +9,9 @@ ext { ] manifestPlaceholders = [ //正式、 - serverHost : "https://napi.yaoulive.com", +// serverHost : "https://napi.yaoulive.com", // 测试 - //serverHost : " https://ceshi.yaoulive.com", + serverHost : " https://ceshi.yaoulive.com", //百度语音识别 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 1a24684c3..7c4122ed9 100644 --- a/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/SudGameActivity.java @@ -297,6 +297,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti .asCustom(new LiveSudGameHistoryPopup(mContext, customSidebarChildModels)).show(); } }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_seat), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { @@ -333,53 +334,51 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti @Override public void onViewClicks() { if (imOff && gameMicManager != null) { - 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) { - } + gameCloseWheat.post(new Runnable() { + @Override + public void run() { + 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) { + } - } - }); - ToastUtil.show(WordUtil.isNewZh() ? "麥克風已開啟" : "Microphone turned on"); - } 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) { - } + } + }); + ToastUtil.show(WordUtil.isNewZh() ? "麥克風已開啟" : "Microphone turned on"); + } 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) { + } - } - }); - ToastUtil.show(WordUtil.isNewZh() ? "麥克風已關閉" : "Microphone turned off"); - } - - } else { - mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() { - @Override - public void run() { + @Override + public void onError(String error) { + } + }); + ToastUtil.show(WordUtil.isNewZh() ? "麥克風已關閉" : "Microphone turned off"); } - }); - } + } + }); + + } diff --git a/main/src/main/res/layout/view_main_home_sud_game_list.xml b/main/src/main/res/layout/view_main_home_sud_game_list.xml index 12b6f8349..55e2b6618 100644 --- a/main/src/main/res/layout/view_main_home_sud_game_list.xml +++ b/main/src/main/res/layout/view_main_home_sud_game_list.xml @@ -191,6 +191,7 @@ android:layout_height="match_parent">