feat:完成房间-游戏切换入口调整需求
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package com.chwl.app.avroom.adapter
|
||||
|
||||
import android.widget.ImageView
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.ui.utils.load
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
import com.chwl.core.room.game.bean.GameInfo
|
||||
|
||||
class RoomGameListAdapter :
|
||||
BaseQuickAdapter<GameInfo, BaseViewHolder>(R.layout.room_gameplay_item2) {
|
||||
override fun convert(helper: BaseViewHolder, item: GameInfo?) {
|
||||
helper.setText(R.id.tv_name, item?.name)
|
||||
val iconView = helper.getView<ImageView>(R.id.iv_icon)
|
||||
iconView.load(item?.pic)
|
||||
}
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
package com.chwl.app.avroom.adapter
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.chad.library.adapter.base.BaseViewHolder
|
||||
import com.chwl.app.R
|
||||
import com.chwl.core.room.game.bean.GameInfo
|
||||
|
||||
class SelectGameAdapter :
|
||||
BaseQuickAdapter<GameInfo, BaseViewHolder>(R.layout.item_room_select_game) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: GameInfo) {
|
||||
helper.setText(R.id.tv_name,item.name)
|
||||
}
|
||||
|
||||
}
|
@@ -44,7 +44,7 @@ class CreateGameRoomDialog : BaseDialog<DialogCreateGameRoomBinding>() {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
GameModel.getGameList()
|
||||
GameModel.getGameList(null)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(
|
||||
{
|
||||
|
@@ -88,7 +88,7 @@ class CreateRoomDialog : BaseDialog<DialogCreateRoomBinding>() {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
|
||||
GameModel.getGameList()
|
||||
GameModel.getGameList(null)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(
|
||||
{
|
||||
|
@@ -0,0 +1,223 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.LifecycleObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.RoomGameListAdapter
|
||||
import com.chwl.app.base.BaseActivity
|
||||
import com.chwl.app.common.widget.dialog.DialogManager
|
||||
import com.chwl.app.databinding.RoomGameplayDialogBinding
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.room.bean.RoomModeType
|
||||
import com.chwl.core.room.core.RoomDataService
|
||||
import com.chwl.core.room.game.GameModel.getGameList
|
||||
import com.chwl.core.room.game.bean.GameInfo
|
||||
import com.chwl.core.support.room.AudioRoomContext
|
||||
import com.chwl.library.utils.JavaUtil
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.example.lib_utils.ktx.asLifecycle
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.unity3d.splash.services.core.lifecycle.LifecycleEvent
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
|
||||
class RoomGameListDialog :
|
||||
BottomSheetDialogFragment(), LifecycleObserver {
|
||||
private var binding: RoomGameplayDialogBinding? = null
|
||||
private var compositeDisposable: CompositeDisposable? = null
|
||||
private val adapter = RoomGameListAdapter()
|
||||
private var dialogManager: DialogManager? = null
|
||||
|
||||
override fun getTheme(): Int {
|
||||
return R.style.ErbanBottomSheetDialogDimFalse
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View? {
|
||||
binding = RoomGameplayDialogBinding.inflate(LayoutInflater.from(context))
|
||||
return binding?.root
|
||||
}
|
||||
|
||||
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
|
||||
return super.onCreateDialog(savedInstanceState).apply {
|
||||
this.setCanceledOnTouchOutside(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
initView()
|
||||
switchStatus(0)
|
||||
requestData()
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
val lifecycleObserver = object : LifecycleEventObserver {
|
||||
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
||||
if (event == Lifecycle.Event.ON_DESTROY) {
|
||||
context.asLifecycle()?.removeObserver(this)
|
||||
try {
|
||||
this@RoomGameListDialog.dismissAllowingStateLoss()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
context.asLifecycle()?.addObserver(lifecycleObserver)
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
adapter.setOnItemClickListener { _, view, position ->
|
||||
val item = adapter.getItem(position) as GameInfo
|
||||
switchGame(item)
|
||||
}
|
||||
binding?.recyclerView?.adapter = adapter
|
||||
}
|
||||
|
||||
private fun requestData() {
|
||||
val dataService =
|
||||
AudioRoomContext.get()
|
||||
?.findAbility<RoomDataService>(RoomDataService::class.java.simpleName)
|
||||
val cacheKey = "game_list#${parentFragment.hashCode()}"
|
||||
val list = dataService?.getData(cacheKey) as? List<GameInfo>
|
||||
if (!list.isNullOrEmpty()) {
|
||||
loadData(list)
|
||||
return
|
||||
}
|
||||
val disposable = getGameList(AvRoomDataManager.get().roomUid)
|
||||
.doOnError {
|
||||
SingleToastUtil.showToast(it.message)
|
||||
switchStatus(-2)
|
||||
}
|
||||
.subscribe { it: List<GameInfo> ->
|
||||
dataService?.putData(cacheKey, it)
|
||||
loadData(it)
|
||||
}
|
||||
getCompositeDisposable().add(disposable)
|
||||
}
|
||||
|
||||
private fun loadData(list: List<GameInfo>?) {
|
||||
if (list.isNullOrEmpty()) {
|
||||
switchStatus(-1)
|
||||
} else {
|
||||
adapter.setNewData(list)
|
||||
switchStatus(1)
|
||||
}
|
||||
}
|
||||
|
||||
private fun switchStatus(status: Int) {
|
||||
when (status) {
|
||||
// loading
|
||||
0 -> {
|
||||
binding?.recyclerView?.isVisible = false
|
||||
binding?.layoutStatus?.isVisible = true
|
||||
binding?.groupStatusLoading?.isVisible = true
|
||||
binding?.groupStatusText?.isVisible = false
|
||||
}
|
||||
|
||||
// 有数据
|
||||
1 -> {
|
||||
binding?.recyclerView?.isVisible = true
|
||||
binding?.layoutStatus?.isVisible = false
|
||||
}
|
||||
|
||||
// 空数据
|
||||
-1 -> {
|
||||
binding?.recyclerView?.isVisible = false
|
||||
binding?.layoutStatus?.isVisible = true
|
||||
binding?.groupStatusLoading?.isVisible = false
|
||||
binding?.groupStatusText?.isVisible = true
|
||||
binding?.tvStatus?.setText(R.string.avroom_presenter_roomnewbiehellowwordpresenter_01)
|
||||
}
|
||||
|
||||
// 失败
|
||||
else -> {
|
||||
binding?.recyclerView?.isVisible = false
|
||||
binding?.layoutStatus?.isVisible = true
|
||||
binding?.groupStatusLoading?.isVisible = false
|
||||
binding?.groupStatusText?.isVisible = true
|
||||
binding?.tvStatus?.setText(R.string.request_failed_again_later)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun switchGame(gameInfo: GameInfo) {
|
||||
if (AvRoomDataManager.get().isGamePlaying) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.room_switch_game_failed_in_game))
|
||||
return
|
||||
}
|
||||
if (!isShowChangeGame()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_04))
|
||||
return
|
||||
}
|
||||
|
||||
if (dialogManager == null) {
|
||||
dialogManager = DialogManager(context)
|
||||
}
|
||||
dialogManager?.showOkCancelDialog(
|
||||
getString(R.string.room_switch_game_tips)
|
||||
) {
|
||||
if (gameInfo.isStandardRoom()) {
|
||||
OpenRoomHelper.updateRoomInfo(
|
||||
activity as BaseActivity,
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
RoomInfo.ROOMTYPE_HOME_PARTY,
|
||||
0,
|
||||
false
|
||||
)
|
||||
} else {
|
||||
OpenRoomHelper.updateRoomInfo(
|
||||
activity as BaseActivity,
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
RoomInfo.ROOMTYPE_GAME,
|
||||
JavaUtil.str2long(gameInfo.mgId),
|
||||
false
|
||||
)
|
||||
}
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
onUnbindContext()
|
||||
dialogManager?.dismissDialog()
|
||||
dialogManager = null
|
||||
}
|
||||
|
||||
private fun getCompositeDisposable(): CompositeDisposable {
|
||||
var disposable = compositeDisposable
|
||||
if (disposable == null) {
|
||||
disposable = CompositeDisposable()
|
||||
compositeDisposable = disposable
|
||||
}
|
||||
return disposable
|
||||
}
|
||||
|
||||
private fun onUnbindContext() {
|
||||
compositeDisposable?.dispose()
|
||||
compositeDisposable = null
|
||||
}
|
||||
|
||||
//这里的2和4是服务端定义的错误状态 关闭排麦模式和关闭PK模式!
|
||||
private fun isShowChangeGame(): Boolean {
|
||||
val currentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo
|
||||
return currentRoomInfo != null && currentRoomInfo.type != RoomInfo.ROOM_TYPE_SINGLE &&
|
||||
(currentRoomInfo.roomModeType == RoomModeType.NORMAL_MODE || currentRoomInfo.roomModeType == 2 || currentRoomInfo.roomModeType == 4)
|
||||
}
|
||||
}
|
@@ -1,17 +1,20 @@
|
||||
package com.chwl.app.avroom.dialog
|
||||
|
||||
import android.app.Dialog
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.chwl.app.R
|
||||
import com.chwl.app.avroom.adapter.RoomGameplayAdapter
|
||||
import com.chwl.app.databinding.RoomGameplayDialogBinding
|
||||
import com.chwl.app.treasure_box.widget.GoldBoxHelper
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity
|
||||
import com.chwl.app.ui.webview.baishun.BaiShunGameWebActivity
|
||||
import com.chwl.app.ui.webview.room_banner.RoomWebDialogActivity
|
||||
import com.chwl.app.utils.CommonJumpHelper
|
||||
import com.chwl.core.room.bean.RoomIcon
|
||||
@@ -19,8 +22,8 @@ import com.chwl.core.room.core.RoomDataService
|
||||
import com.chwl.core.room.game.bean.BaiShunGameConfig
|
||||
import com.chwl.core.room.model.AvRoomModel
|
||||
import com.chwl.core.support.room.AudioRoomContext
|
||||
import com.chwl.core.support.room.RoomContext
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.example.lib_utils.ktx.asLifecycle
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.google.gson.Gson
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
@@ -67,6 +70,22 @@ class RoomGameplayDialog :
|
||||
binding?.recyclerView?.adapter = adapter
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
super.onAttach(context)
|
||||
val lifecycleObserver = object : LifecycleEventObserver {
|
||||
override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) {
|
||||
if (event == Lifecycle.Event.ON_DESTROY) {
|
||||
context.asLifecycle()?.removeObserver(this)
|
||||
try {
|
||||
this@RoomGameplayDialog.dismissAllowingStateLoss()
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
context.asLifecycle()?.addObserver(lifecycleObserver)
|
||||
}
|
||||
|
||||
private fun requestData() {
|
||||
val dataService =
|
||||
AudioRoomContext.get()?.findAbility<RoomDataService>(RoomDataService::class.java.simpleName)
|
||||
|
@@ -44,6 +44,7 @@ import com.chwl.app.avroom.adapter.OnMicroItemClickListener
|
||||
import com.chwl.app.avroom.adapter.RoomMessageIndicatorAdapter
|
||||
import com.chwl.app.avroom.dialog.AttentionHintDialog
|
||||
import com.chwl.app.avroom.dialog.DatingVipRuleDialog
|
||||
import com.chwl.app.avroom.dialog.RoomGameListDialog
|
||||
import com.chwl.app.avroom.dialog.RoomGameplayDialog
|
||||
import com.chwl.app.avroom.dialog.RoomOperationDialog
|
||||
import com.chwl.app.avroom.presenter.BaseRoomPresenter
|
||||
@@ -790,6 +791,9 @@ open class BaseRoomFragment<V : IBaseRoomView?, P1 : BaseRoomPresenter<V>?> :
|
||||
override fun onClick(v: View) {
|
||||
if (mClickLimit.checkForTime(500)) return
|
||||
when (v.id) {
|
||||
R.id.iv_game -> {
|
||||
RoomGameListDialog().show(childFragmentManager, "GAME_LIST")
|
||||
}
|
||||
R.id.input_send -> {
|
||||
sendMsg()
|
||||
}
|
||||
|
@@ -19,11 +19,15 @@ import com.chwl.app.avroom.online.RoomOnlineWidget
|
||||
import com.chwl.app.avroom.presenter.GameRoomPresenter
|
||||
import com.chwl.app.avroom.view.IGameRoomView
|
||||
import com.chwl.app.databinding.FragmentGameRoomBinding
|
||||
import com.chwl.app.home.helper.OpenRoomHelper
|
||||
import com.chwl.app.ui.widget.GiftDialog.OnGiftDialogBtnClickListener
|
||||
import com.chwl.core.manager.AvRoomDataManager
|
||||
import com.chwl.core.music.model.PlayerModel
|
||||
import com.chwl.core.room.bean.RoomInfo
|
||||
import com.chwl.core.room.event.FinishAvRoomEvent
|
||||
import com.chwl.core.sud.model.GameViewInfoModel
|
||||
import com.chwl.library.base.factory.CreatePresenter
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
@@ -74,6 +78,7 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
@SuppressLint("CheckResult")
|
||||
override fun initiate() {
|
||||
gameBinding.microView.bindAdapter(GameMicroViewAdapter(context))
|
||||
resetGameViewRect()
|
||||
super.initiate()
|
||||
//游戏模式暂时不需要这个
|
||||
PlayerModel.get().stop()
|
||||
@@ -93,6 +98,29 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View) {
|
||||
super.onClick(v)
|
||||
when (v.id) {
|
||||
R.id.iv_back_room -> {
|
||||
if (AvRoomDataManager.get().isGamePlaying) {
|
||||
SingleToastUtil.showToast(getString(R.string.avroom_fragment_homepartyfragment_03))
|
||||
return
|
||||
}
|
||||
dialogManager.showOkCancelDialog(
|
||||
getString(R.string.room_switch_standard_room_tips)
|
||||
) {
|
||||
OpenRoomHelper.updateRoomInfo(
|
||||
baseActivity,
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
RoomInfo.ROOMTYPE_HOME_PARTY,
|
||||
0,
|
||||
false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
private fun setMessagePagerAutoHeight(recyclerView: RecyclerView){
|
||||
recyclerView.setOnTouchListener(OnTouchListener { v: View?, event: MotionEvent ->
|
||||
@@ -152,9 +180,18 @@ class GameRoomFragment : BaseRoomFragment<IGameRoomView?, GameRoomPresenter?>(),
|
||||
gameBinding.microView.adapter.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
private fun resetGameViewRect(){
|
||||
gameBinding.vGameRect.post {
|
||||
gameDelegate.gameViewRect = GameViewInfoModel.GameViewRectModel().apply {
|
||||
top = gameBinding.vGameRect.top
|
||||
bottom = gameBinding.layoutRoot.height - gameBinding.vGameRect.bottom
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onGameStart() {
|
||||
if (isSixMic()) {
|
||||
showMiniMic()
|
||||
// showMiniMic()
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -16,17 +16,10 @@ import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.chwl.app.avroom.adapter.SelectGameAdapter;
|
||||
import com.chwl.app.home.helper.OpenRoomHelper;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtilsV2;
|
||||
import com.chwl.app.ui.widget.GiftDialog;
|
||||
import com.chwl.app.ui.widget.UserInfoDialog;
|
||||
import com.chwl.core.room.bean.RoomModeType;
|
||||
import com.chwl.core.room.game.GameModel;
|
||||
import com.chwl.core.room.game.bean.GameInfo;
|
||||
import com.chwl.library.utils.JavaUtil;
|
||||
import com.example.lib_utils.UiUtils;
|
||||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||||
@@ -105,7 +98,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
|
||||
//收藏房间
|
||||
private String FOLLOW_ROOM_TYPE = "";
|
||||
private SelectGameAdapter gameAdapter;
|
||||
|
||||
public static HomePartyFragment newInstance() {
|
||||
HomePartyFragment homePartyFragment = new HomePartyFragment();
|
||||
@@ -224,73 +216,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
}
|
||||
}
|
||||
|
||||
private void initRvGame() {
|
||||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
if (roomInfo == null || gameAdapter != null) return;
|
||||
gameMainBinding.rvGame.setLayoutManager(new LinearLayoutManager(mContext));
|
||||
gameMainBinding.rvGame.setAdapter(gameAdapter = new SelectGameAdapter());
|
||||
gameMainBinding.llSelectGame.setOnClickListener(v -> {
|
||||
if (gameMainBinding.rvGame.getVisibility() == View.VISIBLE) {
|
||||
gameMainBinding.rvGame.setVisibility(View.GONE);
|
||||
gameMainBinding.ivChangeGameArrow.setImageResource(R.drawable.ic_room_arrow_type_below);
|
||||
} else {
|
||||
if (!isShowChangeGame()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_01));
|
||||
return;
|
||||
}
|
||||
if (AvRoomDataManager.get().isGamePlaying()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_02));
|
||||
} else {
|
||||
gameMainBinding.rvGame.setVisibility(View.VISIBLE);
|
||||
gameMainBinding.ivChangeGameArrow.setImageResource(R.drawable.ic_room_arrow_type);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
gameAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||
if (AvRoomDataManager.get().isGamePlaying()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_03));
|
||||
}
|
||||
if (!isShowChangeGame()) {
|
||||
SingleToastUtil.showToast(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_04));
|
||||
return;
|
||||
}
|
||||
|
||||
GameInfo gameInfo = gameAdapter.getItem(position);
|
||||
if (gameInfo != null) {
|
||||
gameMainBinding.rvGame.setVisibility(View.GONE);
|
||||
gameMainBinding.ivChangeGameArrow.setImageResource(R.drawable.ic_room_arrow_type_below);
|
||||
if (gameInfo.isStandardRoom()) {
|
||||
OpenRoomHelper.updateRoomInfo(
|
||||
getBaseActivity(),
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
RoomInfo.ROOMTYPE_HOME_PARTY,
|
||||
0,
|
||||
false);
|
||||
} else {
|
||||
OpenRoomHelper.updateRoomInfo(
|
||||
getBaseActivity(),
|
||||
AvRoomDataManager.get().mCurrentRoomInfo,
|
||||
RoomInfo.ROOMTYPE_GAME,
|
||||
JavaUtil.str2long(gameInfo.getMgId()),
|
||||
false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//这里的2和4是服务端定义的错误状态 关闭排麦模式和关闭PK模式!
|
||||
private boolean isShowChangeGame() {
|
||||
RoomInfo currentRoomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||||
return currentRoomInfo != null &&
|
||||
AvRoomDataManager.get().isRoomOwner() &&
|
||||
currentRoomInfo.getIsPermitRoom() != 1 &&
|
||||
currentRoomInfo.getType() != RoomInfo.ROOM_TYPE_SINGLE &&
|
||||
(currentRoomInfo.getRoomModeType() == RoomModeType.NORMAL_MODE ||
|
||||
currentRoomInfo.getRoomModeType() == 2 ||
|
||||
currentRoomInfo.getRoomModeType() == 4);
|
||||
}
|
||||
|
||||
public void setRoomBg(RoomInfo roomInfo) {
|
||||
if (svgaRoomBg == null) return;
|
||||
AVRoomActivity.setBackBg(mContext, roomInfo, svgaRoomBg, bgPicture);
|
||||
@@ -465,36 +390,6 @@ public class HomePartyFragment extends BaseFragment implements View.OnClickListe
|
||||
ivFollowRoom.setImageResource(AvRoomDataManager.get().isRoomFans ? R.drawable.room_ic_collect_yes : R.drawable.room_ic_collect_no);
|
||||
|
||||
setIdOnlineData();
|
||||
|
||||
if (isShowChangeGame()) {
|
||||
initRvGame();
|
||||
gameMainBinding.llChangeGame.setVisibility(View.VISIBLE);
|
||||
if (AvRoomDataManager.get().isOpenGame()) {
|
||||
gameMainBinding.tvCurrGame.setText(currentRoomInfo.getMgName());
|
||||
} else {
|
||||
gameMainBinding.tvCurrGame.setText(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_08));
|
||||
}
|
||||
GameModel.INSTANCE.getGameList()
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe(gameInfos -> {
|
||||
if (AvRoomDataManager.get().isOpenGame()) {
|
||||
for (int i = 0; i < gameInfos.size(); i++) {
|
||||
GameInfo gameInfo = gameInfos.get(i);
|
||||
if (JavaUtil.str2long(gameInfo.getMgId()) == currentRoomInfo.getMgId()) {
|
||||
gameInfos.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
GameInfo gameInfo = new GameInfo();
|
||||
gameInfo.asStandardRoom();
|
||||
gameInfo.setName(ResUtil.getString(R.string.avroom_fragment_homepartyfragment_09));
|
||||
gameInfos.add(gameInfo);
|
||||
}
|
||||
gameAdapter.setNewData(gameInfos);
|
||||
});
|
||||
} else {
|
||||
gameMainBinding.llChangeGame.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ import com.chwl.core.room.game.bean.GameCfg
|
||||
import com.chwl.core.room.game.GameModel
|
||||
import com.chwl.core.room.game.GameStatus
|
||||
import com.chwl.core.room.model.HomePartyModel
|
||||
import com.chwl.core.sud.model.GameViewInfoModel.GameViewRectModel
|
||||
import com.chwl.core.sud.state.SudMGPAPPState
|
||||
import com.chwl.core.sud.state.SudMGPMGState
|
||||
import com.chwl.core.user.UserModel
|
||||
@@ -25,6 +26,7 @@ import com.chwl.core.utils.LogUtils
|
||||
import com.chwl.core.utils.net.RxHelper
|
||||
import com.chwl.library.language.LanguageHelper
|
||||
import com.chwl.library.net.rxnet.callback.CallBack
|
||||
import com.chwl.library.utils.ResUtil
|
||||
import com.chwl.library.utils.SingleToastUtil
|
||||
import okhttp3.*
|
||||
import org.json.JSONException
|
||||
@@ -56,6 +58,8 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
|
||||
private var onGameStatusChangeListener: OnGameStatusChangeListener? = null
|
||||
|
||||
var gameViewRect: GameViewRectModel? = null
|
||||
|
||||
fun setOnGameStatusChangeListener(onGameStatusChangeListener: OnGameStatusChangeListener) {
|
||||
this.onGameStatusChangeListener = onGameStatusChangeListener
|
||||
}
|
||||
@@ -342,12 +346,26 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
|
||||
//遊戲安全操作區域
|
||||
val viewGameRect = JSONObject()
|
||||
viewGameRect.put("left", 0)
|
||||
viewGameRect.put("top", container.context.resources.getDimensionPixelOffset(R.dimen.dp_180))
|
||||
viewGameRect.put("right", 0)
|
||||
viewGameRect.put("bottom", container.context.resources.getDimensionPixelOffset(R.dimen.dp_150))
|
||||
val viewRect = gameViewRect
|
||||
if (viewRect != null) {
|
||||
Log.d(TAG,"notifyGameViewInfo top:${viewRect.top} viewRect:${viewRect.bottom}")
|
||||
viewGameRect.put("left", viewRect.left)
|
||||
viewGameRect.put("top", viewRect.top)
|
||||
viewGameRect.put("right", viewRect.right)
|
||||
viewGameRect.put("bottom", viewRect.bottom)
|
||||
} else {
|
||||
viewGameRect.put("left", 0)
|
||||
viewGameRect.put(
|
||||
"top",
|
||||
container.context.resources.getDimensionPixelOffset(R.dimen.dp_185)
|
||||
)
|
||||
viewGameRect.put("right", 0)
|
||||
viewGameRect.put(
|
||||
"bottom",
|
||||
container.context.resources.getDimensionPixelOffset(R.dimen.dp_180)
|
||||
)
|
||||
}
|
||||
jsonObject.put("view_game_rect", viewGameRect)
|
||||
|
||||
//通知遊戲
|
||||
val json = jsonObject.toString()
|
||||
Log.d(TAG, "notifyGameViewInfo:$json")
|
||||
@@ -471,7 +489,7 @@ class GameDelegate(val activity: Activity, val container: FrameLayout, var mgId:
|
||||
} else if (isJoin) {
|
||||
val upPosition = AvRoomDataManager.get().findGamePosition()
|
||||
if (upPosition == Int.MIN_VALUE) {
|
||||
showToast("當前遊戲人數已滿!")
|
||||
showToast(ResUtil.getString(R.string.room_game_number_full))
|
||||
} else {
|
||||
UserModel.get().cacheLoginUserInfo?.gameStatus = 1
|
||||
homePartyModel.upMicroPhone(upPosition,
|
||||
|
@@ -68,41 +68,43 @@ class RoomOnlineWidget : FrameLayoutRoomWidget, RoomWidget {
|
||||
) : super(context, attrs, defStyleAttr, defStyleRes)
|
||||
|
||||
init {
|
||||
this.singleClick {
|
||||
RoomOnlineUserActivity.start(context)
|
||||
}
|
||||
adapter.setOnItemClickListener { adapter, view, position ->
|
||||
RoomOnlineUserActivity.start(context)
|
||||
}
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.recyclerView.addItemDecoration(
|
||||
VerticalDecoration(
|
||||
UIUtil.dip2px(context, 4.5),
|
||||
false,
|
||||
false
|
||||
if (!isInEditMode) {
|
||||
this.singleClick {
|
||||
RoomOnlineUserActivity.start(context)
|
||||
}
|
||||
adapter.setOnItemClickListener { adapter, view, position ->
|
||||
RoomOnlineUserActivity.start(context)
|
||||
}
|
||||
binding.recyclerView.adapter = adapter
|
||||
binding.recyclerView.addItemDecoration(
|
||||
VerticalDecoration(
|
||||
UIUtil.dip2px(context, 4.5),
|
||||
false,
|
||||
false
|
||||
)
|
||||
)
|
||||
)
|
||||
val isRTL = UiUtils.isRtl(context)
|
||||
binding.recyclerView.outlineProvider = object : ViewOutlineProvider() {
|
||||
override fun getOutline(view: View?, outline: Outline?) {
|
||||
if (isRTL) {
|
||||
outline?.setRect(
|
||||
UiUtils.dip2px(9f),
|
||||
0,
|
||||
(view?.width ?: 0),
|
||||
(view?.height ?: 0),
|
||||
)
|
||||
} else {
|
||||
outline?.setRect(
|
||||
0,
|
||||
0,
|
||||
(view?.width ?: 0) - UiUtils.dip2px(9f),
|
||||
(view?.height ?: 0),
|
||||
)
|
||||
val isRTL = UiUtils.isRtl(context)
|
||||
binding.recyclerView.outlineProvider = object : ViewOutlineProvider() {
|
||||
override fun getOutline(view: View?, outline: Outline?) {
|
||||
if (isRTL) {
|
||||
outline?.setRect(
|
||||
UiUtils.dip2px(9f),
|
||||
0,
|
||||
(view?.width ?: 0),
|
||||
(view?.height ?: 0),
|
||||
)
|
||||
} else {
|
||||
outline?.setRect(
|
||||
0,
|
||||
0,
|
||||
(view?.width ?: 0) - UiUtils.dip2px(9f),
|
||||
(view?.height ?: 0),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
binding.recyclerView.clipToOutline = true
|
||||
}
|
||||
binding.recyclerView.clipToOutline = true
|
||||
}
|
||||
|
||||
override fun onInitialize(roomView: RoomView, roomContext: RoomContext) {
|
||||
|
@@ -84,7 +84,9 @@ public class PKBoardView extends RelativeLayout implements View.OnClickListener
|
||||
|
||||
private void init() {
|
||||
inflate(getContext(), R.layout.layout_pk_board_view, this);
|
||||
|
||||
if (isInEditMode()) {
|
||||
return;
|
||||
}
|
||||
llPkScoreBoard = findViewById(R.id.root_view);
|
||||
rlRedTeamAddPeople = findViewById(R.id.fl_left);
|
||||
tvRedTeamScore = this.findViewById(R.id.tv_red_team_score);
|
||||
|
BIN
app/src/main/res/drawable-xxhdpi/room_ic_back_room.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/room_ic_back_room.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
app/src/main/res/drawable-xxhdpi/room_ic_game.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/room_ic_game.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
@@ -178,6 +178,7 @@
|
||||
|
||||
<com.chwl.app.avroom.widget.BottomView
|
||||
android:id="@+id/bottom_view"
|
||||
tools:layout_height="@dimen/dp_60"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentBottom="true" />
|
||||
@@ -236,6 +237,17 @@
|
||||
tools:contentDescription="@string/layout_fragment_av_room_game_05"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:onClick="@{click}"
|
||||
android:id="@+id/iv_game"
|
||||
android:layout_width="@dimen/dp_38"
|
||||
android:layout_height="@dimen/dp_38"
|
||||
android:layout_above="@id/iv_queuing_micro"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="@dimen/dp_11"
|
||||
android:layout_marginBottom="@dimen/dp_6"
|
||||
android:src="@drawable/room_ic_game" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
|
@@ -116,58 +116,6 @@
|
||||
app:layout_constraintStart_toEndOf="@id/room_title"
|
||||
app:layout_constraintTop_toTopOf="@id/room_title" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_change_game"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="7dp"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:background="@drawable/bg_room_select_game"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingTop="2dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="2dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toStartOf="@id/barrier_title_bar_right_menu_start"
|
||||
app:layout_constraintTop_toTopOf="@id/space_title_bar"
|
||||
tools:visibility="visible">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_select_game"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_curr_game"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="true"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="15sp"
|
||||
tools:text="@string/layout_fragment_chatroom_game_main_04" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_change_game_arrow"
|
||||
android:layout_width="20dp"
|
||||
android:layout_height="10dp"
|
||||
android:scaleType="center"
|
||||
android:src="@drawable/ic_room_arrow_type_below" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_game"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="4dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.Barrier
|
||||
android:id="@+id/barrier_title_bar_right_menu_start"
|
||||
android:layout_width="wrap_content"
|
||||
|
@@ -22,6 +22,7 @@
|
||||
</data>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/layout_root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
@@ -79,6 +80,7 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/layout_mic"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentEnd="true"
|
||||
@@ -123,6 +125,15 @@
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_back_room"
|
||||
android:layout_width="@dimen/dp_21"
|
||||
android:layout_height="@dimen/dp_21"
|
||||
android:layout_below="@id/layout_mic"
|
||||
android:layout_marginStart="@dimen/dp_10"
|
||||
android:layout_marginTop="@dimen/dp_5"
|
||||
android:onClick="@{click}"
|
||||
android:src="@drawable/room_ic_back_room" />
|
||||
|
||||
<com.chwl.app.avroom.widget.BottomView
|
||||
android:id="@+id/bottom_view"
|
||||
@@ -148,6 +159,17 @@
|
||||
android:layout_marginEnd="90dp"
|
||||
android:layout_marginBottom="@dimen/dp_10" />
|
||||
|
||||
<ImageView
|
||||
android:onClick="@{click}"
|
||||
android:id="@+id/iv_game"
|
||||
android:layout_width="@dimen/dp_38"
|
||||
android:layout_height="@dimen/dp_38"
|
||||
android:layout_above="@id/bottom_view"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginEnd="@dimen/dp_11"
|
||||
android:layout_marginBottom="@dimen/dp_6"
|
||||
android:src="@drawable/room_ic_game" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/input_layout"
|
||||
android:layout_width="match_parent"
|
||||
@@ -205,5 +227,11 @@
|
||||
android:layout_marginTop="75dp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<Space
|
||||
android:id="@+id/v_game_rect"
|
||||
android:layout_above="@id/message_indicator"
|
||||
android:layout_below="@id/layout_mic"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</RelativeLayout>
|
||||
</layout>
|
@@ -1,31 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:background="@color/white_transparent_60" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:lines="1"
|
||||
android:maxWidth="@dimen/dp_150"
|
||||
android:maxLines="1"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="15dp"
|
||||
app:autoSizeMaxTextSize="15dp"
|
||||
app:autoSizeMinTextSize="7dp"
|
||||
app:autoSizeStepGranularity="1px"
|
||||
app:autoSizeTextType="uniform"
|
||||
tools:text="@string/layout_item_room_select_game_01" />
|
||||
|
||||
</LinearLayout>
|
@@ -5282,4 +5282,9 @@
|
||||
|
||||
<string name="room_theme">خلفية الغرفة</string>
|
||||
<string name="room_theme_changed_tips">هل أنت متأكد أنك تريد اختيار هذه الصورة لتكون خلفية لغرفتك؟</string>
|
||||
|
||||
<string name="room_switch_game_tips">確認開啓該遊戲?</string>
|
||||
<string name="room_switch_standard_room_tips">確認切換成普通房嗎?</string>
|
||||
<string name="room_switch_game_failed_in_game">遊戲進行中,不可中止~</string>
|
||||
<string name="room_game_number_full">當前遊戲人數已滿!</string>
|
||||
</resources>
|
@@ -5225,4 +5225,8 @@
|
||||
<string name="gift_value">禮物值</string>
|
||||
<string name="room_theme">房間主題</string>
|
||||
<string name="room_theme_changed_tips">確認選擇這張圖片作為房間主題嗎?</string>
|
||||
<string name="room_switch_game_tips">確認開啓該遊戲?</string>
|
||||
<string name="room_switch_standard_room_tips">確認切換成普通房嗎?</string>
|
||||
<string name="room_switch_game_failed_in_game">遊戲進行中,不可中止~</string>
|
||||
<string name="room_game_number_full">當前遊戲人數已滿!</string>
|
||||
</resources>
|
@@ -5264,6 +5264,11 @@ You cannot join again within 24 hours after leaving</string>
|
||||
|
||||
<string name="room_theme">Room Background</string>
|
||||
<string name="room_theme_changed_tips">Are you sure you want to select this image as the room background?</string>
|
||||
|
||||
<string name="room_switch_game_tips">確認開啓該遊戲?</string>
|
||||
<string name="room_switch_standard_room_tips">確認切換成普通房嗎?</string>
|
||||
<string name="room_switch_game_failed_in_game">遊戲進行中,不可中止~</string>
|
||||
<string name="room_game_number_full">當前遊戲人數已滿!</string>
|
||||
</resources>
|
||||
|
||||
|
||||
|
@@ -97,7 +97,6 @@ class GameHomeFragment : BaseViewBindingFragment<GameHomeFragmentBinding>(), Mai
|
||||
binding.ivGameLogo.load(config.pic)
|
||||
adapter.setNewData(config.gameModes)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onWalletInfoUpdate(event: UpdateWalletInfoEvent?) {
|
||||
if (_binding == null) {
|
||||
|
@@ -20,24 +20,37 @@ object GameModel : BaseModel() {
|
||||
.compose(RxHelper.handleSchAndExce())
|
||||
}
|
||||
|
||||
fun getGameList(): Single<List<GameInfo>> {
|
||||
return api.getGameList()
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchAndExce())
|
||||
fun getGameList(roomUid: Long?): Single<List<GameInfo>> {
|
||||
if (roomUid == null) {
|
||||
return api.getGameList()
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchAndExce())
|
||||
} else {
|
||||
return api.getGameList(roomUid)
|
||||
.compose(RxHelper.handleBeanData())
|
||||
.compose(RxHelper.handleSchAndExce())
|
||||
}
|
||||
}
|
||||
|
||||
private interface Api {
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@POST("/miniGame/record/miniGameList")
|
||||
fun getGameList(
|
||||
): Single<ServiceResult<List<GameInfo>>>
|
||||
|
||||
/**
|
||||
* @param uid
|
||||
* @return
|
||||
*/
|
||||
@FormUrlEncoded
|
||||
@POST("/miniGame/record/miniGameList")
|
||||
fun getGameList(
|
||||
@Field("roomUid") uid: Long
|
||||
): Single<ServiceResult<List<GameInfo>>>
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
|
Reference in New Issue
Block a user