优化
This commit is contained in:
parent
1eb43fb8cf
commit
64f9cee3af
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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<SudGameUserModel> personList = new Gson().fromJson(msgDTO.getCt(), new TypeToken<List<SudGameUserModel>>() {
|
||||
}.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相关回调
|
||||
*/
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
|
@ -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">
|
||||
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_marginStart="10dp"
|
||||
android:gravity="start"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/room_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
@ -96,7 +96,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="137dp"
|
||||
android:layout_width="34dp"
|
||||
android:layout_height="34dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginStart="12dp"
|
||||
@ -106,10 +106,8 @@
|
||||
android:id="@+id/game_review_input"
|
||||
android:layout_width="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:text="@string/game_review_input"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@ -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 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/player_we_are_2"
|
||||
android:layout_width="70dp"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="3dp"
|
||||
android:layout_marginBottom="3dp"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:text="@string/interactive_game_player_we_are_2"
|
||||
android:textColor="#000"
|
||||
android:textColor="#B3000000"
|
||||
android:textSize="12sp" />
|
||||
|
||||
<LinearLayout
|
||||
@ -162,6 +162,7 @@
|
||||
android:layout_width="68dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="2dp"
|
||||
android:background="@drawable/bg_home_sud_list_sill"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="70dp"
|
||||
android:layout_height="110dp"
|
||||
android:layout_height="70dp"
|
||||
android:background="@mipmap/backgroud_sud_game_small_window"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/layout"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center_vertical"
|
||||
@ -39,5 +39,14 @@
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
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>
|
||||
</LinearLayout>
|
BIN
common/src/main/res/mipmap-xxhdpi/icon_game_review_input.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/icon_game_review_input.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.5 KiB |
BIN
common/src/main/res/mipmap-xxhdpi/icon_game_status.png
Normal file
BIN
common/src/main/res/mipmap-xxhdpi/icon_game_status.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
@ -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",
|
||||
|
||||
//百度语音识别
|
||||
|
||||
|
@ -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<HttpCallbackModel>() {
|
||||
@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<HttpCallbackModel>() {
|
||||
@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<HttpCallbackModel>() {
|
||||
@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<HttpCallbackModel>() {
|
||||
@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");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -191,6 +191,7 @@
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.yunbao.common.custom.CommonRefreshView
|
||||
android:layout_marginTop="5dp"
|
||||
android:id="@+id/refreshView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
|
Loading…
Reference in New Issue
Block a user