This commit is contained in:
18401019693 2024-01-23 09:50:34 +08:00
parent 1eb43fb8cf
commit 64f9cee3af
14 changed files with 154 additions and 78 deletions

View File

@ -6,6 +6,17 @@ public class SudGameChatImModel extends BaseModel {
//文字消息 //文字消息
private String textMessage; private String textMessage;
private boolean welcomMessage;
public boolean isWelcomMessage() {
return welcomMessage;
}
public SudGameChatImModel setWelcomMessage(boolean welcomMessage) {
this.welcomMessage = welcomMessage;
return this;
}
public String getNickname() { public String getNickname() {
return nickname; return nickname;
} }

View File

@ -1,5 +1,7 @@
package com.yunbao.common.bean; package com.yunbao.common.bean;
import android.text.TextUtils;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
public class SudGameUserModel extends BaseModel { public class SudGameUserModel extends BaseModel {
@ -14,6 +16,21 @@ public class SudGameUserModel extends BaseModel {
private int id; private int id;
@SerializedName("mic_status") @SerializedName("mic_status")
private int micStatus; //麦克风状态 2.打开麦克风 3.关闭麦克风 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; private boolean mute = false;

View File

@ -392,6 +392,7 @@ public class GameMicManager {
@Override @Override
public void onSuccess() { public void onSuccess() {
Log.i("tx", "加入成功"); Log.i("tx", "加入成功");
enterRoom();
} }
@ -440,7 +441,18 @@ public class GameMicManager {
SudGameSocketImEvent.MsgDTO msgDTO = msgDTOS.get(0); SudGameSocketImEvent.MsgDTO msgDTO = msgDTOS.get(0);
//正常文字消息 //正常文字消息
if (TextUtils.equals(msgDTO.getMethod(), "SendMsg")) { 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")) { } else if (TextUtils.equals(msgDTO.getMethod(), "sudGameRoomVoiceList")) {
List<SudGameUserModel> personList = new Gson().fromJson(msgDTO.getCt(), new TypeToken<List<SudGameUserModel>>() { List<SudGameUserModel> personList = new Gson().fromJson(msgDTO.getCt(), new TypeToken<List<SudGameUserModel>>() {
}.getType()); }.getType());
@ -451,12 +463,7 @@ public class GameMicManager {
} }
} }
/** private void sendChatMessage(String textMessage, String method) {
* 发送聊天信息
*
* @param textMessage
*/
public void sendMessage(String textMessage) {
IMLoginModel loginModel = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo(); IMLoginModel loginModel = IMLoginManager.get(CommonAppContext.sInstance.getApplicationContext()).getUserInfo();
SudGameSocketImEvent sudGameSocketImEvent = new SudGameSocketImEvent(); SudGameSocketImEvent sudGameSocketImEvent = new SudGameSocketImEvent();
sudGameSocketImEvent.setRetcode("000000"); sudGameSocketImEvent.setRetcode("000000");
@ -467,7 +474,7 @@ public class GameMicManager {
.setCt(textMessage) .setCt(textMessage)
.setEquipment("app") .setEquipment("app")
.setUid(String.valueOf(loginModel.getId())) .setUid(String.valueOf(loginModel.getId()))
.setMethod("SendMsg") .setMethod(method)
.setUname(loginModel.getUserNicename()) .setUname(loginModel.getUserNicename())
.setRoomnum(mRoomID); .setRoomnum(mRoomID);
@ -499,6 +506,23 @@ public class GameMicManager {
}); });
} }
/**
* 发送聊天信息
*
* @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相关回调 * activity相关回调
*/ */

View File

@ -32,18 +32,29 @@ public class SudGameChatViewHolder extends RecyclerView.ViewHolder {
public void sudGameChat(SudGameChatImModel msgModel) { public void sudGameChat(SudGameChatImModel msgModel) {
new LoadDian9TuUtilSud().loadDian9TuAssets(itemView.getContext(), mBg, 1); new LoadDian9TuUtilSud().loadDian9TuAssets(itemView.getContext(), mBg, 1);
StringBuffer buffer = new StringBuffer(); StringBuffer buffer = new StringBuffer();
SpannableStringBuilder builder = new SpannableStringBuilder();
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() + ":"; String userName = msgModel.getNickname() + ":";
buffer.append(userName) buffer.append(userName)
.append(" ") .append(" ")
.append(msgModel.getTextMessage()); .append(msgModel.getTextMessage());
String msg = buffer.toString(); String msg = buffer.toString();
int unameIndexOf = msg.indexOf(userName); int unameIndexOf = msg.indexOf(userName);
int unameSize = userName.length(); int unameSize = userName.length();
SpannableStringBuilder builder = new SpannableStringBuilder();
builder.append(msg); builder.append(msg);
builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFBD0D")), unameIndexOf, unameIndexOf + unameSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); builder.setSpan(new ForegroundColorSpan(Color.parseColor("#FFBD0D")), unameIndexOf, unameIndexOf + unameSize, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
chatMessage.setText(builder); chatMessage.setText(builder);
} }
} }

View File

@ -1,8 +1,6 @@
package com.yunbao.common.views; package com.yunbao.common.views;
import android.app.Activity;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout; import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -19,11 +17,11 @@ import com.yunbao.common.bean.SudGameUserModel;
import com.yunbao.common.dialog.SudGameSmallPopupPindow; import com.yunbao.common.dialog.SudGameSmallPopupPindow;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.Bus; 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; import com.yunbao.common.views.weight.ViewClicksAntiShake;
public class SudGameUserListViewHolder extends RecyclerView.ViewHolder { 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 FrameLayout user_layout;
private RoundedImageView sud_game_user; private RoundedImageView sud_game_user;
private LinearLayout layout; private LinearLayout layout;
@ -35,6 +33,7 @@ public class SudGameUserListViewHolder extends RecyclerView.ViewHolder {
user_layout = itemView.findViewById(R.id.user_layout); user_layout = itemView.findViewById(R.id.user_layout);
mic_status = itemView.findViewById(R.id.mic_status); mic_status = itemView.findViewById(R.id.mic_status);
layout = itemView.findViewById(R.id.layout); layout = itemView.findViewById(R.id.layout);
game_status = itemView.findViewById(R.id.game_status);
} }
public void upData(SudGameUserModel sudGameUserModel, SudGameUserListAdapter.SudGameSmallCallBack sudGameSmallCallBack, int position) { public void upData(SudGameUserModel sudGameUserModel, SudGameUserListAdapter.SudGameSmallCallBack sudGameSmallCallBack, int position) {
@ -67,13 +66,19 @@ public class SudGameUserListViewHolder extends RecyclerView.ViewHolder {
if (sudGameUserModel.isMute()) { if (sudGameUserModel.isMute()) {
ImgLoader.display2(itemView.getContext(), R.mipmap.icon_game_close_wheat_mute, mic_status); 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() { ViewClicksAntiShake.clicksAntiShake(user_layout, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override @Override
public void onViewClicks() { 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) builder.hasShadowBg(false)
.isDestroyOnDismiss(true) .isDestroyOnDismiss(true)
.isLightStatusBar(false) .isLightStatusBar(false)
.maxHeight(DpUtil.dp2px(70))
.popupPosition(PopupPosition.Bottom) .popupPosition(PopupPosition.Bottom)
.asCustom(new SudGameSmallPopupPindow(itemView.getContext(), .asCustom(new SudGameSmallPopupPindow(itemView.getContext(),
sudGameUserModel, sudGameUserModel,

View File

@ -23,20 +23,20 @@
android:layout_marginStart="23dp" android:layout_marginStart="23dp"
android:layout_marginTop="25dp" android:layout_marginTop="25dp"
android:background="@drawable/bg_live_sud_game_top_new" android:background="@drawable/bg_live_sud_game_top_new"
android:gravity="center"> android:gravity="start|center_vertical">
<LinearLayout <LinearLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="center" android:layout_marginStart="10dp"
android:gravity="start"
android:orientation="vertical"> android:orientation="vertical">
<TextView <TextView
android:id="@+id/room_name" android:id="@+id/room_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp" android:layout_marginEnd="10dp"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
@ -96,7 +96,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="137dp" android:layout_width="34dp"
android:layout_height="34dp" android:layout_height="34dp"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
@ -106,10 +106,8 @@
android:id="@+id/game_review_input" android:id="@+id/game_review_input"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@drawable/bg_live_sud_game_bottom_input" android:background="@mipmap/icon_game_review_input"
android:gravity="center" android:gravity="center"
android:text="@string/game_review_input"
android:textColor="@color/white"
android:textSize="14sp" /> android:textSize="14sp" />
</LinearLayout> </LinearLayout>

View File

@ -5,7 +5,7 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="88dp" android:layout_height="88dp"
android:layout_marginStart="15dp" android:layout_marginStart="15dp"
android:layout_marginTop="14dp"
android:layout_marginEnd="15dp" android:layout_marginEnd="15dp"
android:background="@mipmap/background_home_sud_game_list" android:background="@mipmap/background_home_sud_game_list"
android:orientation="horizontal"> android:orientation="horizontal">
@ -76,14 +76,14 @@
<TextView <TextView
android:id="@+id/player_we_are_2" android:id="@+id/player_we_are_2"
android:layout_width="70dp" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="3dp" android:layout_marginEnd="3dp"
android:layout_marginBottom="3dp" android:layout_marginBottom="3dp"
android:ellipsize="end" android:ellipsize="end"
android:singleLine="true" android:singleLine="true"
android:text="@string/interactive_game_player_we_are_2" android:text="@string/interactive_game_player_we_are_2"
android:textColor="#000" android:textColor="#B3000000"
android:textSize="12sp" /> android:textSize="12sp" />
<LinearLayout <LinearLayout
@ -162,6 +162,7 @@
android:layout_width="68dp" android:layout_width="68dp"
android:layout_height="26dp" android:layout_height="26dp"
android:layout_gravity="end" android:layout_gravity="end"
android:layout_marginTop="2dp"
android:background="@drawable/bg_home_sud_list_sill" android:background="@drawable/bg_home_sud_list_sill"
android:gravity="center_vertical"> android:gravity="center_vertical">

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="70dp" android:layout_width="70dp"
android:layout_height="110dp" android:layout_height="70dp"
android:background="@mipmap/backgroud_sud_game_small_window" android:background="@mipmap/backgroud_sud_game_small_window"
android:orientation="vertical"> android:orientation="vertical">

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="match_parent"
android:gravity="center_vertical" android:gravity="center_vertical"
@ -39,5 +39,14 @@
android:layout_marginStart="5dp" android:layout_marginStart="5dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:src="@mipmap/icon_game_close_wheat_mute" /> android:src="@mipmap/icon_game_close_wheat_mute" />
<ImageView
android:id="@+id/game_status"
android:layout_width="18dp"
android:layout_height="14dp"
android:layout_marginStart="5dp"
android:layout_gravity="bottom|center_horizontal"
android:src="@mipmap/icon_game_status" />
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -9,9 +9,9 @@ ext {
] ]
manifestPlaceholders = [ manifestPlaceholders = [
// //
serverHost : "https://napi.yaoulive.com", // serverHost : "https://napi.yaoulive.com",
// //
//serverHost : " https://ceshi.yaoulive.com", serverHost : " https://ceshi.yaoulive.com",
// //

View File

@ -297,6 +297,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
.asCustom(new LiveSudGameHistoryPopup(mContext, customSidebarChildModels)).show(); .asCustom(new LiveSudGameHistoryPopup(mContext, customSidebarChildModels)).show();
} }
}); });
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_seat), new ViewClicksAntiShake.ViewClicksCallBack() { ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_seat), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override @Override
public void onViewClicks() { public void onViewClicks() {
@ -333,7 +334,10 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
@Override @Override
public void onViewClicks() { public void onViewClicks() {
if (imOff && gameMicManager != null) { if (imOff && gameMicManager != null) {
if (mProcessResultUtil.checkPermissions(new String[]{Manifest.permission.RECORD_AUDIO})) {
gameCloseWheat.post(new Runnable() {
@Override
public void run() {
if (disable) { if (disable) {
disable = false; disable = false;
// 设置禁用麦克风采集 // 设置禁用麦克风采集
@ -371,15 +375,10 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
}); });
ToastUtil.show(WordUtil.isNewZh() ? "麥克風已關閉" : "Microphone turned off"); ToastUtil.show(WordUtil.isNewZh() ? "麥克風已關閉" : "Microphone turned off");
} }
} else {
mProcessResultUtil.requestPermissions(new String[]{Manifest.permission.RECORD_AUDIO}, new Runnable() {
@Override
public void run() {
} }
}); });
}
} }

View File

@ -191,6 +191,7 @@
android:layout_height="match_parent"> android:layout_height="match_parent">
<com.yunbao.common.custom.CommonRefreshView <com.yunbao.common.custom.CommonRefreshView
android:layout_marginTop="5dp"
android:id="@+id/refreshView" android:id="@+id/refreshView"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"