add[声望升级-游戏房判断声网或者融云]
This commit is contained in:
@@ -85,7 +85,10 @@
|
||||
android:name=".activity.WebViewActivityMedal"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.SudGameActivity"
|
||||
android:name=".activity.SudSwGameActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.SudRyGameActivity"
|
||||
android:screenOrientation="portrait" />
|
||||
<activity
|
||||
android:name=".activity.MedalQuestionWebViewActivity"
|
||||
|
||||
@@ -1798,7 +1798,6 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
|
||||
}else{
|
||||
fragment.show(((LiveRyAnchorActivity) mContext).getSupportFragmentManager(), "LiveMicAnchorDialogFragment");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,698 @@
|
||||
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.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.lifecycle.Observer;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
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.RoomMicStatusModel;
|
||||
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.SubGameEvent;
|
||||
import com.yunbao.common.event.SudGameSocketImEvent;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.imrongcloud.GameRyMicManager;
|
||||
import com.yunbao.common.sud.QuickStartGameViewModel;
|
||||
import com.yunbao.common.sud.model.GameConfigModel;
|
||||
import com.yunbao.common.sud.model.GameViewInfoModel;
|
||||
import com.yunbao.common.sud.state.SudMGPAPPState;
|
||||
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.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import cn.rongcloud.rtc.api.RCRTCEngine;
|
||||
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_SudRyGameActivity)
|
||||
public class SudRyGameActivity extends AbsActivity implements GameRyMicManager.MeetingCallback {
|
||||
private FrameLayout gameContainer;
|
||||
private long mInteractionID;
|
||||
private String mLiveUid;
|
||||
private final QuickStartGameViewModel gameViewModel = new QuickStartGameViewModel(); // 创建ViewModel
|
||||
|
||||
private CreateSudRoomModel mCreateSudRoomModel;
|
||||
private TextView roomName, roomNumber;
|
||||
private GameRyMicManager gameMicManager;
|
||||
private ImageView gameCloseWheat, gameSeat;
|
||||
private boolean disable = true, publishDefault = false;
|
||||
|
||||
private RecyclerView chatList, userList;
|
||||
private SudGameChatAdapter mLiveChatAdapter;
|
||||
private SudGameUserListAdapter sudGameUserListAdapter;
|
||||
private ProcessResultUtil mProcessResultUtil;
|
||||
private List<String> muteUser = new ArrayList<>();
|
||||
private boolean imOff;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.activity_sud_game;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void main() {
|
||||
Bus.getOn(this);
|
||||
super.main();
|
||||
initView();
|
||||
initDate();
|
||||
}
|
||||
|
||||
private List<CustomSidebarChildModel> customSidebarChildModels = new ArrayList<>();
|
||||
|
||||
private void initDate() {
|
||||
|
||||
LiveNetManager.get(mContext)
|
||||
.getCustomSidebarInfo("1", new HttpCallback<List<CustomSidebarInfoModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<CustomSidebarInfoModel> data) {
|
||||
for (CustomSidebarInfoModel datum : data) {
|
||||
if (datum.getType().equals("6")) {
|
||||
customSidebarChildModels = datum.getChild();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// 设置禁用麦克风采集
|
||||
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
|
||||
ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
|
||||
gameCloseWheat.setVisibility(View.INVISIBLE);
|
||||
|
||||
|
||||
mProcessResultUtil = new ProcessResultUtil(this);
|
||||
LiveNetManager.get(mContext)
|
||||
.getRoomMicStatus(new HttpCallback<RoomMicStatusModel>() {
|
||||
@Override
|
||||
public void onSuccess(RoomMicStatusModel data) {
|
||||
gameMicManager = new GameRyMicManager();
|
||||
gameMicManager.attachView(SudRyGameActivity.this);
|
||||
gameMicManager.config(SudRyGameActivity.this);
|
||||
//语音
|
||||
if (TextUtils.equals(data.getMicStatus(), "1")) {
|
||||
imOff = true;
|
||||
gameSeat.setVisibility(View.VISIBLE);
|
||||
userList.setVisibility(View.VISIBLE);
|
||||
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);
|
||||
} else {
|
||||
imOff = false;
|
||||
gameSeat.setVisibility(View.GONE);
|
||||
userList.setVisibility(View.GONE);
|
||||
}
|
||||
if (TextUtils.equals(data.getImStatus(), "1")) {
|
||||
findViewById(R.id.game_review_input).setVisibility(View.VISIBLE);
|
||||
chatList.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
findViewById(R.id.game_review_input).setVisibility(View.GONE);
|
||||
chatList.setVisibility(View.GONE);
|
||||
}
|
||||
gameMicManager.joinRoom(mLiveUid, imOff);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
imOff = false;
|
||||
//文字
|
||||
findViewById(R.id.game_review_input).setVisibility(View.GONE);
|
||||
chatList.setVisibility(View.GONE);
|
||||
//语音
|
||||
gameCloseWheat.setVisibility(View.GONE);
|
||||
gameSeat.setVisibility(View.GONE);
|
||||
userList.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
|
||||
LiveNetManager.get(mContext)
|
||||
.leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
if (gameMicManager != null) {
|
||||
gameMicManager.leaveRoom();
|
||||
gameMicManager.detachView();
|
||||
}
|
||||
Bus.getOff(this);
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
|
||||
String createSudRoomJson = getIntent().getStringExtra("CreateSudRoom");
|
||||
mCreateSudRoomModel = new Gson().fromJson(createSudRoomJson, CreateSudRoomModel.class);
|
||||
mInteractionID = mCreateSudRoomModel.getLongSudGameId();
|
||||
mLiveUid = mCreateSudRoomModel.getSudGameRoomId();
|
||||
|
||||
gameContainer = findViewById(R.id.game_container);
|
||||
roomName = findViewById(R.id.room_name);
|
||||
roomNumber = findViewById(R.id.room_number);
|
||||
gameCloseWheat = findViewById(R.id.game_close_wheat);
|
||||
gameSeat = findViewById(R.id.game_seat);
|
||||
chatList = findViewById(R.id.chat_list);
|
||||
userList = findViewById(R.id.user_list);
|
||||
//聊天栏
|
||||
FrameLayout.LayoutParams params1 = (FrameLayout.LayoutParams)
|
||||
chatList.getLayoutParams();
|
||||
params1.topMargin = DpUtil.dp2px(65);
|
||||
chatList.setLayoutParams(params1);
|
||||
|
||||
chatList.setHasFixedSize(true);
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(mContext);
|
||||
layoutManager.setOrientation(RecyclerView.VERTICAL);
|
||||
layoutManager.setStackFromEnd(true);
|
||||
chatList.setLayoutManager(layoutManager);
|
||||
chatList.addItemDecoration(new TopGradual());
|
||||
chatList.setItemViewCacheSize(10);
|
||||
mLiveChatAdapter = new SudGameChatAdapter(mContext);
|
||||
chatList.setAdapter(mLiveChatAdapter);
|
||||
sudGameUserListAdapter = new SudGameUserListAdapter(new ArrayList<>());
|
||||
ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_seat : R.mipmap.icon_game_seat_en, gameSeat);
|
||||
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");
|
||||
}
|
||||
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 {
|
||||
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(((SudRyGameActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
|
||||
}
|
||||
});
|
||||
userList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
|
||||
userList.setAdapter(sudGameUserListAdapter);
|
||||
if (mCreateSudRoomModel != null) {
|
||||
roomName.setText(mCreateSudRoomModel.getRoomName());
|
||||
roomNumber.setText(mCreateSudRoomModel.getSudGameRoomId());
|
||||
}
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.exit), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
gameViewModel.onDestroy();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.sud_history), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
|
||||
new XPopup.Builder(mContext)
|
||||
.enableDrag(false)
|
||||
.asCustom(new LiveSudGameHistoryPopup(mContext, customSidebarChildModels)).show();
|
||||
}
|
||||
});
|
||||
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_seat), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
if (imOff && gameMicManager != null) {
|
||||
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 {
|
||||
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 (imOff && gameMicManager != null) {
|
||||
|
||||
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 off");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.game_review_input), new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
@Override
|
||||
public void onViewClicks() {
|
||||
new XPopup.Builder(mContext)
|
||||
.enableDrag(false)
|
||||
.asCustom(new SudGameInputPopupWindow(mContext, new SudGameInputPopupWindow.SudGameInputCallBack() {
|
||||
@Override
|
||||
public void sendMessage(String textMessage) {
|
||||
gameMicManager.sendMessage(textMessage);
|
||||
}
|
||||
}))
|
||||
.show();
|
||||
}
|
||||
});
|
||||
|
||||
gameViewModel.gameViewLiveData.observe(this, new Observer<View>() {
|
||||
@Override
|
||||
public void onChanged(View view) {
|
||||
if (view == null) { // 在关闭游戏时,把游戏View给移除
|
||||
gameContainer.removeAllViews();
|
||||
} else { // 把游戏View添加到容器内
|
||||
gameContainer.addView(view, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
// 加载游戏,参数定义可查看BaseGameViewModel.switchGame()方法注释
|
||||
// 游戏配置
|
||||
GameConfigModel gameConfigModel = gameViewModel.getGameConfigModel();
|
||||
gameConfigModel.ui.ping.hide = true; // 配置不隐藏ping值
|
||||
gameConfigModel.ui.level.hide = true; // 配置不隐藏ping值
|
||||
gameConfigModel.ui.lobby_game_setting.hide = true; // 配置不隐藏ping值
|
||||
|
||||
gameConfigModel.ui.lobby_players.custom = true;
|
||||
gameConfigModel.ui.join_btn.custom = true;
|
||||
gameConfigModel.ui.game_settle_again_btn.custom = true;
|
||||
gameConfigModel.ui.start_btn.custom = true;
|
||||
|
||||
|
||||
// SudMGP平台64bit游戏ID
|
||||
gameViewModel.switchGame((Activity) mContext, mLiveUid, mInteractionID);
|
||||
// gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, -1, true, 1);
|
||||
// gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfCaptain(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
|
||||
// ViewClicksAntiShake.clicksAntiShake(gameTitle, new ViewClicksAntiShake.ViewClicksCallBack() {
|
||||
// @Override
|
||||
// public void onViewClicks() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// 设置游戏安全操作区域
|
||||
GameViewInfoModel.GameViewRectModel gameViewRectModel = new GameViewInfoModel.GameViewRectModel();
|
||||
gameViewRectModel.left = 0;
|
||||
gameViewRectModel.top = DpUtil.dp2px(155);
|
||||
gameViewRectModel.right = 0;
|
||||
gameViewRectModel.bottom = DpUtil.dp2px(155);
|
||||
gameViewModel.gameViewRectModel = gameViewRectModel;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onCheckRemainingBalanceEvent(CheckRemainingBalanceEvent event) {
|
||||
switch (event.getSudMGPMGState()) {
|
||||
case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN:
|
||||
case SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN:
|
||||
|
||||
LiveNetManager.get(mContext).checkRemainingBalance(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback<CheckRemainingBalance>() {
|
||||
@Override
|
||||
public void onSuccess(CheckRemainingBalance data) {
|
||||
if (TextUtils.equals(String.valueOf(data.getGoldenBeanRemainingBalance()), "1")) {
|
||||
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, event.getSeatIndex(), true, 1);
|
||||
} else {
|
||||
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
|
||||
ToastUtil.show("貨幣数量不足 ");
|
||||
} else {
|
||||
ToastUtil.show("Insufficient number of currency");
|
||||
}
|
||||
|
||||
}
|
||||
// ToastUtil.show(data.toString());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
if (IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
|
||||
ToastUtil.show("貨幣数量不足 ");
|
||||
} else {
|
||||
ToastUtil.show("Insufficient number of currency");
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
break;
|
||||
case SudMGPMGState.MG_COMMON_GAME_SETTLE:
|
||||
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(false, event.getSeatIndex(), true, 1);
|
||||
break;
|
||||
case SudMGPMGState.MG_COMMON_SELF_CLICK_START_BTN:
|
||||
LiveNetManager.get(mContext).gameStartCheckRemainingBalance(mCreateSudRoomModel.getSudGameId(),
|
||||
mCreateSudRoomModel.getSudGameRoomId(), new
|
||||
HttpCallback<CheckRemainingBalance>() {
|
||||
@Override
|
||||
public void onSuccess(CheckRemainingBalance data) {
|
||||
if (data.getStatus() == 1) {
|
||||
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfPlaying(true);
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case SudMGPMGState.MG_COMMON_GAME_STATE:
|
||||
LiveNetManager.get(mContext).deductMoney(mCreateSudRoomModel.getSudGameRoomId());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoinRoomSuccess(RCRTCRoom rcrtcRoom) {
|
||||
LiveNetManager.get(mContext).getRoomMicData(mLiveUid, new HttpCallback<List<SudGameUserModel>>() {
|
||||
@Override
|
||||
public void onSuccess(List<SudGameUserModel> data) {
|
||||
|
||||
gameMicManager.refreshStreams(data);
|
||||
sudGameUserListAdapter.refreshSudGameUserList(data, muteUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
}
|
||||
});
|
||||
// 主动订阅远端用户发布的资源
|
||||
// gameMicManager.subscribeAVStream();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onJoinRoomFailed(RTCErrorCode rtcErrorCode) {
|
||||
ToastUtil.show("加入失败 " + rtcErrorCode.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPublishSuccess() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_hang_up : R.mipmap.icon_game_hang_up_en, gameSeat);
|
||||
publishDefault = true;
|
||||
gameCloseWheat.setVisibility(View.VISIBLE);
|
||||
disable = false;
|
||||
// 设置禁用麦克风采集
|
||||
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
|
||||
ImgLoader.display(mContext, R.mipmap.icon_game_open_wheat, gameCloseWheat);
|
||||
}
|
||||
});
|
||||
|
||||
LiveNetManager.get(mContext)
|
||||
.joinMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPublishFailed() {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "語音加入失敗" : "Voice joining failed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribeSuccess(List<RCRTCInputStream> inputStreamList) {
|
||||
// ToastUtil.show("订阅成功 ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribeFailed() {
|
||||
ToastUtil.show("订阅失败 ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribeSuccess(String userID, boolean mute, int position) {
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribeFailed(String userID) {
|
||||
ToastUtil.show("订阅失败 ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserJoined(RCRTCRemoteUser rcrtcRemoteUser) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUserLeft(RCRTCRemoteUser rcrtcRemoteUser) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertItem(SudGameChatImModel sudGameChatImModel) {
|
||||
mLiveChatAdapter.insertItem(sudGameChatImModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshSudGameUserList(List<SudGameUserModel> personList) {
|
||||
sudGameUserListAdapter.refreshSudGameUserList(personList, muteUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnPublishStreamsSuccess() {
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ImgLoader.display(mContext, WordUtil.isNewZh() ? R.mipmap.icon_game_seat : R.mipmap.icon_game_seat_en, gameSeat);
|
||||
publishDefault = false;
|
||||
gameCloseWheat.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
});
|
||||
LiveNetManager.get(mContext)
|
||||
.leaveMic(mLiveUid, new HttpCallback<HttpCallbackModel>() {
|
||||
@Override
|
||||
public void onSuccess(HttpCallbackModel data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnPublishStreamsFailed() {
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onSudGameStatus(SubGameEvent event) {
|
||||
if (event.getType() == 0) {
|
||||
Log.i("游戏回调", "onGameStateChange: event :" + event.toString());
|
||||
if (event.getModel().getCode() == 1001 || event.getModel().getCode() == 1002) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("result", 0);
|
||||
gameViewModel.sudFSTAPPDecorator.notifyStateChange(SudMGPAPPState.APP_COMMON_GAME_CREATE_ORDER_RESULT, jsonObject.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -39,7 +39,7 @@ import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.imrongcloud.GameMicManager;
|
||||
import com.yunbao.common.manager.imrongcloud.GameSwMicManager;
|
||||
import com.yunbao.common.sud.QuickStartGameViewModel;
|
||||
import com.yunbao.common.sud.model.GameConfigModel;
|
||||
import com.yunbao.common.sud.model.GameViewInfoModel;
|
||||
@@ -72,8 +72,8 @@ import io.rong.imlib.IRongCoreCallback;
|
||||
import io.rong.imlib.IRongCoreEnum;
|
||||
import io.rong.imlib.chatroom.base.RongChatRoomClient;
|
||||
|
||||
@Route(path = RouteUtil.PATH_SudGameActivity)
|
||||
public class SudGameActivity extends AbsActivity implements GameMicManager.MeetingCallback {
|
||||
@Route(path = RouteUtil.PATH_SudSwGameActivity)
|
||||
public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.MeetingCallback {
|
||||
private FrameLayout gameContainer;
|
||||
private long mInteractionID;
|
||||
private String mLiveUid;
|
||||
@@ -81,7 +81,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
|
||||
|
||||
private CreateSudRoomModel mCreateSudRoomModel;
|
||||
private TextView roomName, roomNumber;
|
||||
private GameMicManager gameMicManager;
|
||||
private GameSwMicManager gameMicManager;
|
||||
private ImageView gameCloseWheat, gameSeat;
|
||||
private boolean disable = true, publishDefault = false;
|
||||
|
||||
@@ -91,7 +91,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
|
||||
private ProcessResultUtil mProcessResultUtil;
|
||||
private List<String> muteUser = new ArrayList<>();
|
||||
private boolean imOff;
|
||||
private boolean isSw = true;
|
||||
private boolean isSw = CommonAppConfig.getInstance().getConfig().isSw();
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
@@ -136,9 +136,9 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
|
||||
LiveNetManager.get(mContext).getRoomMicStatus(new HttpCallback<RoomMicStatusModel>() {
|
||||
@Override
|
||||
public void onSuccess(RoomMicStatusModel data) {
|
||||
gameMicManager = new GameMicManager();
|
||||
gameMicManager.attachView(SudGameActivity.this);
|
||||
gameMicManager.config(SudGameActivity.this);
|
||||
gameMicManager = new GameSwMicManager();
|
||||
gameMicManager.attachView(SudSwGameActivity.this);
|
||||
gameMicManager.config(SudSwGameActivity.this);
|
||||
//初始化声网引擎
|
||||
SWAuManager.get().initRtcEngineAudio(mContext);
|
||||
//语音
|
||||
@@ -316,7 +316,7 @@ public class SudGameActivity extends AbsActivity implements GameMicManager.Meeti
|
||||
bundle.putString(Constants.STREAM, "");
|
||||
bundle.putString(Constants.TO_UID, sudGameUserModel.getId() + "");
|
||||
fragment.setArguments(bundle);
|
||||
fragment.show(((SudGameActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
|
||||
fragment.show(((SudSwGameActivity) mContext).getSupportFragmentManager(), "LiveUserDialogFragment");
|
||||
}
|
||||
});
|
||||
userList.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
|
||||
@@ -231,14 +231,12 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
|
||||
goHomeUser.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mContext instanceof LiveAnchorActivity) {
|
||||
((LiveAnchorActivity) mContext).superBackPressed();
|
||||
if (mContext instanceof LiveRyAnchorActivity) {
|
||||
((LiveRyAnchorActivity) mContext).superBackPressed();
|
||||
} else if (mContext instanceof LiveAudienceActivity) {
|
||||
((LiveAudienceActivity) mContext).exitLiveRoom();
|
||||
} else if (mContext instanceof LiveSwAnchorActivity) {
|
||||
((LiveSwAnchorActivity) mContext).superBackPressed();
|
||||
}else if(mContext instanceof LiveRyAnchorActivity){
|
||||
((LiveRyAnchorActivity) mContext).superBackPressed();
|
||||
}
|
||||
Bus.get().post(new CloseEvent());
|
||||
}
|
||||
@@ -264,8 +262,8 @@ public class LiveEndViewHolder extends AbsViewHolder implements View.OnClickList
|
||||
.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (mContext instanceof LiveAnchorActivity) {
|
||||
((LiveAnchorActivity) mContext).superBackPressed();
|
||||
if (mContext instanceof LiveRyAnchorActivity) {
|
||||
((LiveRyAnchorActivity) mContext).superBackPressed();
|
||||
} else if (mContext instanceof LiveAudienceActivity) {
|
||||
((LiveAudienceActivity) mContext).exitLiveRoom();
|
||||
} else if (mContext instanceof LiveSwAnchorActivity) {
|
||||
|
||||
@@ -3685,32 +3685,34 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
|
||||
if (isStayRoomfive) {
|
||||
showFollowDialog(mNameText, mAvatarUrl, mContext);
|
||||
} else {
|
||||
|
||||
if(mContext instanceof LiveSwAnchorActivity){
|
||||
LiveSwAnchorActivity.backIndex = 1;
|
||||
((LiveSwAnchorActivity) mContext).onBackPressed();
|
||||
}else{
|
||||
LiveRyAnchorActivity.backIndex = 1;
|
||||
((LiveRyAnchorActivity) mContext).onBackPressed();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(mContext instanceof LiveSwAnchorActivity){
|
||||
LiveSwAnchorActivity.backIndex = 1;
|
||||
((LiveSwAnchorActivity) mContext).onBackPressed();
|
||||
}else{
|
||||
}
|
||||
} else {
|
||||
LiveSwAnchorActivity.backIndex = 1;
|
||||
((LiveSwAnchorActivity) mContext).onBackPressed();
|
||||
}
|
||||
} else {
|
||||
LiveSwAnchorActivity.backIndex = 1;
|
||||
((LiveSwAnchorActivity) mContext).onBackPressed();
|
||||
}
|
||||
}else if(mContext instanceof LiveRyAnchorActivity){
|
||||
if (forAct == 1) {
|
||||
//是否关注0==没关注
|
||||
if (isAttention == 0) {
|
||||
if (isStayRoomfive) {
|
||||
showFollowDialog(mNameText, mAvatarUrl, mContext);
|
||||
} else {
|
||||
LiveRyAnchorActivity.backIndex = 1;
|
||||
((LiveRyAnchorActivity) mContext).onBackPressed();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if(mContext instanceof LiveSwAnchorActivity){
|
||||
LiveSwAnchorActivity.backIndex = 1;
|
||||
((LiveSwAnchorActivity) mContext).onBackPressed();
|
||||
}else{
|
||||
} else {
|
||||
LiveRyAnchorActivity.backIndex = 1;
|
||||
((LiveRyAnchorActivity) mContext).onBackPressed();
|
||||
}
|
||||
} else {
|
||||
LiveRyAnchorActivity.backIndex = 1;
|
||||
((LiveRyAnchorActivity) mContext).onBackPressed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.yunbao.live.views;
|
||||
|
||||
import static com.yunbao.live.activity.LiveActivity.isSw;
|
||||
import static com.yunbao.live.activity.LiveActivity.mLiveUid;
|
||||
import static com.yunbao.live.activity.LiveSwAnchorActivity.PKing;
|
||||
import static com.yunbao.live.activity.LiveSwAnchorActivity.pk_nub;
|
||||
@@ -174,7 +175,11 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
|
||||
|
||||
if (yaoqing.size() < 3) {
|
||||
if (PKing == false) {
|
||||
((LiveRyAnchorActivity) mContext).openLinkMicAnchorWindow(true);
|
||||
if(isSw){
|
||||
((LiveSwAnchorActivity) mContext).openLinkMicAnchorWindow(true);
|
||||
}else{
|
||||
((LiveRyAnchorActivity) mContext).openLinkMicAnchorWindow(true);
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show(WordUtil.isNewZh() ? "您已在PK中" : "You are already in the PK");
|
||||
}
|
||||
@@ -242,7 +247,11 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
|
||||
* 关闭直播
|
||||
*/
|
||||
private void close() {
|
||||
((LiveRyAnchorActivity) mContext).closeLive();
|
||||
if(isSw){
|
||||
((LiveSwAnchorActivity) mContext).closeLive();
|
||||
}else{
|
||||
((LiveRyAnchorActivity) mContext).closeLive();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -258,7 +267,11 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
|
||||
if (mBtnFunction != null) {
|
||||
mBtnFunction.setImageDrawable(mDrawable1);
|
||||
}
|
||||
((LiveRyAnchorActivity) mContext).showFunctionDialog();
|
||||
if(isSw){
|
||||
((LiveSwAnchorActivity) mContext).showFunctionDialog();
|
||||
}else{
|
||||
((LiveRyAnchorActivity) mContext).showFunctionDialog();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,7 +304,11 @@ public class LiveRyAnchorViewHolder extends AbsLiveViewHolder {
|
||||
* 发起主播连麦pk
|
||||
*/
|
||||
private void applyLinkMicPk() {
|
||||
((LiveRyAnchorActivity) mContext).applyLinkMicPk();
|
||||
if(isSw){
|
||||
((LiveSwAnchorActivity) mContext).applyLinkMicPk();
|
||||
}else{
|
||||
((LiveRyAnchorActivity) mContext).applyLinkMicPk();
|
||||
}
|
||||
}
|
||||
|
||||
public void setLinkMicEnable(boolean linkMicEnable) {
|
||||
|
||||
Reference in New Issue
Block a user