diff --git a/app/src/main/java/com/chwl/app/avroom/adapter/RoomGameListAdapter.kt b/app/src/main/java/com/chwl/app/avroom/adapter/RoomGameListAdapter.kt new file mode 100644 index 000000000..3504815ed --- /dev/null +++ b/app/src/main/java/com/chwl/app/avroom/adapter/RoomGameListAdapter.kt @@ -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(R.layout.room_gameplay_item2) { + override fun convert(helper: BaseViewHolder, item: GameInfo?) { + helper.setText(R.id.tv_name, item?.name) + val iconView = helper.getView(R.id.iv_icon) + iconView.load(item?.pic) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/avroom/adapter/SelectGameAdapter.kt b/app/src/main/java/com/chwl/app/avroom/adapter/SelectGameAdapter.kt deleted file mode 100644 index 5462bee97..000000000 --- a/app/src/main/java/com/chwl/app/avroom/adapter/SelectGameAdapter.kt +++ /dev/null @@ -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(R.layout.item_room_select_game) { - - override fun convert(helper: BaseViewHolder, item: GameInfo) { - helper.setText(R.id.tv_name,item.name) - } - -} \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/avroom/dialog/CreateGameRoomDialog.kt b/app/src/main/java/com/chwl/app/avroom/dialog/CreateGameRoomDialog.kt index 978a558ca..b8a305915 100644 --- a/app/src/main/java/com/chwl/app/avroom/dialog/CreateGameRoomDialog.kt +++ b/app/src/main/java/com/chwl/app/avroom/dialog/CreateGameRoomDialog.kt @@ -44,7 +44,7 @@ class CreateGameRoomDialog : BaseDialog() { dismissAllowingStateLoss() } - GameModel.getGameList() + GameModel.getGameList(null) .compose(bindToLifecycle()) .subscribe( { diff --git a/app/src/main/java/com/chwl/app/avroom/dialog/CreateRoomDialog.kt b/app/src/main/java/com/chwl/app/avroom/dialog/CreateRoomDialog.kt index 0ad739c51..2a7240ea1 100644 --- a/app/src/main/java/com/chwl/app/avroom/dialog/CreateRoomDialog.kt +++ b/app/src/main/java/com/chwl/app/avroom/dialog/CreateRoomDialog.kt @@ -88,7 +88,7 @@ class CreateRoomDialog : BaseDialog() { dismissAllowingStateLoss() } - GameModel.getGameList() + GameModel.getGameList(null) .compose(bindToLifecycle()) .subscribe( { diff --git a/app/src/main/java/com/chwl/app/avroom/dialog/RoomGameListDialog.kt b/app/src/main/java/com/chwl/app/avroom/dialog/RoomGameListDialog.kt new file mode 100644 index 000000000..ec1beaf72 --- /dev/null +++ b/app/src/main/java/com/chwl/app/avroom/dialog/RoomGameListDialog.kt @@ -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::class.java.simpleName) + val cacheKey = "game_list#${parentFragment.hashCode()}" + val list = dataService?.getData(cacheKey) as? List + if (!list.isNullOrEmpty()) { + loadData(list) + return + } + val disposable = getGameList(AvRoomDataManager.get().roomUid) + .doOnError { + SingleToastUtil.showToast(it.message) + switchStatus(-2) + } + .subscribe { it: List -> + dataService?.putData(cacheKey, it) + loadData(it) + } + getCompositeDisposable().add(disposable) + } + + private fun loadData(list: List?) { + 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) + } +} \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/avroom/dialog/RoomGameplayDialog.kt b/app/src/main/java/com/chwl/app/avroom/dialog/RoomGameplayDialog.kt index b124db71a..9a1ab4d44 100644 --- a/app/src/main/java/com/chwl/app/avroom/dialog/RoomGameplayDialog.kt +++ b/app/src/main/java/com/chwl/app/avroom/dialog/RoomGameplayDialog.kt @@ -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::class.java.simpleName) diff --git a/app/src/main/java/com/chwl/app/avroom/fragment/BaseRoomFragment.kt b/app/src/main/java/com/chwl/app/avroom/fragment/BaseRoomFragment.kt index e3982c216..aabf821b2 100644 --- a/app/src/main/java/com/chwl/app/avroom/fragment/BaseRoomFragment.kt +++ b/app/src/main/java/com/chwl/app/avroom/fragment/BaseRoomFragment.kt @@ -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?> : 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() } diff --git a/app/src/main/java/com/chwl/app/avroom/fragment/GameRoomFragment.kt b/app/src/main/java/com/chwl/app/avroom/fragment/GameRoomFragment.kt index 10a4a98d9..3e53e7e41 100644 --- a/app/src/main/java/com/chwl/app/avroom/fragment/GameRoomFragment.kt +++ b/app/src/main/java/com/chwl/app/avroom/fragment/GameRoomFragment.kt @@ -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(), @SuppressLint("CheckResult") override fun initiate() { gameBinding.microView.bindAdapter(GameMicroViewAdapter(context)) + resetGameViewRect() super.initiate() //游戏模式暂时不需要这个 PlayerModel.get().stop() @@ -93,6 +98,29 @@ class GameRoomFragment : BaseRoomFragment(), } } + 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(), 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() } } diff --git a/app/src/main/java/com/chwl/app/avroom/fragment/HomePartyFragment.java b/app/src/main/java/com/chwl/app/avroom/fragment/HomePartyFragment.java index b058219b3..dce06cb36 100644 --- a/app/src/main/java/com/chwl/app/avroom/fragment/HomePartyFragment.java +++ b/app/src/main/java/com/chwl/app/avroom/fragment/HomePartyFragment.java @@ -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); - } } } diff --git a/app/src/main/java/com/chwl/app/avroom/game/GameDelegate.kt b/app/src/main/java/com/chwl/app/avroom/game/GameDelegate.kt index cc37a4dca..1fda79b1f 100644 --- a/app/src/main/java/com/chwl/app/avroom/game/GameDelegate.kt +++ b/app/src/main/java/com/chwl/app/avroom/game/GameDelegate.kt @@ -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, diff --git a/app/src/main/java/com/chwl/app/avroom/online/RoomOnlineWidget.kt b/app/src/main/java/com/chwl/app/avroom/online/RoomOnlineWidget.kt index e88633327..1e0dbcfb1 100644 --- a/app/src/main/java/com/chwl/app/avroom/online/RoomOnlineWidget.kt +++ b/app/src/main/java/com/chwl/app/avroom/online/RoomOnlineWidget.kt @@ -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) { diff --git a/app/src/main/java/com/chwl/app/avroom/widget/PKBoardView.java b/app/src/main/java/com/chwl/app/avroom/widget/PKBoardView.java index 7c3242d98..a7bbf416f 100644 --- a/app/src/main/java/com/chwl/app/avroom/widget/PKBoardView.java +++ b/app/src/main/java/com/chwl/app/avroom/widget/PKBoardView.java @@ -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); diff --git a/app/src/main/res/drawable-xxhdpi/room_ic_back_room.png b/app/src/main/res/drawable-xxhdpi/room_ic_back_room.png new file mode 100644 index 000000000..a69a89f6d Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/room_ic_back_room.png differ diff --git a/app/src/main/res/drawable-xxhdpi/room_ic_game.png b/app/src/main/res/drawable-xxhdpi/room_ic_game.png new file mode 100644 index 000000000..aad91dd0b Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/room_ic_game.png differ diff --git a/app/src/main/res/layout/fragment_av_room_game.xml b/app/src/main/res/layout/fragment_av_room_game.xml index f8b6e3603..e2dd4485b 100644 --- a/app/src/main/res/layout/fragment_av_room_game.xml +++ b/app/src/main/res/layout/fragment_av_room_game.xml @@ -178,6 +178,7 @@ @@ -236,6 +237,17 @@ tools:contentDescription="@string/layout_fragment_av_room_game_05" tools:visibility="visible" /> + + - - - - - - - - - - - - - - @@ -79,6 +80,7 @@ + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/item_room_select_game.xml b/app/src/main/res/layout/item_room_select_game.xml deleted file mode 100644 index 72deff7b7..000000000 --- a/app/src/main/res/layout/item_room_select_game.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index cd425acde..96d5ae58c 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -5282,4 +5282,9 @@ خلفية الغرفة هل أنت متأكد أنك تريد اختيار هذه الصورة لتكون خلفية لغرفتك؟ + + 確認開啓該遊戲? + 確認切換成普通房嗎? + 遊戲進行中,不可中止~ + 當前遊戲人數已滿! \ No newline at end of file diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 55fe15b5f..1c66c1273 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -5225,4 +5225,8 @@ 禮物值 房間主題 確認選擇這張圖片作為房間主題嗎? + 確認開啓該遊戲? + 確認切換成普通房嗎? + 遊戲進行中,不可中止~ + 當前遊戲人數已滿! \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ab8ad8ea7..9a2ffac98 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -5264,6 +5264,11 @@ You cannot join again within 24 hours after leaving Room Background Are you sure you want to select this image as the room background? + + 確認開啓該遊戲? + 確認切換成普通房嗎? + 遊戲進行中,不可中止~ + 當前遊戲人數已滿! diff --git a/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeFragment.kt b/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeFragment.kt index 079d91bbe..725667a1d 100644 --- a/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeFragment.kt +++ b/app/src/module_game/java/com/chwl/app/game/ui/home/GameHomeFragment.kt @@ -97,7 +97,6 @@ class GameHomeFragment : BaseViewBindingFragment(), Mai binding.ivGameLogo.load(config.pic) adapter.setNewData(config.gameModes) } - @Subscribe(threadMode = ThreadMode.MAIN) fun onWalletInfoUpdate(event: UpdateWalletInfoEvent?) { if (_binding == null) { diff --git a/core/src/main/java/com/chwl/core/room/game/GameModel.kt b/core/src/main/java/com/chwl/core/room/game/GameModel.kt index 6dd27edb2..85f8df4b4 100644 --- a/core/src/main/java/com/chwl/core/room/game/GameModel.kt +++ b/core/src/main/java/com/chwl/core/room/game/GameModel.kt @@ -20,24 +20,37 @@ object GameModel : BaseModel() { .compose(RxHelper.handleSchAndExce()) } - fun getGameList(): Single> { - return api.getGameList() - .compose(RxHelper.handleBeanData()) - .compose(RxHelper.handleSchAndExce()) + fun getGameList(roomUid: Long?): Single> { + 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>> + /** + * @param uid + * @return + */ + @FormUrlEncoded + @POST("/miniGame/record/miniGameList") + fun getGameList( + @Field("roomUid") uid: Long + ): Single>> + /** * *