|
|
@@ -31,6 +31,7 @@ import com.adealink.weparty.commonui.toast.util.showFailedToast
|
|
|
import com.adealink.weparty.commonui.toast.util.showToast
|
|
|
import com.adealink.weparty.commonui.widget.BottomDialogFragment
|
|
|
import com.adealink.weparty.module.game.data.GameActivityRewardInfo.Companion.STATUS_RECEIVED
|
|
|
+import com.adealink.weparty.module.game.data.GameAppVersionOldCanPlayGameError
|
|
|
import com.adealink.weparty.module.game.gamehub.GameHubViewModel
|
|
|
import com.adealink.weparty.module.gamehub.carrom.Carrom
|
|
|
import com.adealink.weparty.module.gamehub.carrom.data.CarromGameType
|
|
|
@@ -449,49 +450,55 @@ class RoomGameCenterPanelFragment : BottomDialogFragment(R.layout.fragment_room_
|
|
|
return
|
|
|
}
|
|
|
roomGameViewModel.startGame(game).observe(viewLifecycleOwner) { rlt ->
|
|
|
+ fun doStartGame() {
|
|
|
+ when (game) {
|
|
|
+ Game.LUDO -> {
|
|
|
+ Router.getRouterInstance<BaseDialogFragment>(Ludo.CreateDialog.PATH)
|
|
|
+ ?.apply {
|
|
|
+ arguments = Bundle().apply {
|
|
|
+ putInt(
|
|
|
+ Ludo.Common.EXTRA_GAME_TYPE, when (type) {
|
|
|
+ RoomPlayCenterType.LUDO_TEAM -> LudoGameType.TEAM.type
|
|
|
+ else -> LudoGameType.MATCH.type
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }?.show(parentFragmentManager)
|
|
|
+ }
|
|
|
+
|
|
|
+ Game.CARROM -> {
|
|
|
+ Router.getRouterInstance<BaseDialogFragment>(Carrom.CreateDialog.PATH)
|
|
|
+ ?.apply {
|
|
|
+ arguments = Bundle().apply {
|
|
|
+ putInt(
|
|
|
+ Carrom.Common.EXTRA_GAME_TYPE, CarromGameType.MATCH.type
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }?.show(parentFragmentManager)
|
|
|
+ }
|
|
|
+
|
|
|
+ Game.UNO -> {
|
|
|
+ Router.getRouterInstance<BaseDialogFragment>(Uno.CreateDialog.PATH)
|
|
|
+ ?.apply {
|
|
|
+ arguments = Bundle().apply {
|
|
|
+ putInt(
|
|
|
+ Uno.Common.EXTRA_GAME_TYPE, UnoGameType.MATCH.type
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }?.show(parentFragmentManager)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
when (rlt) {
|
|
|
is Rlt.Failed -> {
|
|
|
showFailedToast(rlt)
|
|
|
+ if (rlt.error is GameAppVersionOldCanPlayGameError) {
|
|
|
+ doStartGame()
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
is Rlt.Success -> {
|
|
|
- when (game) {
|
|
|
- Game.LUDO -> {
|
|
|
- Router.getRouterInstance<BaseDialogFragment>(Ludo.CreateDialog.PATH)
|
|
|
- ?.apply {
|
|
|
- arguments = Bundle().apply {
|
|
|
- putInt(
|
|
|
- Ludo.Common.EXTRA_GAME_TYPE, when (type) {
|
|
|
- RoomPlayCenterType.LUDO_TEAM -> LudoGameType.TEAM.type
|
|
|
- else -> LudoGameType.MATCH.type
|
|
|
- }
|
|
|
- )
|
|
|
- }
|
|
|
- }?.show(parentFragmentManager)
|
|
|
- }
|
|
|
-
|
|
|
- Game.CARROM -> {
|
|
|
- Router.getRouterInstance<BaseDialogFragment>(Carrom.CreateDialog.PATH)
|
|
|
- ?.apply {
|
|
|
- arguments = Bundle().apply {
|
|
|
- putInt(
|
|
|
- Carrom.Common.EXTRA_GAME_TYPE, CarromGameType.MATCH.type
|
|
|
- )
|
|
|
- }
|
|
|
- }?.show(parentFragmentManager)
|
|
|
- }
|
|
|
-
|
|
|
- Game.UNO -> {
|
|
|
- Router.getRouterInstance<BaseDialogFragment>(Uno.CreateDialog.PATH)
|
|
|
- ?.apply {
|
|
|
- arguments = Bundle().apply {
|
|
|
- putInt(
|
|
|
- Uno.Common.EXTRA_GAME_TYPE, UnoGameType.MATCH.type
|
|
|
- )
|
|
|
- }
|
|
|
- }?.show(parentFragmentManager)
|
|
|
- }
|
|
|
- }
|
|
|
+ doStartGame()
|
|
|
}
|
|
|
}
|
|
|
}
|