DoggyZhang 4 сар өмнө
parent
commit
2462463524
100 өөрчлөгдсөн 18 нэмэгдсэн , 10011 устгасан
  1. 0 26
      app/build.gradle
  2. 18 16
      app/src/main/java/com/adealink/weparty/App.kt
  3. 0 2
      app/src/main/java/com/adealink/weparty/apm/HookTest.kt
  4. 0 14
      app/src/main/java/com/adealink/weparty/channel/AppChannel.kt
  5. 0 6
      app/src/main/java/com/adealink/weparty/channel/Tags.kt
  6. 0 201
      app/src/main/java/com/adealink/weparty/cocosgame/BaseCocosWebGameFragment.kt
  7. 0 5
      app/src/main/java/com/adealink/weparty/cocosgame/CocosGame.kt
  8. 0 35
      app/src/main/java/com/adealink/weparty/cocosgame/chat/adapter/QuickTextViewBinder.kt
  9. 0 103
      app/src/main/java/com/adealink/weparty/cocosgame/chat/component/ChatMessageComp.kt
  10. 0 638
      app/src/main/java/com/adealink/weparty/cocosgame/chat/component/QuickChatComp.kt
  11. 0 20
      app/src/main/java/com/adealink/weparty/cocosgame/chat/data/Data.kt
  12. 0 16
      app/src/main/java/com/adealink/weparty/cocosgame/chat/datasource/remote/ChatSocketService.kt
  13. 0 119
      app/src/main/java/com/adealink/weparty/cocosgame/chat/fragment/QuickChatFragment.kt
  14. 0 9
      app/src/main/java/com/adealink/weparty/cocosgame/chat/listener/IChatOperateListener.kt
  15. 0 24
      app/src/main/java/com/adealink/weparty/cocosgame/chat/viewmodel/QuickChatViewModel.kt
  16. 0 181
      app/src/main/java/com/adealink/weparty/cocosgame/comp/CoinsCollectAnimComp.kt
  17. 0 39
      app/src/main/java/com/adealink/weparty/cocosgame/data/CocosDialogData.kt
  18. 0 401
      app/src/main/java/com/adealink/weparty/cocosgame/data/CocosGameData.kt
  19. 0 189
      app/src/main/java/com/adealink/weparty/cocosgame/data/CocosNativeData.kt
  20. 0 126
      app/src/main/java/com/adealink/weparty/cocosgame/data/CocosPlayerData.kt
  21. 0 12
      app/src/main/java/com/adealink/weparty/cocosgame/data/CocosRoomType.kt
  22. 0 212
      app/src/main/java/com/adealink/weparty/cocosgame/data/CocosWindowViewData.kt
  23. 0 27
      app/src/main/java/com/adealink/weparty/cocosgame/data/Error.kt
  24. 0 20
      app/src/main/java/com/adealink/weparty/cocosgame/data/GameConstants.kt
  25. 0 331
      app/src/main/java/com/adealink/weparty/cocosgame/data/GameData.kt
  26. 0 218
      app/src/main/java/com/adealink/weparty/cocosgame/data/GameToNativeOpData.kt
  27. 0 31
      app/src/main/java/com/adealink/weparty/cocosgame/data/NativeToGameOpData.kt
  28. 0 15
      app/src/main/java/com/adealink/weparty/cocosgame/data/Tags.kt
  29. 0 31
      app/src/main/java/com/adealink/weparty/cocosgame/datasource/local/CocosGameLocalService.kt
  30. 0 166
      app/src/main/java/com/adealink/weparty/cocosgame/datasource/remote/CommonGameHttpService.kt
  31. 0 81
      app/src/main/java/com/adealink/weparty/cocosgame/gift/adapter/SendGiftInfoRollViewBinder.kt
  32. 0 123
      app/src/main/java/com/adealink/weparty/cocosgame/gift/comp/SendGiftComp.kt
  33. 0 20
      app/src/main/java/com/adealink/weparty/cocosgame/listener/ICocosGameOperateListener.kt
  34. 0 342
      app/src/main/java/com/adealink/weparty/cocosgame/manager/CocosWebGameManager.kt
  35. 0 47
      app/src/main/java/com/adealink/weparty/cocosgame/manager/ICocosWebGameManager.kt
  36. 0 42
      app/src/main/java/com/adealink/weparty/cocosgame/manager/listener/ICocosGameListener.kt
  37. 0 36
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnDeeplink.kt
  38. 0 22
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnDismissDialog.kt
  39. 0 21
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnGameEnd.kt
  40. 0 22
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnGameOp.kt
  41. 0 24
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnGameRecoverFail.kt
  42. 0 20
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnGameStart.kt
  43. 0 31
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnGetAppEnv.kt
  44. 0 45
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnGetCurrency.kt
  45. 0 35
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnGetGameView.kt
  46. 0 22
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnInitNodeView.kt
  47. 0 29
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnLog.kt
  48. 0 106
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnNetworkRequest.kt
  49. 0 25
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnNodeVisibleChanged.kt
  50. 0 38
      app/src/main/java/com/adealink/weparty/cocosgame/method/OnStat.kt
  51. 0 26
      app/src/main/java/com/adealink/weparty/cocosgame/method/PauseDialogManagerJSNativeMethod.kt
  52. 0 39
      app/src/main/java/com/adealink/weparty/cocosgame/util/CocosGameUtil.kt
  53. 0 370
      app/src/main/java/com/adealink/weparty/cocosgame/viewmodel/BaseCocosWebGameViewModel.kt
  54. 0 42
      app/src/main/java/com/adealink/weparty/cocosgame/viewmodel/CocosGameUserLeagueViewModel.kt
  55. 0 80
      app/src/main/java/com/adealink/weparty/cocosgame/viewmodel/IBaseCocosWebGameViewModel.kt
  56. 0 47
      app/src/main/java/com/adealink/weparty/cocosgame/viewmodel/ICocosGameViewModel.kt
  57. 0 161
      app/src/main/java/com/adealink/weparty/cocosgame/web/CocosGameWebView.kt
  58. 0 309
      app/src/main/java/com/adealink/weparty/cocosgame/web/CocosJSBridgeImpl.kt
  59. 0 37
      app/src/main/java/com/adealink/weparty/cocosgame/web/data/CocosJSRequest.kt
  60. 0 590
      app/src/main/java/com/adealink/weparty/commonui/datepicker/CustomDatePicker.kt
  61. 0 52
      app/src/main/java/com/adealink/weparty/commonui/datepicker/DateFormatUtils.kt
  62. 0 363
      app/src/main/java/com/adealink/weparty/commonui/datepicker/PickerView.kt
  63. 0 184
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/BaseDialogData.kt
  64. 0 29
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/BaseDialogTask.kt
  65. 0 10
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/DialogScope.kt
  66. 0 221
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/DialogShowManager.kt
  67. 0 72
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/DialogTaskManager.kt
  68. 0 21
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/Priority.kt
  69. 0 54
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/CharmLevelUpgradeDialogTask.kt
  70. 0 48
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/CommonDialogTask.kt
  71. 0 54
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/CommonTaskRewardDialogTask.kt
  72. 0 48
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/CompleteProfileDialogTask.kt
  73. 0 65
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/DailySignInTask.kt
  74. 0 84
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/GenderChangeDialogTask.kt
  75. 0 52
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/InviteRewardDialogTask.kt
  76. 0 86
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/MedalAchieveDialogTask.kt
  77. 0 69
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/NewUserLotteryDialogTask.kt
  78. 0 81
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/NewUserRewardDialogTask.kt
  79. 0 110
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/UserGreetingDialogTask.kt
  80. 0 83
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/VipNewFeatureDialogTask.kt
  81. 0 52
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/VipRechargeLevelUpgradeDialogTask.kt
  82. 0 50
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/WealthLevelUpgradeDialogTask.kt
  83. 0 94
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/WelcomeDialogTask.kt
  84. 0 49
      app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/WomemChatDiamondDialogTask.kt
  85. 0 451
      app/src/main/java/com/adealink/weparty/commonui/dialogfragment/WheelDatePickerDialogFragment.kt
  86. 0 80
      app/src/main/java/com/adealink/weparty/commonui/dialogfragment/WheelSimpleListStringDialogFragment.kt
  87. 0 0
      app/src/main/java/com/adealink/weparty/commonui/ext/FragmentExt.kt
  88. 0 1
      app/src/main/java/com/adealink/weparty/commonui/fresco/NetworkImageUtil.kt
  89. 0 277
      app/src/main/java/com/adealink/weparty/commonui/game/GameButton.kt
  90. 0 441
      app/src/main/java/com/adealink/weparty/commonui/game/GameTextView.kt
  91. 0 32
      app/src/main/java/com/adealink/weparty/commonui/widget/choicelist/ChoiceItemViewBinder.kt
  92. 0 14
      app/src/main/java/com/adealink/weparty/commonui/widget/choicelist/ChoiceModel.kt
  93. 0 106
      app/src/main/java/com/adealink/weparty/commonui/widget/choicelist/CommonChoiceListView.kt
  94. 0 114
      app/src/main/java/com/adealink/weparty/commonui/widget/choicelist/CommonImageChoiceListView.kt
  95. 0 42
      app/src/main/java/com/adealink/weparty/commonui/widget/choicelist/ImageChoiceItemViewBinder.kt
  96. 0 9
      app/src/main/java/com/adealink/weparty/commonui/widget/choicelist/OnCheckChangeListener.kt
  97. 0 10
      app/src/main/java/com/adealink/weparty/commonui/widget/tags/OnSelectTagsListener.kt
  98. 0 242
      app/src/main/java/com/adealink/weparty/commonui/widget/tags/TagsLayout.kt
  99. 0 12
      app/src/main/java/com/adealink/weparty/commonui/widget/upload/InnerUploadFileOpCallback.kt
  100. 0 84
      app/src/main/java/com/adealink/weparty/commonui/widget/upload/UploadFileAddView.kt

+ 0 - 26
app/build.gradle

@@ -207,32 +207,6 @@ android {
     dynamicFeatures = [
             ':module:account',
             ':module:profile',
-//            ':module:room',
-//            ':module:follow',
-//            ':module:setting',
-//            ':module:gift',
-//            ':module:wallet',
-//            ':module:webview',
-//            ':module:emotion',
-//            ':module:message',
-//            ':module:rank',
-//            ':module:game',
-//            ':module:music',
-//            ':module:theme',
-//            ':module:level',
-//            ':module:operation',
-//            ':module:entereffect',
-//            ':module:store',
-//            ':module:headline',
-//            ':module:search',
-//            ':module:share',
-//            ':module:image',
-//            ':module:call',
-//            ':module:excel',
-//            ':module:email',
-//            ':module:skin',
-//            ':module:family',
-//            ':module:attribution'
     ]
     buildFeatures {
         viewBinding true

+ 18 - 16
app/src/main/java/com/adealink/weparty/App.kt

@@ -147,7 +147,9 @@ class App : SplitCompatApplication(), ActivityLifecycleCallbacksExt {
         Room.databaseBuilder(applicationContext, AppDatabase::class.java, "weparty_app_db").build()
     }
     val logService: ILogService by lazy { LogService(LogConfig()) }
-    val imService by lazy { IMService.create(IMConfig()) }
+
+    // TODO: 重写IM
+//    val imService by lazy { IMService.create(IMConfig()) }
     val hardwareManager: IHardwareManager by lazy { HardwareManager() }
 
     var appStartTime = 0L
@@ -386,21 +388,21 @@ class App : SplitCompatApplication(), ActivityLifecycleCallbacksExt {
 
     inner class InitIM : SubWaitStartUpTask() {
         override fun run() {
-            imService.init(
-                this@App,
-                InitOption.Builder()
-                    .setAreaCode(
-                        when (AppBase.isProdEnv) {
-                            true -> InitOption.AreaCode.SG
-                            else -> InitOption.AreaCode.BJ
-                        }
-                    )
-                    .setMainProcess(true)
-                    .enablePush(false)
-                    .enableSyncEmptyTopConversation(true)
-                    .build()
-            )
-            MessageModule.appOnCreateMainTask(this@App)
+//            imService.init(
+//                this@App,
+//                InitOption.Builder()
+//                    .setAreaCode(
+//                        when (AppBase.isProdEnv) {
+//                            true -> InitOption.AreaCode.SG
+//                            else -> InitOption.AreaCode.BJ
+//                        }
+//                    )
+//                    .setMainProcess(true)
+//                    .enablePush(false)
+//                    .enableSyncEmptyTopConversation(true)
+//                    .build()
+//            )
+//            MessageModule.appOnCreateMainTask(this@App)
         }
     }
 

+ 0 - 2
app/src/main/java/com/adealink/weparty/apm/HookTest.kt

@@ -7,8 +7,6 @@ import com.flyjingfish.android_aop_annotation.enums.MatchType
 
 /**
  * 定义一些替换操作
- * Created by XiaoDongLin.
- * Date: 2025/8/22
  */
 @AndroidAopMatchClassMethod(
     targetClassName = "androidx.viewpager2.widget.ScrollEventAdapter",

+ 0 - 14
app/src/main/java/com/adealink/weparty/channel/AppChannel.kt

@@ -1,14 +0,0 @@
-package com.adealink.weparty.channel
-
-/**
- * Created by sunxiaodong on 2021/9/8.
- */
-enum class AppChannel(val channel: String) {
-    GP("gp"), //自然量
-    GOOGLE_PLAY("google-play"), //自然量
-    HUAWEI("huawei"),
-    LUOKAI("luokai"),
-    GOOGLE("google"), //google投放
-    FB("fb"), //fb投放
-    HUI_TENG("huiteng"), //辉腾
-}

+ 0 - 6
app/src/main/java/com/adealink/weparty/channel/Tags.kt

@@ -1,6 +0,0 @@
-package com.adealink.weparty.channel
-
-/**
- * Created by sunxiaodong on 2021/9/6.
- */
-const val TAG_CHANNEL = "tag_channel"

+ 0 - 201
app/src/main/java/com/adealink/weparty/cocosgame/BaseCocosWebGameFragment.kt

@@ -1,201 +0,0 @@
-package com.adealink.weparty.cocosgame
-
-import android.os.Bundle
-import android.view.View
-import androidx.annotation.LayoutRes
-import androidx.constraintlayout.widget.ConstraintLayout
-import androidx.core.view.updateLayoutParams
-import androidx.fragment.app.DialogFragment
-import androidx.lifecycle.Observer
-import androidx.viewbinding.ViewBinding
-import com.adealink.frame.base.AppBase
-import com.adealink.frame.router.Router
-import com.adealink.weparty.cocosgame.chat.listener.IChatOperateListener
-import com.adealink.weparty.cocosgame.data.ClickAvatarOpData
-import com.adealink.weparty.cocosgame.data.ClickEmotionOpData
-import com.adealink.weparty.cocosgame.data.ClickMessageOpData
-import com.adealink.weparty.cocosgame.data.ClickMicOpData
-import com.adealink.weparty.cocosgame.data.CurrencyInsufficientDialogData
-import com.adealink.weparty.cocosgame.data.DialogData
-import com.adealink.weparty.cocosgame.data.ExitGameDialogData
-import com.adealink.weparty.cocosgame.data.Game
-import com.adealink.weparty.cocosgame.data.GameToNativeOpData
-import com.adealink.weparty.cocosgame.data.InitGameData
-import com.adealink.weparty.cocosgame.data.ShowGameRuleOpData
-import com.adealink.weparty.cocosgame.data.UnknownDialogData
-import com.adealink.weparty.cocosgame.viewmodel.BaseCocosWebGameViewModel
-import com.adealink.weparty.cocosgame.web.CocosGameWebView
-import com.adealink.weparty.commonui.BaseFragment
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.commonui.ext.dp
-import com.adealink.weparty.commonui.toast.util.showToast
-import com.adealink.weparty.commonui.widget.BottomDialogFragment
-import com.adealink.weparty.module.room.Room
-import com.adealink.weparty.module.room.data.MemberInfoDialogSource
-import com.adealink.weparty.module.wallet.Wallet
-import com.adealink.weparty.module.wallet.data.Currency
-import com.qmuiteam.qmui.widget.util.QMUIStatusBarHelper
-
-/**
- * Cocos Web 游戏基础
- */
-abstract class BaseCocosWebGameFragment<VM : BaseCocosWebGameViewModel<*, *, *, *>, VB : ViewBinding>(@LayoutRes contentLayoutId: Int) :
-    BaseFragment(contentLayoutId),
-    IChatOperateListener {
-
-    abstract val cocosViewModel: VM
-
-    /**
-     * Cocos游戏码
-     */
-    abstract fun cocosGame(): Game
-
-    /**
-     * Cocos游戏启动Url
-     */
-    abstract fun gameUrl(): String
-
-    /**
-     * Activity content view
-     */
-    abstract fun contentView(): VB
-
-    /**
-     * 这个方法在 setContentView 之后调用,用于初始化一些视图控件
-     */
-    abstract fun onCocosGameViewCreated(viewBinding: VB)
-
-    /**
-     * Cocos游戏渲染安全区域(排除顶部状态栏, 底部导航栏等)
-     */
-    abstract fun safeView(): View
-
-    abstract fun inflateCocosWebView(viewBinding: VB)
-
-    abstract fun webView(): CocosGameWebView
-
-    override fun initViews() {
-        super.initViews()
-        val contentViewBinding = contentView()
-        fixSafeView()
-        cocosViewModel.onCreate()
-        cocosViewModel.initGame(
-            webView(),
-            safeView(),
-            InitGameData(cocosGame(), 58.dp())
-        )
-        loadUrlAfterViewCreated()
-        onCocosGameViewCreated(contentViewBinding)
-        if (!AppBase.isRelease) {
-            // DEBUG包打印游戏路径
-            showToast("DEBUG: gameCode:${cocosGame()}, gameUrl:${gameUrl()}")
-        }
-    }
-
-    open fun fixSafeView() {
-        safeView().updateLayoutParams<ConstraintLayout.LayoutParams> {
-            topMargin = QMUIStatusBarHelper.getStatusbarHeight(context) + 44.dp() //44dp是游戏顶部栏高度
-        }
-    }
-
-    open fun reload() {
-        webView().loadUrl(gameUrl())
-    }
-
-    open fun loadUrlAfterViewCreated(){
-        webView().loadUrl(gameUrl())
-    }
-
-    override fun onDestroy() {
-        super.onDestroy()
-        webView().onDestroy()
-        cocosViewModel.onDestroy()
-    }
-
-    override fun observeViewModel() {
-        super.observeViewModel()
-        cocosViewModel.apply {
-            gameToNativeOpLD.observeWithoutCache(viewLifecycleOwner,
-                object : Observer<GameToNativeOpData>{
-                    override fun onChanged(value: GameToNativeOpData) {
-                        onGameToNativeOpData(value)
-                    }
-                }
-            )
-            showDialogLD.observeWithoutCache(viewLifecycleOwner,
-                object: Observer<DialogData>{
-                    override fun onChanged(value: DialogData) {
-                        showDialog(value)
-                    }
-                }
-            )
-            dismissDialogLD.observeWithoutCache(viewLifecycleOwner,
-                object: Observer<Long>{
-                    override fun onChanged(value: Long) {
-                        dismissDialog(value)
-                    }
-                }
-            )
-        }
-    }
-
-    /*
-     * OpData
-     */
-    open fun onGameToNativeOpData(opData: GameToNativeOpData) {
-        when (opData) {
-            is ClickAvatarOpData -> onAvatarClick(opData.uid)
-            is ClickMicOpData -> onMicClick(opData.uid)
-            is ClickEmotionOpData -> onEmotionBtnClick(opData)
-            is ClickMessageOpData -> onMessageBtnClick(opData)
-            is ShowGameRuleOpData -> onGameRuleBtnClick(opData)
-            else -> {}
-        }
-    }
-
-    open fun onAvatarClick(uid: Long) {
-        Router.getRouterInstance<BottomDialogFragment>(Room.RoomMemberInfo.PATH)?.apply {
-            arguments = Bundle().apply {
-                putLong(Room.Common.EXTRA_UID, uid)
-                putSerializable(
-                    Room.Common.EXTRA_SOURCE,
-                    MemberInfoDialogSource.RoomGaming
-                )
-            }
-        }?.show(childFragmentManager)
-    }
-
-    open fun onMicClick(uid: Long) {}
-
-    open fun onEmotionBtnClick(data: ClickEmotionOpData) {}
-
-    open fun onMessageBtnClick(data: ClickMessageOpData) {}
-
-    open fun onGameRuleBtnClick(data: ShowGameRuleOpData) {}
-
-    /*
-     * DialogData
-     */
-    open fun showDialog(data: DialogData) {
-        when (data) {
-            is ExitGameDialogData -> showExitGameDialog(data)
-            is CurrencyInsufficientDialogData -> {
-                Router.getRouterInstance<BaseDialogFragment>(Wallet.WalletNotEnoughDialog.PATH)?.apply { //5
-                    arguments = Bundle().apply {
-                        putByte(Wallet.WalletNotEnoughDialog.EXTRA_CURRENCY_TYPE, Currency.getCurrencyByValue(data.type.toByte())?.value ?: Currency.Coin.value)
-                    }
-                }
-                    ?.show(childFragmentManager)
-            }
-
-            is UnknownDialogData -> {}
-        }
-    }
-
-    private fun dismissDialog(id: Long) {
-        (childFragmentManager.findFragmentByTag(id.toString()) as? DialogFragment)?.dismissAllowingStateLoss()
-    }
-
-    open fun showExitGameDialog(exitData: ExitGameDialogData) {}
-
-}

+ 0 - 5
app/src/main/java/com/adealink/weparty/cocosgame/CocosGame.kt

@@ -1,5 +0,0 @@
-package com.adealink.weparty.cocosgame
-
-interface CocosGame {
-
-}

+ 0 - 35
app/src/main/java/com/adealink/weparty/cocosgame/chat/adapter/QuickTextViewBinder.kt

@@ -1,35 +0,0 @@
-package com.adealink.weparty.cocosgame.chat.adapter
-
-import android.view.LayoutInflater
-import android.view.ViewGroup
-import com.adealink.weparty.cocosgame.chat.listener.IChatOperateListener
-import com.adealink.weparty.cocosgame.data.QuickText
-import com.adealink.weparty.commonui.recycleview.adapter.BindingViewHolder
-import com.adealink.weparty.commonui.recycleview.adapter.multitype.ItemViewBinder
-import com.adealink.weparty.databinding.ItemCocosgameQuickTextBinding
-
-class QuickTextViewBinder(val l: IChatOperateListener) :
-    ItemViewBinder<QuickText, BindingViewHolder<ItemCocosgameQuickTextBinding>>() {
-
-    override fun onCreateViewHolder(
-        inflater: LayoutInflater,
-        parent: ViewGroup
-    ): BindingViewHolder<ItemCocosgameQuickTextBinding> {
-        return BindingViewHolder(ItemCocosgameQuickTextBinding.inflate(inflater, parent, false))
-    }
-
-    override fun onBindViewHolder(
-        holder: BindingViewHolder<ItemCocosgameQuickTextBinding>,
-        item: QuickText
-    ) {
-        holder.binding.root.text = item.getText()
-        holder.binding.root.setOnClickListener {
-            l.onQuickTextClick(item)
-        }
-    }
-
-    companion object {
-        const val SPAN_COUNT = 3
-    }
-
-}

+ 0 - 103
app/src/main/java/com/adealink/weparty/cocosgame/chat/component/ChatMessageComp.kt

@@ -1,103 +0,0 @@
-package com.adealink.weparty.cocosgame.chat.component
-
-import android.view.View
-import androidx.constraintlayout.widget.ConstraintLayout
-import androidx.core.view.updateLayoutParams
-import androidx.lifecycle.LifecycleOwner
-import com.adealink.frame.base.fastLazy
-import com.adealink.frame.dot.Dot
-import com.adealink.frame.dot.DotView
-import com.adealink.frame.dot.NormalDot
-import com.adealink.frame.dot.NumDot
-import com.adealink.frame.mvvm.view.ViewComponent
-import com.adealink.weparty.cocosgame.data.ClickMessageOpData
-import com.adealink.weparty.cocosgame.data.CocosPosition
-import com.adealink.weparty.cocosgame.data.CocosViewSize
-import com.adealink.weparty.cocosgame.viewmodel.IBaseCocosWebGameViewModel
-import com.adealink.weparty.commonui.ext.dp
-import com.adealink.weparty.module.room.RoomModule
-import com.adealink.weparty.module.room.data.RoomChatMessagePanelStatus
-
-class ChatMessageComp(
-    lifecycleOwner: LifecycleOwner,
-    private val ivMessage: View,
-    private val dotView: DotView,
-    private val cocosViewModel: IBaseCocosWebGameViewModel<*, *, *, *>
-) : ViewComponent(lifecycleOwner) {
-
-    private val chatMessageViewModel by fastLazy { RoomModule.getChatMessageViewModel(requireActivity()) }
-    private val roomGameViewModel by fastLazy { RoomModule.getRoomGameViewModel(requireActivity()) }
-
-    private val messageDot = Dot(arrayListOf(), "MessageDot")
-
-    override fun onCreate() {
-        super.onCreate()
-        initViews()
-        observeViewModel()
-    }
-
-    private fun initViews() {
-        dotView.observeDot(viewLifecycleOwner, messageDot)
-    }
-
-    private fun observeViewModel() {
-        cocosViewModel.messageBtnNodeViewLD.observe(viewLifecycleOwner) {
-            initMessageBtn(it.position, it.size)
-        }
-        chatMessageViewModel?.messageAddLD?.observeWithoutCache(viewLifecycleOwner) {
-            showNewMessageDot(true)
-        }
-    }
-
-    private fun initMessageBtn(position: CocosPosition, size: CocosViewSize) {
-        ivMessage.updateLayoutParams<ConstraintLayout.LayoutParams> {
-            width = size.width.toInt()
-            height = size.height.toInt()
-            leftMargin = (position.x - size.width / 2).toInt()
-            bottomMargin = (position.y - size.height / 2).toInt()
-        }
-        dotView.updateLayoutParams<ConstraintLayout.LayoutParams> {
-            leftMargin = (size.width * 0.75f).toInt()
-            topMargin = 1.dp()
-        }
-    }
-
-    fun switchChatMessagePanel(data: ClickMessageOpData) {
-        if (isShow()) {
-            hideChatMessagePanel()
-        } else {
-            initMessageBtn(data.position, data.size)
-            showChatMessagePanel()
-            showNewMessageDot(false)
-        }
-    }
-
-    private fun showChatMessagePanel() {
-        roomGameViewModel?.updateRoomChatMessagePanelStatus(RoomChatMessagePanelStatus.Expanding)
-    }
-
-    fun isShow(): Boolean {
-        return roomGameViewModel?.isRoomChatMessageShow ?: false
-    }
-
-    fun hideChatMessagePanel() {
-        if (roomGameViewModel?.isIamPlayer() == true) {
-            roomGameViewModel?.updateRoomChatMessagePanelStatus(RoomChatMessagePanelStatus.Hide)
-            return
-        }
-        roomGameViewModel?.updateRoomChatMessagePanelStatus(RoomChatMessagePanelStatus.Shrinking)
-    }
-
-    fun clear() {
-        dotView.show(NumDot(0))
-    }
-
-    private fun showNewMessageDot(show: Boolean) {
-        if (roomGameViewModel?.isIamPlayer() == true) {
-            messageDot.show(NormalDot(show))
-        } else {
-            messageDot.hide()
-        }
-    }
-
-}

+ 0 - 638
app/src/main/java/com/adealink/weparty/cocosgame/chat/component/QuickChatComp.kt

@@ -1,638 +0,0 @@
-package com.adealink.weparty.cocosgame.chat.component
-
-import android.view.Gravity
-import android.view.LayoutInflater
-import android.view.View
-import android.widget.FrameLayout
-import android.widget.TextView
-import androidx.constraintlayout.widget.ConstraintLayout
-import androidx.constraintlayout.widget.ConstraintLayout.LayoutParams
-import androidx.core.view.isVisible
-import androidx.core.view.updateLayoutParams
-import androidx.lifecycle.LifecycleOwner
-import com.adealink.frame.aab.util.getCompatDrawable
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.base.fastLazy
-import com.adealink.frame.effect.listener.IPlayListener
-import com.adealink.frame.effect.view.EffectView
-import com.adealink.frame.log.Log
-import com.adealink.frame.mvvm.view.ViewComponent
-import com.adealink.frame.util.DisplayUtil
-import com.adealink.frame.util.runOnUiThread
-import com.adealink.weparty.R
-import com.adealink.weparty.cocosgame.chat.data.EmotionBubble
-import com.adealink.weparty.cocosgame.chat.data.QuickChatBubble
-import com.adealink.weparty.cocosgame.chat.data.QuickTextBubble
-import com.adealink.weparty.cocosgame.chat.fragment.QuickChatFragment
-import com.adealink.weparty.cocosgame.data.ClickEmotionOpData
-import com.adealink.weparty.cocosgame.data.CocosPosition
-import com.adealink.weparty.cocosgame.data.CocosViewData
-import com.adealink.weparty.cocosgame.data.CocosViewLocation
-import com.adealink.weparty.cocosgame.data.CocosViewSize
-import com.adealink.weparty.cocosgame.data.Game
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_FLOW
-import com.adealink.weparty.cocosgame.viewmodel.IBaseCocosWebGameViewModel
-import com.adealink.weparty.commonui.ext.gone
-import com.adealink.weparty.commonui.ext.show
-import com.adealink.weparty.commonui.toast.util.showFailedToast
-import com.adealink.weparty.databinding.LayoutCocosgameEmotionBubbleBottomBinding
-import com.adealink.weparty.databinding.LayoutCocosgameEmotionBubbleLeftBinding
-import com.adealink.weparty.databinding.LayoutCocosgameEmotionBubbleRightBinding
-import com.adealink.weparty.databinding.LayoutCocosgameEmotionBubbleTopBinding
-import com.adealink.weparty.databinding.LayoutCocosgameQuickTextBubbleBottomBinding
-import com.adealink.weparty.databinding.LayoutCocosgameQuickTextBubbleLeftBinding
-import com.adealink.weparty.databinding.LayoutCocosgameQuickTextBubbleRightBinding
-import com.adealink.weparty.databinding.LayoutCocosgameQuickTextBubbleTopBinding
-import com.adealink.weparty.module.emotion.EmotionModule
-import com.adealink.weparty.module.emotion.data.EmotionInfo
-import com.adealink.weparty.module.emotion.data.SendEmotionNotify
-import com.adealink.weparty.module.emotion.effect.EmotionEffectEntity
-import com.adealink.weparty.module.room.RoomModule
-import com.adealink.weparty.module.room.chat.data.EmotionMsgContent
-import com.adealink.weparty.module.room.chat.data.Message
-import com.adealink.weparty.module.room.chat.data.MessageType
-import com.adealink.weparty.module.room.chat.data.QuickMsgContent
-import com.adealink.weparty.module.room.data.SendEmotionScene
-import java.util.LinkedList
-import java.util.Queue
-import kotlin.collections.set
-
-class QuickChatComp(
-    lifecycleOwner: LifecycleOwner,
-    private val game: Game,
-    private val vEmotion: View, //表情按钮
-    private val panelContainer: FrameLayout, //表情面板
-    private val emotionContainer: ConstraintLayout, //表情气泡容器
-    private val cocosViewModel: IBaseCocosWebGameViewModel<*, *, *, *>?
-) : ViewComponent(lifecycleOwner) {
-
-    private val chatViewModel by fastLazy { RoomModule.getChatMessageViewModel(requireActivity()) }
-    private val emotionViewModel by fastLazy { EmotionModule.getEmotionViewModel(requireActivity()) }
-    private var quickChatFragment: QuickChatFragment? = null
-
-    //玩家头像位置辅助定位
-    private val player2EmotionBubble = HashMap<Long, Pair<CocosViewLocation, View>>(4)
-    private val player2QuickTextBubble = HashMap<Long, Pair<CocosViewLocation, View>>(4)
-    private val player2BubbleQueue = HashMap<Long, Queue<QuickChatBubble>>(4)
-
-    override fun onCreate() {
-        super.onCreate()
-        initViews()
-        observeViewModel()
-    }
-
-    private fun initViews() {
-
-    }
-
-    private fun observeViewModel() {
-        cocosViewModel?.emotionBtnNodeViewLD?.observe(viewLifecycleOwner) {
-            initEmotionBtn(it.position, it.size)
-        }
-        emotionViewModel?.apply {
-            clickedEmotionLD.observeWithoutCache(viewLifecycleOwner) {
-                this@QuickChatComp.onEmotionClick(it.first, it.second)
-            }
-            sendEmotionNotifyLD.observeWithoutCache(viewLifecycleOwner) {
-                onEmotionNotify(it)
-            }
-        }
-        chatViewModel?.messageAddLD?.observeWithoutCache(viewLifecycleOwner) {
-            it.onEach { msg ->
-                if (msg.getMessageType() == MessageType.QUICK_MESSAGE) {
-                    val quickText = (msg.content as? QuickMsgContent)?.quickText
-                    if (quickText != null) {
-                        quickText.senderUid = msg.sendUid
-                        addQuickChatBubble(QuickTextBubble(msg.sendUid, quickText))
-                    }
-                }
-            }
-        }
-    }
-
-    private fun onEmotionNotify(data: SendEmotionNotify) {
-        when (SendEmotionScene.map(data.scene)) {
-            SendEmotionScene.UNKNOWN -> {}
-            SendEmotionScene.MIC,
-            SendEmotionScene.ROOM_CHAT,
-            SendEmotionScene.SESSION_DETAIL -> {
-                addQuickChatBubble(EmotionBubble(data.fromUid, data.emotionInfo, data.resultIndex))
-            }
-
-            SendEmotionScene.COCOS_GAME -> {
-                chatViewModel?.addMessages(
-                    listOf(
-                        Message.crateMessage(
-                            MessageType.EMOTION,
-                            EmotionMsgContent(data),
-                            data.fromUid
-                        )
-                    )
-                )
-                addQuickChatBubble(EmotionBubble(data.fromUid, data.emotionInfo, data.resultIndex))
-            }
-
-            SendEmotionScene.GAME_PRANK -> {}
-        }
-    }
-
-    private fun onEmotionClick(emotionInfo: EmotionInfo, scene: SendEmotionScene) {
-        val roomId = RoomModule.getJoinedRoomId()
-        if (roomId == null || roomId <= 0) {
-            return
-        }
-        emotionViewModel?.sendEmotion(roomId, emotionInfo.id, scene)
-            ?.observe(viewLifecycleOwner) { rlt ->
-                when (rlt) {
-                    is Rlt.Success -> hideEmotionQuickTextPanel()
-                    else -> showFailedToast(rlt)
-                }
-            }
-    }
-
-    fun switchEmotionQuickTextPanel(data: ClickEmotionOpData) {
-        if (isShow()) {
-            hideEmotionQuickTextPanel()
-        } else {
-            initEmotionBtn(data.position, data.size)
-            showEmotionQuickTextPanel(data)
-        }
-    }
-
-    private fun initEmotionBtn(position: CocosPosition, size: CocosViewSize) {
-        vEmotion.updateLayoutParams<LayoutParams> {
-            width = size.width.toInt()
-            height = size.height.toInt()
-            leftMargin = (position.x - size.width / 2).toInt()
-            bottomMargin = (position.y - size.height / 2).toInt()
-        }
-    }
-
-    private fun showEmotionQuickTextPanel(data: ClickEmotionOpData) {
-        hideEmotionQuickTextPanel()
-        quickChatFragment =
-            QuickChatFragment.newInstance(data).also {
-                it.setHidePanelCallback {
-                    hideEmotionQuickTextPanel()
-                }
-            }
-        fragmentManager
-            .beginTransaction()
-            .replace(panelContainer.id, quickChatFragment!!)
-            .commitAllowingStateLoss()
-    }
-
-    fun isShow(): Boolean {
-        return quickChatFragment != null
-    }
-
-    fun hideEmotionQuickTextPanel() {
-        quickChatFragment?.let {
-            fragmentManager
-                .beginTransaction()
-                .remove(it)
-                .commitAllowingStateLoss()
-        }
-        quickChatFragment = null
-    }
-
-    private fun isQuickChatBubbleShow(uid: Long): Boolean {
-        val emotionBubbleBinding = player2EmotionBubble[uid]
-        if (emotionBubbleBinding != null && emotionBubbleBinding.second.isVisible) {
-            return true
-        }
-
-        val quickTextBubbleBinding = player2QuickTextBubble[uid]
-        return quickTextBubbleBinding != null && quickTextBubbleBinding.second.isVisible
-    }
-
-    private fun addQuickChatBubble(quickChatBubble: QuickChatBubble) {
-        val uid = quickChatBubble.uid
-        var queue = player2BubbleQueue[uid]
-        if (queue == null) {
-            queue = LinkedList()
-            player2BubbleQueue[uid] = queue
-        }
-        queue.offer(quickChatBubble)
-        if (isQuickChatBubbleShow(uid)) {
-            return
-        }
-
-        showNextQuickChatBubble(uid)
-    }
-
-    private fun showNextQuickChatBubble(uid: Long) {
-        val queue = player2BubbleQueue[uid]
-        val bubble = queue?.poll() ?: return
-        when (bubble) {
-            is EmotionBubble -> showEmotionBubble(bubble)
-            is QuickTextBubble -> showQuickTextBubble(bubble)
-        }
-    }
-
-    private fun showEmotionBubble(bubble: EmotionBubble) {
-        Log.d(TAG_COCOS_GAME_FLOW, "showEmotionBubble, $bubble")
-        val uid = bubble.uid
-        val cacheView = player2EmotionBubble[uid]
-        if (cacheView != null) {
-            playEmotionBubbleEffect(
-                getEmotionEffectView(cacheView.first, cacheView.second),
-                bubble,
-                onStart = {
-                    if (isValid) {
-                        cacheView.second.show()
-                    }
-                },
-                onComplete = {
-                    if (isValid) {
-                        cacheView.second.gone()
-                    }
-                },
-                onError = {
-                    if (isValid) {
-                        cacheView.second.gone()
-                    }
-                })
-            return
-        }
-
-        cocosViewModel?.getPlayerAvatarView(uid)?.observe(this.lifecycleOwner) {
-            Log.d(TAG_COCOS_GAME_FLOW, "getPlayerAvatarView, uid:$uid, data:${it}")
-            if (it is Rlt.Success) {
-                val position = it.data.position
-                val size = it.data.size
-                val location = getBubbleLocation(it.data)
-
-                //1.添加一个辅助View
-                var avatarGuideView = emotionContainer.findViewWithTag<View>("playerAvatar_$uid")
-                if (avatarGuideView == null) {
-                    avatarGuideView = View(context).apply {
-                        id = View.generateViewId()
-                        tag = "playerAvatar_$uid"
-                        background = getCompatDrawable(R.drawable.common_33000000_radius_12_bg)
-                    }
-                    emotionContainer.addView(avatarGuideView)
-                }
-                avatarGuideView.updateLayoutParams<LayoutParams> {
-                    width = size.width.toInt()
-                    height = size.height.toInt()
-                    leftToLeft = LayoutParams.PARENT_ID
-                    bottomToBottom = LayoutParams.PARENT_ID
-                    leftMargin = (position.x - size.width / 2).toInt()
-                    bottomMargin = (position.y - size.height / 2).toInt()
-                }
-
-                //2.添加气泡
-                val bubbleView = when (location) {
-                    CocosViewLocation.TOP,
-                    CocosViewLocation.TOP_LEFT,
-                    CocosViewLocation.TOP_RIGHT -> {
-                        LayoutCocosgameEmotionBubbleTopBinding.inflate(
-                            LayoutInflater.from(context),
-                            emotionContainer,
-                            true
-                        ).root.also { root ->
-                            root.updateLayoutParams<LayoutParams> {
-                                leftToLeft = avatarGuideView.id
-                                rightToRight = avatarGuideView.id
-                                topToBottom = avatarGuideView.id
-                            }
-                        }
-                    }
-
-                    CocosViewLocation.CENTER,
-                    CocosViewLocation.BOTTOM,
-                    CocosViewLocation.BOTTOM_LEFT,
-                    CocosViewLocation.BOTTOM_RIGHT -> {
-                        LayoutCocosgameEmotionBubbleBottomBinding.inflate(
-                            LayoutInflater.from(context),
-                            emotionContainer,
-                            true
-                        ).root.also { root ->
-                            root.updateLayoutParams<LayoutParams> {
-                                leftToLeft = avatarGuideView.id
-                                rightToRight = avatarGuideView.id
-                                bottomToTop = avatarGuideView.id
-                            }
-                        }
-                    }
-
-                    CocosViewLocation.LEFT -> {
-                        LayoutCocosgameEmotionBubbleLeftBinding.inflate(
-                            LayoutInflater.from(context),
-                            emotionContainer,
-                            true
-                        ).root.also { root ->
-                            root.updateLayoutParams<LayoutParams> {
-                                leftToRight = avatarGuideView.id
-                                topToTop = avatarGuideView.id
-                                bottomToBottom = avatarGuideView.id
-                            }
-                        }
-                    }
-
-                    CocosViewLocation.RIGHT -> {
-                        LayoutCocosgameEmotionBubbleRightBinding.inflate(
-                            LayoutInflater.from(context),
-                            emotionContainer,
-                            true
-                        ).root.also { root ->
-                            root.updateLayoutParams<LayoutParams> {
-                                rightToLeft = avatarGuideView.id
-                                topToTop = avatarGuideView.id
-                                bottomToBottom = avatarGuideView.id
-                            }
-                        }
-                    }
-                }
-                player2EmotionBubble[uid] = Pair(location, bubbleView)
-                playEmotionBubbleEffect(
-                    getEmotionEffectView(location, bubbleView),
-                    bubble,
-                    onStart = {
-                        if (isValid) {
-                            bubbleView.show()
-                        }
-                    },
-                    onComplete = {
-                        if (isValid) {
-                            bubbleView.gone()
-                        }
-                    },
-                    onError = {
-                        if (isValid) {
-                            bubbleView.gone()
-                        }
-                    }
-                )
-            } else {
-                showNextQuickChatBubble(uid)
-            }
-        }
-    }
-
-    private fun getEmotionEffectView(location: CocosViewLocation, view: View): EffectView {
-        return when (location) {
-            CocosViewLocation.TOP,
-            CocosViewLocation.TOP_LEFT,
-            CocosViewLocation.TOP_RIGHT -> {
-                LayoutCocosgameEmotionBubbleTopBinding.bind(view).evEmotion
-            }
-
-            CocosViewLocation.CENTER,
-            CocosViewLocation.BOTTOM,
-            CocosViewLocation.BOTTOM_LEFT,
-            CocosViewLocation.BOTTOM_RIGHT -> {
-                LayoutCocosgameEmotionBubbleTopBinding.bind(view).evEmotion
-            }
-
-            CocosViewLocation.LEFT -> {
-                LayoutCocosgameEmotionBubbleLeftBinding.bind(view).evEmotion
-            }
-
-            CocosViewLocation.RIGHT -> {
-                LayoutCocosgameEmotionBubbleRightBinding.bind(view).evEmotion
-            }
-        }
-    }
-
-    private fun playEmotionBubbleEffect(
-        effectView: EffectView,
-        bubble: EmotionBubble,
-        onStart: () -> Unit,
-        onComplete: () -> Unit,
-        onError: () -> Unit
-    ) {
-        Log.d(TAG_COCOS_GAME_FLOW, "playEmotionBubbleEffect, $bubble")
-        val uid = bubble.uid
-        val emotion = bubble.emotion
-        val effectPath = EmotionModule.getEmotionAnimationResPath(emotion)
-        if (effectPath.isNullOrEmpty()) {
-            showNextQuickChatBubble(uid)
-            return
-        }
-        onStart.invoke()
-        effectView.add(
-            EmotionEffectEntity(
-                path = effectPath,
-                emotionInfo = emotion,
-                loop = 0,
-                resultIndex = bubble.resultIndex,
-                showAvatarMask = false,
-                showResultOnly = false,
-                playListener = object : IPlayListener {
-
-                    override fun onComplete() {
-                        onComplete.invoke()
-                        showNextQuickChatBubble(uid)
-                    }
-
-                    override fun onError(errCode: Int) {
-                        onError.invoke()
-                        showNextQuickChatBubble(uid)
-                    }
-
-                }
-            )
-        )
-    }
-
-    private fun showQuickTextBubble(bubble: QuickTextBubble) {
-        val uid = bubble.uid
-        val cacheView = player2QuickTextBubble[uid]
-        if (cacheView != null) {
-            showQuickTextBubble(
-                getQuickChatTextView(cacheView.first, cacheView.second),
-                bubble,
-                onStart = {
-                    if (isValid) {
-                        cacheView.second.show()
-                    }
-                },
-                onComplete = {
-                    if (isValid) {
-                        cacheView.second.gone()
-                    }
-                }
-            )
-            return
-        }
-
-        cocosViewModel?.getPlayerAvatarView(uid)?.observe(this.lifecycleOwner) {
-            Log.d(TAG_COCOS_GAME_FLOW, "getPlayerAvatarView, uid:$uid, data:${it}")
-            if (it is Rlt.Success) {
-                val position = it.data.position
-                val size = it.data.size
-                val location = getBubbleLocation(it.data)
-
-                //1.添加一个辅助View
-                var avatarGuideView = emotionContainer.findViewWithTag<View>("playerAvatar_$uid")
-                if (avatarGuideView == null) {
-                    avatarGuideView = View(context).apply {
-                        id = View.generateViewId()
-                        tag = "playerAvatar_$uid"
-                    }
-                    emotionContainer.addView(avatarGuideView)
-                }
-                avatarGuideView.updateLayoutParams<LayoutParams> {
-                    width = size.width.toInt()
-                    height = size.height.toInt()
-                    leftToLeft = LayoutParams.PARENT_ID
-                    bottomToBottom = LayoutParams.PARENT_ID
-                    leftMargin = (position.x - size.width / 2).toInt()
-                    bottomMargin = (position.y - size.height / 2).toInt()
-                }
-
-                //2.添加气泡
-                val bubbleView = when (location) {
-                    CocosViewLocation.TOP,
-                    CocosViewLocation.TOP_LEFT,
-                    CocosViewLocation.TOP_RIGHT -> {
-                        LayoutCocosgameQuickTextBubbleTopBinding.inflate(
-                            LayoutInflater.from(context),
-                            emotionContainer,
-                            true
-                        ).root.also { root ->
-                            root.updateLayoutParams<LayoutParams> {
-                                topToBottom = avatarGuideView.id
-                                leftToLeft = avatarGuideView.id
-                                rightToRight = avatarGuideView.id
-                            }
-                        }
-                    }
-
-                    CocosViewLocation.BOTTOM,
-                    CocosViewLocation.CENTER,
-                    CocosViewLocation.BOTTOM_LEFT,
-                    CocosViewLocation.BOTTOM_RIGHT -> {
-                        LayoutCocosgameQuickTextBubbleBottomBinding.inflate(
-                            LayoutInflater.from(context),
-                            emotionContainer,
-                            true
-                        ).root.also { root ->
-                            root.updateLayoutParams<LayoutParams> {
-                                bottomToTop = avatarGuideView.id
-                                leftToLeft = avatarGuideView.id
-                                rightToRight = avatarGuideView.id
-                            }
-                        }
-                    }
-
-                    CocosViewLocation.LEFT -> {
-                        LayoutCocosgameQuickTextBubbleLeftBinding.inflate(
-                            LayoutInflater.from(context),
-                            emotionContainer,
-                            true
-                        ).root.also { root ->
-                            root.updateLayoutParams<LayoutParams> {
-                                leftToRight = avatarGuideView.id
-                                topToTop = avatarGuideView.id
-                                bottomToBottom = avatarGuideView.id
-                            }
-                        }
-                    }
-
-                    CocosViewLocation.RIGHT -> {
-                        LayoutCocosgameQuickTextBubbleRightBinding.inflate(
-                            LayoutInflater.from(context),
-                            emotionContainer,
-                            true
-                        ).root.also { root ->
-                            root.updateLayoutParams<LayoutParams> {
-                                rightToLeft = avatarGuideView.id
-                                topToTop = avatarGuideView.id
-                                bottomToBottom = avatarGuideView.id
-                            }
-                        }
-                    }
-                }
-                player2QuickTextBubble[uid] = Pair(location, bubbleView)
-                showQuickTextBubble(
-                    getQuickChatTextView(location, bubbleView),
-                    bubble,
-                    onStart = {
-                        if (isValid) {
-                            bubbleView.show()
-                        }
-                    },
-                    onComplete = {
-                        if (isValid) {
-                            bubbleView.gone()
-                        }
-                    }
-                )
-            } else {
-                showNextQuickChatBubble(uid)
-            }
-        }
-    }
-
-    private fun getQuickChatTextView(location: CocosViewLocation, view: View): TextView {
-        return when (location) {
-            CocosViewLocation.TOP,
-            CocosViewLocation.TOP_LEFT,
-            CocosViewLocation.TOP_RIGHT -> {
-                LayoutCocosgameQuickTextBubbleTopBinding.bind(view).tvText
-            }
-
-            CocosViewLocation.BOTTOM,
-            CocosViewLocation.CENTER,
-            CocosViewLocation.BOTTOM_LEFT,
-            CocosViewLocation.BOTTOM_RIGHT -> {
-                LayoutCocosgameQuickTextBubbleBottomBinding.bind(view).tvText
-            }
-
-            CocosViewLocation.LEFT -> {
-                LayoutCocosgameQuickTextBubbleLeftBinding.bind(view).tvText
-            }
-
-            CocosViewLocation.RIGHT -> {
-                LayoutCocosgameQuickTextBubbleRightBinding.bind(view).tvText
-            }
-        }
-    }
-
-    private fun showQuickTextBubble(
-        quickChatText: TextView,
-        bubble: QuickTextBubble,
-        onStart: () -> Unit,
-        onComplete: () -> Unit
-    ) {
-        val uid = bubble.uid
-        val text = bubble.quickText
-        onStart.invoke()
-        quickChatText.text = text.getText()
-        runOnUiThread({
-            onComplete.invoke()
-            showNextQuickChatBubble(uid)
-        }, 3000)
-    }
-
-    private fun getBubbleLocation(data: CocosViewData): CocosViewLocation {
-        val l = data.location
-        if (l != null) {
-            return CocosViewLocation.map(l) ?: CocosViewLocation.BOTTOM
-        }
-        val position = data.position
-        var location = 0
-        location = if (position.x > DisplayUtil.getScreenWidth() / 2) {
-            location or CocosViewLocation.RIGHT.location
-        } else {
-            location or CocosViewLocation.LEFT.location
-        }
-
-        location = if (position.y > DisplayUtil.getScreenHeight() / 2) {
-            location or Gravity.BOTTOM
-        } else {
-            location or Gravity.TOP
-        }
-        return CocosViewLocation.map(location) ?: CocosViewLocation.BOTTOM
-    }
-
-    fun clear() {
-        player2EmotionBubble.clear()
-        player2QuickTextBubble.clear()
-        player2BubbleQueue.clear()
-    }
-
-}

+ 0 - 20
app/src/main/java/com/adealink/weparty/cocosgame/chat/data/Data.kt

@@ -1,20 +0,0 @@
-package com.adealink.weparty.cocosgame.chat.data
-
-import com.adealink.weparty.cocosgame.data.QuickText
-import com.adealink.weparty.module.emotion.data.EmotionInfo
-import com.google.gson.annotations.SerializedName
-
-sealed class QuickChatBubble(open val uid: Long)
-
-data class QuickTextBubble(override val uid: Long, val quickText: QuickText) : QuickChatBubble(uid)
-
-data class EmotionBubble(override val uid: Long, val emotion: EmotionInfo, val resultIndex: Int) :
-    QuickChatBubble(uid)
-
-data class SendMessageReq(
-    @SerializedName("type") val type: String,
-    @SerializedName("roomId") val roomId: Long,
-    @SerializedName("ts") val ts: Long,
-    @SerializedName("content") val content: String,
-)
-

+ 0 - 16
app/src/main/java/com/adealink/weparty/cocosgame/chat/datasource/remote/ChatSocketService.kt

@@ -1,16 +0,0 @@
-package com.adealink.weparty.cocosgame.chat.datasource.remote
-
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.network.data.Res
-import com.adealink.frame.network.socket.annotation.Uri
-import com.adealink.weparty.cocosgame.chat.data.SendMessageReq
-import retrofit2.http.Body
-import retrofit2.http.Core
-
-interface ChatSocketService {
-
-    @Core
-    @Uri("TEXT_REQUEST")
-    suspend fun sendMessage(@Body req: SendMessageReq): Rlt<Res<Any>>
-
-}

+ 0 - 119
app/src/main/java/com/adealink/weparty/cocosgame/chat/fragment/QuickChatFragment.kt

@@ -1,119 +0,0 @@
-package com.adealink.weparty.cocosgame.chat.fragment
-
-import android.os.Build
-import android.os.Bundle
-import androidx.constraintlayout.widget.ConstraintLayout
-import androidx.core.view.updateLayoutParams
-import androidx.fragment.app.activityViewModels
-import androidx.recyclerview.widget.GridLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import com.adealink.frame.aab.util.getCompatDimension
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.base.fastLazy
-import com.adealink.frame.mvvm.view.viewBinding
-import com.adealink.frame.router.Router
-import com.adealink.weparty.R
-import com.adealink.weparty.cocosgame.chat.adapter.QuickTextViewBinder
-import com.adealink.weparty.cocosgame.chat.listener.IChatOperateListener
-import com.adealink.weparty.cocosgame.chat.viewmodel.QuickChatViewModel
-import com.adealink.weparty.cocosgame.data.ClickEmotionOpData
-import com.adealink.weparty.cocosgame.data.CocosRoomType
-import com.adealink.weparty.cocosgame.data.QuickText
-import com.adealink.weparty.commonui.BaseFragment
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.commonui.ext.dp
-import com.adealink.weparty.commonui.recycleview.adapter.MultiTypeListAdapter
-import com.adealink.weparty.commonui.recycleview.diffutil.BaseListDiffUtil
-import com.adealink.weparty.commonui.recycleview.itemdecoration.GridSpacingItemDecoration
-import com.adealink.weparty.commonui.toast.util.showFailedToast
-import com.adealink.weparty.databinding.FragmentCocosgameEmotionQuickTextBinding
-import com.adealink.weparty.module.emotion.Emotion
-import com.adealink.weparty.module.room.Room
-import com.adealink.weparty.module.room.RoomModule
-import com.adealink.weparty.module.room.chat.data.Message
-import com.adealink.weparty.module.room.chat.data.MessageType
-import com.adealink.weparty.module.room.chat.data.QuickMsgContent
-import com.adealink.weparty.module.room.data.SendEmotionScene
-
-class QuickChatFragment : BaseFragment(R.layout.fragment_cocosgame_emotion_quick_text), IChatOperateListener {
-
-    companion object {
-
-        const val EXTRA_COCOS_EMOTION_CLICK_OP_DATA = "extra_cocos_emotion_click_op_data"
-
-        fun newInstance(
-            data: ClickEmotionOpData
-        ): QuickChatFragment {
-            return QuickChatFragment().apply {
-                arguments = Bundle().apply {
-                    putParcelable(EXTRA_COCOS_EMOTION_CLICK_OP_DATA, data)
-                }
-            }
-        }
-
-    }
-
-    private val binding by viewBinding(FragmentCocosgameEmotionQuickTextBinding::bind)
-    private val chatMessageViewModel by fastLazy { RoomModule.getChatMessageViewModel(requireActivity()) }
-    private val quickChatViewModel by activityViewModels<QuickChatViewModel>()
-    private val quickTextAdapter by fastLazy { MultiTypeListAdapter(BaseListDiffUtil()) }
-
-    private var hidePanelCallback: (() -> Unit)? = null
-
-    fun setHidePanelCallback(callback: () -> Unit) {
-        this.hidePanelCallback = callback
-    }
-
-    override fun initViews() {
-        super.initViews()
-        val clickOpData = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
-            arguments?.getParcelable(EXTRA_COCOS_EMOTION_CLICK_OP_DATA, ClickEmotionOpData::class.java)
-        } else {
-            arguments?.getParcelable(EXTRA_COCOS_EMOTION_CLICK_OP_DATA)
-        }
-        clickOpData?.let {
-            val leftMargin = (it.position.x - it.size.width / 2).toInt() - getCompatDimension(R.dimen.cocos_game_quick_chat_margin_left).toInt()
-            binding.ivBottomArrow.updateLayoutParams<ConstraintLayout.LayoutParams> {
-                this.leftMargin = leftMargin
-            }
-        }
-
-        quickTextAdapter.register(QuickTextViewBinder(this))
-        binding.rcQuickText.layoutManager = GridLayoutManager(
-            context,
-            QuickTextViewBinder.SPAN_COUNT,
-            RecyclerView.VERTICAL,
-            false
-        )
-        binding.rcQuickText.addItemDecoration(
-            GridSpacingItemDecoration(QuickTextViewBinder.SPAN_COUNT, 6.dp(), 6.dp(), false)
-        )
-        binding.rcQuickText.adapter = quickTextAdapter
-        if (childFragmentManager.findFragmentByTag(Room.RoomGameEmotionPanel.TAG) == null) {
-            val fragment =
-                Router.getRouterInstance<BaseDialogFragment>(Emotion.EmotionPanel.PATH) ?: return
-            childFragmentManager.beginTransaction()
-                .replace(R.id.fcv_emotion, fragment)
-                .commit()
-        }
-    }
-
-    override fun loadData() {
-        super.loadData()
-        quickChatViewModel.getQuickText().observe(viewLifecycleOwner) {
-            quickTextAdapter.submitList(it)
-        }
-    }
-
-    override fun onQuickTextClick(quickText: QuickText) {
-        chatMessageViewModel?.sendChatMessage(
-            Message.crateMessage(MessageType.QUICK_MESSAGE, QuickMsgContent(quickText))
-        )?.observe(viewLifecycleOwner) {
-            when (it) {
-                is Rlt.Success -> hidePanelCallback?.invoke()
-                is Rlt.Failed -> showFailedToast(it)
-            }
-        }
-    }
-
-}

+ 0 - 9
app/src/main/java/com/adealink/weparty/cocosgame/chat/listener/IChatOperateListener.kt

@@ -1,9 +0,0 @@
-package com.adealink.weparty.cocosgame.chat.listener
-
-import com.adealink.weparty.cocosgame.data.QuickText
-
-interface IChatOperateListener {
-
-    fun onQuickTextClick(quickText: QuickText) {}
-
-}

+ 0 - 24
app/src/main/java/com/adealink/weparty/cocosgame/chat/viewmodel/QuickChatViewModel.kt

@@ -1,24 +0,0 @@
-package com.adealink.weparty.cocosgame.chat.viewmodel
-
-import androidx.lifecycle.LiveData
-import com.adealink.frame.mvvm.livedata.OnceMutableLiveData
-import com.adealink.frame.mvvm.viewmodel.BaseViewModel
-import com.adealink.weparty.cocosgame.data.QuickText
-import com.adealink.weparty.config.GlobalConfigType
-import com.adealink.weparty.config.globalConfigManager
-import kotlinx.coroutines.launch
-
-class QuickChatViewModel:BaseViewModel() {
-
-    fun getQuickText(): LiveData<List<QuickText>> {
-        val liveData = OnceMutableLiveData<List<QuickText>>()
-        viewModelScope.launch {
-            val quickTextList = globalConfigManager.suspendGetConfigList(
-                GlobalConfigType.GLOBAL_GAME_QUICK_MESSAGE,
-                QuickText::class.java
-            )
-            liveData.send(quickTextList)
-        }
-        return liveData
-    }
-}

+ 0 - 181
app/src/main/java/com/adealink/weparty/cocosgame/comp/CoinsCollectAnimComp.kt

@@ -1,181 +0,0 @@
-package com.adealink.weparty.cocosgame.comp
-
-import android.content.Context
-import android.graphics.PointF
-import android.view.LayoutInflater
-import android.view.View
-import android.widget.FrameLayout
-import androidx.core.view.updateLayoutParams
-import androidx.lifecycle.LifecycleOwner
-import com.adealink.frame.log.Log
-import com.adealink.frame.mvvm.view.ViewComponent
-import com.adealink.frame.util.getCenterLocationInWindow
-import com.adealink.frame.util.runOnUiThread
-import com.adealink.weparty.App
-import com.adealink.weparty.commonui.ext.dp
-import com.adealink.weparty.commonui.ext.gone
-import com.adealink.weparty.commonui.ext.show
-import com.adealink.weparty.commonui.widget.CollectCoinView
-import com.adealink.weparty.commonui.widget.CollectPathAnimView
-import com.adealink.weparty.databinding.LayoutCoinsCollectAnimBinding
-import com.adealink.weparty.module.sound.data.Sound
-import com.opensource.svgaplayer.SVGACallback
-import kotlin.math.max
-
-class CoinsCollectAnimComp(
-    lifecycleOwner: LifecycleOwner,
-    private val container: FrameLayout
-) : ViewComponent(lifecycleOwner) {
-
-    private var binding: LayoutCoinsCollectAnimBinding = LayoutCoinsCollectAnimBinding.inflate(LayoutInflater.from(context), container, true)
-
-    private val animViewCreator = object : CollectPathAnimView.CollectViewCreator {
-        override fun createCollectView(context: Context): View {
-            return CollectCoinView(context)
-        }
-    }
-
-    override fun onCreate() {
-        super.onCreate()
-        initViews()
-    }
-
-    private fun initViews() {
-        binding.root.updateLayoutParams<FrameLayout.LayoutParams> {
-            width = FrameLayout.LayoutParams.MATCH_PARENT
-            height = FrameLayout.LayoutParams.MATCH_PARENT
-        }
-        binding.svgaCoins.updateLayoutParams<FrameLayout.LayoutParams> {
-            width = 190.dp()
-            height = 190.dp()
-        }
-        binding.svgaCoins.callback = object : SVGACallback {
-            override fun onFinished() {
-                runOnUiThread {
-                    binding.svgaCoins.gone()
-                }
-            }
-        }
-    }
-
-    fun playCollectAnim(onFinish: () -> Unit, endView: View, vararg startViews: View) {
-        val endPosition = endView.getCenterLocationInWindow()
-        val startPositions = startViews.map {
-            val startPosition = it.getCenterLocationInWindow()
-            PointF(
-                startPosition[0].toFloat(),
-                startPosition[1].toFloat()
-            )
-        }.toTypedArray()
-
-        reset()
-        playCollectAnimInner(
-            onFinish,
-            PointF(
-                endPosition[0].toFloat(),
-                endPosition[1].toFloat()
-            ),
-            *startPositions,
-        )
-    }
-
-    /**
-     * @param endPosition 终点坐标位置
-     * @param startPositions 起点坐标位置(可以设置多个起点)
-     */
-    private fun playCollectAnimInner(onFinish: () -> Unit, endPosition: PointF, vararg startPositions: PointF) {
-        Log.d(TAG, "playCollectAnim, endPosition:(${endPosition.x}, ${endPosition.y})")
-        startPositions.forEach { startPosition ->
-            val animView = generateAnimView(startPosition, endPosition)
-            binding.flAnim.addView(animView)
-            animView.updateLayoutParams<FrameLayout.LayoutParams> {
-                width = FrameLayout.LayoutParams.MATCH_PARENT
-                height = FrameLayout.LayoutParams.MATCH_PARENT
-            }
-        }
-        App.instance.soundPlayer.play(Sound.COINS_COLLECT.soundName)
-        for (i in 0 until binding.flAnim.childCount) {
-            val animView = binding.flAnim.getChildAt(i) as? CollectPathAnimView ?: continue
-            if (i == 0) {
-                //用第一个动画做监听
-                animView.setAnimListener(object : CollectPathAnimView.ICollectAnimListener {
-                    override fun onStart(position: Int) {
-                        Log.d(TAG, "playCollectAnim, onStart:$position")
-                        if (position == 0) {
-                            //第一个金币到达路径终点,开始显示金币撒花动画
-                            playCoinsCollectEffect(endPosition)
-                        }
-                    }
-
-                    override fun onUpdate(view: View, position: Int, percent: Float) {
-                        if (percent > 0.8f) {
-                            (view as? CollectCoinView)?.showFlashAnim()
-                        }
-                    }
-
-                    override fun onEnd(position: Int) {
-                        Log.d(TAG, "playCollectAnim, onEnd:$position")
-//                        if (position == 0) {
-//                            //第一个金币到达路径终点,开始显示金币撒花动画
-//                            playCoinsCollectEffect(endPosition)
-//                        }
-                    }
-
-                    override fun onFinish() {
-                        Log.d(TAG, "playCollectAnim, onFinish")
-                    }
-                })
-            } else {
-                animView.setAnimListener(null)
-            }
-            animView.startAnim()
-        }
-        //所有动画的时长
-        val allAnimDuration = max(
-            PATH_ANIM_DURATION + COINS_COLLECT_EFFECT_DURATION,
-            PATH_ANIM_DURATION + (COLLECT_COUNT - 1) * PATH_ANIM_OFFSET_DURATION
-        )
-        binding.root.postDelayed({
-            Log.d(TAG, "playCollectAnim, onFinish.invoke()")
-            onFinish.invoke()
-        }, allAnimDuration)
-    }
-
-    private fun generateAnimView(start: PointF, end: PointF): CollectPathAnimView {
-        val animView = CollectPathAnimView(binding.flAnim.context)
-        animView.setCollectCount(COLLECT_COUNT)
-        animView.setMaxAnimCount(6)
-        animView.setDuration(PATH_ANIM_DURATION)
-        animView.setOffsetDuration(PATH_ANIM_OFFSET_DURATION)
-        animView.setCollectViewCreator(animViewCreator, COLLECT_COIN_VIEW_WIDTH)
-        animView.setPath(start, end)
-        return animView
-    }
-
-    private fun playCoinsCollectEffect(endPosition: PointF) {
-        Log.d(TAG, "playCoinsCollectEffect, endPosition:(${endPosition.x}, ${endPosition.y})")
-        binding.svgaCoins.show()
-        binding.svgaCoins.x = endPosition.x - binding.svgaCoins.layoutParams.width / 2
-        binding.svgaCoins.y = endPosition.y - binding.svgaCoins.layoutParams.height / 2
-        binding.svgaCoins.setAsset("cocosgame_coins_collect_effect.svga")
-    }
-
-    private fun reset() {
-        binding.root.removeCallbacks(null)
-        binding.flAnim.removeAllViews()
-        binding.svgaCoins.stopAnimation()
-        binding.svgaCoins.gone()
-    }
-
-    companion object {
-        private const val TAG = "CoinsCollectAnimComp"
-
-        private val COLLECT_COIN_VIEW_WIDTH = 48.dp()
-
-        private const val COLLECT_COUNT = 10 //收集的金币数量
-        private const val PATH_ANIM_DURATION = 500L //(单个)金币路径动画时长
-        private const val PATH_ANIM_OFFSET_DURATION = 80L //每个金币动画时间间隔
-        private const val COINS_COLLECT_EFFECT_DURATION = 1900L //金币撒花动效时长
-    }
-
-}

+ 0 - 39
app/src/main/java/com/adealink/weparty/cocosgame/data/CocosDialogData.kt

@@ -1,39 +0,0 @@
-package com.adealink.weparty.cocosgame.data
-
-import com.google.gson.annotations.SerializedName
-
-/*
- * Cocos游戏弹窗
- */
-
-//@JsonAdapter(DialogParser::class)
-//class Dialog(@SerializedName("type") val type: DialogType) {
-//    @SerializedName("id")
-//    var id: Long = 0
-//
-//    @SerializedName("data")
-//    var data: DialogData? = null
-//}
-
-open class DialogData(var id: Long = 0, var players: Map<Long, GamePlayerInfo> = hashMapOf())
-
-/**
- * 未知弹窗类型
- */
-class UnknownDialogData : DialogData() {
-    override fun toString(): String {
-        return "UnknownDialogData()"
-    }
-}
-
-/**
- * 退出游戏确认弹窗
- */
-data class ExitGameDialogData(@SerializedName("game_record") val gameRecord: String) :
-    DialogData() {
-    override fun toString(): String {
-        return "ExitGameDialogData(gameRecord='$gameRecord')"
-    }
-}
-
-data class CurrencyInsufficientDialogData(@SerializedName("type") val type: Int) : DialogData()

+ 0 - 401
app/src/main/java/com/adealink/weparty/cocosgame/data/CocosGameData.kt

@@ -1,401 +0,0 @@
-package com.adealink.weparty.cocosgame.data
-
-import android.os.Parcelable
-import com.adealink.frame.aab.util.getCompatString
-import com.adealink.frame.base.AppBase
-import com.adealink.frame.locale.language.data.Language
-import com.adealink.frame.locale.language.languageManager
-import com.adealink.frame.util.PackageUtil
-import com.adealink.weparty.R
-import com.adealink.weparty.commonui.recycleview.diffutil.BaseListItemData
-import com.adealink.weparty.module.account.AccountModule
-import com.adealink.weparty.module.profile.data.UserInfo
-import com.adealink.weparty.module.rank.data.RankListItemData
-import com.google.gson.annotations.GsonNullable
-import com.google.gson.annotations.Must
-import com.google.gson.annotations.SerializedName
-import kotlinx.parcelize.Parcelize
-
-data class GameStartNotify(
-    @SerializedName("seqid") val seqId: Long,
-    @Must
-    @SerializedName("channel") val channel: String,
-    @Must
-    @SerializedName("gameId") val gameId: String,
-    @Must
-    @SerializedName("gamePlayers") val gamePlayers: List<GamePlayerInfo>,
-    @SerializedName("gameMeta") val gameMeta: String,
-    @SerializedName("gameType") val game: Int, //参考: Game
-    @SerializedName("gameMode") val gameMode: Int,
-    @SerializedName("gameFee") val gameFee: Int, //游戏参与费用,0表示免费游戏 >0表示加入游戏的花费
-    @SerializedName("magicMode") val magicMode: Int, //0:关闭道具模式,1:开启道具模式
-    @SerializedName("maxPlayerCount") val maxPlayerCount: Int, //最大玩家数量
-    @SerializedName("gameRoomType") val gameType: Int, //参考 LudoGameType, CarromGameType
-    @SerializedName("startRoomType") val cocosRoomType: Int,
-    @SerializedName("createTime") val createTime: Long, //游戏创建时间
-    @SerializedName("gameCreator") val gameCreator: Long, //游戏发起者ID
-    @SerializedName("gameState") val gameState: Int,//游戏状态,0:准备,1:进行中,2:游戏结束
-    @SerializedName("gameRewardInfoList") val gameRewardInfoList: List<GameRewardData> = listOf(),
-) {
-
-    fun toGameConfigInfo(): GameConfigInfo {
-        return GameConfigInfo(
-            game = game,
-            gameType = gameType,
-            gameMode = gameMode,
-            magicMode = magicMode,
-            maxPlayerCount = maxPlayerCount,
-            cocosRoomType = cocosRoomType,
-            gameFee = gameFee
-        )
-    }
-
-    fun toStartGameData(roomId: Long): StartGameData {
-        return StartGameData(
-            roomId,
-            channel,
-            gameId,
-            AccountModule.uid,
-            gameMeta,
-            gamePlayers,
-            cocosRoomType = cocosRoomType,
-            gameCreator = gameCreator,
-            gameConfig = toGameConfigInfo()
-        )
-    }
-
-}
-
-data class JoinCodeReq(
-    @SerializedName("teamCode") val teamCode: String,
-    @SerializedName("gameRoomType") val gameType: Int
-)
-
-data class ExitGameReq(
-    @SerializedName("roomId") val roomId: Long,
-
-    @SerializedName("gameId") val gameId: String? = null,
-    @SerializedName("teamCode") val teamCode: String? = null,
-    @SerializedName("gameType") val gameType: Int? = null,
-    @SerializedName("seqid") val seqId: Long = System.currentTimeMillis()
-)
-
-data class CreateGameRes(
-    @SerializedName("gameConfigInfo") val gameConfigInfo: GameConfigInfo,
-    @SerializedName("gameExpireTime") val gameExpireTime: Long,
-    @SerializedName("teamCode") val teamCode: String,
-    @SerializedName("channel") val channel: Long,
-)
-
-data class JoinRoomRes(
-    @SerializedName("token") val token: String,
-    @SerializedName("rtcType") val rtcType: Int = 0
-)
-
-enum class LeaveRoomReason(val reason: String) {
-    INITIATIVE("initiative"),
-}
-
-
-data class JoinRoomReq(
-    @SerializedName("roomId") val roomId: Long,
-    @SerializedName("versionCode") val versionCode: Int = PackageUtil.getVersionCode(),
-    @SerializedName("platform") val platform: String = AppBase.platform,
-    @SerializedName("packageName") val packageName: String = PackageUtil.getPackageName(),
-)
-
-data class LeaveRoomReq(
-    @SerializedName("roomId") val roomId: Long
-)
-
-data class GamePlayersInfo(
-    val players: List<GamePlayerInfo>,
-    val groupId: Int? = null
-)
-
-data class GameConfigReq(@SerializedName("gameConfigInfo") val gameConfigInfo: GameConfigInfo)
-
-@Parcelize
-data class GameInviteNotify(
-    @SerializedName("teamCode") val teamCode: String,
-    @Must
-    @SerializedName("inviterInfo") val inviterUser: UserInfo, //邀请方
-    @SerializedName("groupId") val groupId: Int,
-    @Must
-    @SerializedName("gameConfigInfo") val gameConfigInfo: GameConfigInfo,
-    @SerializedName("micSeat") val micSeat: Int,
-    @SerializedName("roomId") val roomId: Long,
-) : Parcelable
-
-@Parcelize
-data class PlayerChangedNotify(
-    @Must
-    @SerializedName("seqid") val seqId: Long,
-    @Must
-    @SerializedName("gamePlayerInfoList") val gamePlayerInfoList: List<GamePlayerInfo>,
-    @GsonNullable
-    @SerializedName("gameConfigInfo") val gameConfigInfo: GameConfigInfo?,
-    @SerializedName("code") val code: Int = 0,
-    @SerializedName("message") val message: String = "",
-) : Parcelable {
-
-    fun getSelfPlayerInfo(myUid: Long): GamePlayerInfo? {
-        return gamePlayerInfoList.find { it.playerId == myUid }
-    }
-
-    fun getConfigInfo(): GameConfigInfo {
-        return gameConfigInfo ?: GameConfigInfo(-1, -1, -1, -1, 0, -1, 0)
-    }
-
-}
-
-@Parcelize
-data class PlayerGameInfo(
-    val seqId: Long,
-    @Must
-    @SerializedName("gameConfigInfo") val configInfo: GameConfigInfo,
-    @Must
-    @SerializedName("gamePlayerInfoList") val players: List<GamePlayerInfo>,
-    @SerializedName("teamCreatorId") val creatorUid: Long,
-    @SerializedName("teamCode") val teamCode: String,
-    @SerializedName("gameExpireTime") val codeExpireTime: Long,
-    @Must
-    @SerializedName("channel") val channel: String,
-    @Must
-    @SerializedName("roomId") val roomId: Long,
-
-    @SerializedName("gameId") val gameId: String,
-    @SerializedName("gameMeta") val gameMeta: String,
-    @SerializedName("micSeat") val micSeat: Int = 0,
-) : Parcelable {
-
-    fun getPlayerChangedNotify(): PlayerChangedNotify {
-        return PlayerChangedNotify(
-            if (seqId > 0) seqId else System.currentTimeMillis(),
-            players,
-            configInfo
-        )
-    }
-
-}
-
-data class GameDashboardReq(
-    @SerializedName("gameType") val gameType: Int
-)
-
-data class GameDashboardRes(
-    @SerializedName("uid") val uid: Long,
-    @SerializedName("weekRank") val weekRank: Long,//周排名
-    @SerializedName("weekWinNum") val weekWinNum: Long,//周胜场次
-    @SerializedName("winNum") val winNum: Long,//胜场
-    @GsonNullable
-    @SerializedName("winRate") val winRate: Double? = null,//胜率
-    @GsonNullable
-    @SerializedName("weekTopUser") val weekTopUser: RankListItemData? = null,//周榜第一用户
-    @GsonNullable
-    @SerializedName("totalGainReward") val totalGainReward: Long? = null,    //赢得总奖金
-    @GsonNullable
-    @SerializedName("totalPlayCount") val totalPlayCount: Long? = null,    //总对局次数
-)
-
-
-data class QuickText(
-    @SerializedName("id") val id: Long,
-
-    @SerializedName("en")
-    val enStr: String = "",
-
-    @SerializedName("zh")
-    val zhStr: String = "",
-
-    @SerializedName("zh")
-    val zhTWStr: String = "",
-
-    @SerializedName("ar")
-    val arStr: String = "",
-
-    @SerializedName("tr")
-    val trStr: String = "",
-
-    @SerializedName("hi")
-    val hiStr: String = "",
-
-    @SerializedName("bn")
-    val bnStr: String = "",
-
-    @SerializedName("ur")
-    val urStr: String = "",
-
-    @SerializedName("in")
-    val idStr: String = "",
-
-    @SerializedName("th")
-    val thStr: String = "",
-
-    @SerializedName("vi")
-    val viStr: String = "",
-
-    @SerializedName("tl")
-    val tlStr: String = "",
-
-    @SerializedName("ms")
-    val msStr: String = "",
-
-    @SerializedName("pt")
-    val ptStr: String = "",
-
-    @SerializedName("es")
-    val esStr: String = "",
-
-    @SerializedName("kk")
-    val kkStr: String = "",
-
-    @SerializedName("ky")
-    val kyStr: String = "",
-
-    @SerializedName("ru")
-    val ruStr: String = "",
-
-    @SerializedName("tg")
-    val tgStr: String = "",
-
-    @SerializedName("tk")
-    val tkStr: String = "",
-
-    @SerializedName("uz")
-    val uzStr: String = "",
-) : BaseListItemData {
-
-    override fun areItemsTheSame(newItem: Any): Boolean {
-        return newItem is QuickText && newItem.id == id
-    }
-
-    var senderUid: Long = 0
-
-    fun getText(): String {
-        return when (languageManager?.getLanguage()) {
-            Language.AR -> arStr.ifEmpty { enStr }
-            Language.HI -> hiStr.ifEmpty { enStr }
-            Language.TR -> trStr.ifEmpty { enStr }
-            Language.TH -> thStr.ifEmpty { enStr }
-            Language.BN -> bnStr.ifEmpty { enStr }
-            Language.VI -> viStr.ifEmpty { enStr }
-            Language.UR -> urStr.ifEmpty { enStr }
-            Language.ID -> idStr.ifEmpty { enStr }
-            Language.TL -> tlStr.ifEmpty { enStr }
-            Language.MS -> msStr.ifEmpty { enStr }
-            Language.PT -> ptStr.ifEmpty { enStr }
-            Language.ES -> esStr.ifEmpty { enStr }
-            Language.KK -> kkStr.ifEmpty { enStr }
-            Language.KY -> kyStr.ifEmpty { enStr }
-            Language.RU -> ruStr.ifEmpty { enStr }
-            Language.TG -> tgStr.ifEmpty { enStr }
-            Language.TK -> tkStr.ifEmpty { enStr }
-            Language.ZH -> zhStr.ifEmpty { enStr }
-            Language.ZH_TW -> zhTWStr.ifEmpty { enStr }
-            Language.UZ -> uzStr.ifEmpty { enStr }
-            Language.EN -> enStr
-            else -> enStr
-        }
-    }
-
-}
-
-/**
- * 游戏匹配请求数据
- */
-data class SingleRoomMatchReq(
-    @SerializedName("seqid") val seqid: Long = System.currentTimeMillis(),
-    @SerializedName("lang") val lang: String = languageManager?.getLanguageCode() ?: "",
-    @SerializedName("gameConfigInfo") val gameConfigInfo: GuessGameConfigInfo
-)
-
-data class GuessGameConfigInfo(
-    @SerializedName("gameType") val gameType: Int, //游戏类型
-    @SerializedName("region") val region: String,  //大区
-    @SerializedName("maxPlayerCount") val maxPlayerCount: Int, //最大玩家数量
-    @SerializedName("gameMode") val gameMode: Int //游戏模式 0-默认
-)
-
-
-data class GameRecoverFailData(
-    @SerializedName("reason") val reason: Int, //失败原因, 1:网络重连
-    @SerializedName("msg") val msg: String, //失败原因描述
-) {
-    fun getReasonMsg(): String {
-        return msg.ifEmpty { GameRecoverFailReason.getReasonMessage(reason) }
-    }
-}
-
-data class OnNodeVisibleChangedData(
-    @SerializedName("type") val type: String, //按钮类型, emotion_btn, message_btn
-    @Must
-    @SerializedName("visible") val visible: Int, //控件可见, 0:不可见, 1:可见
-) {
-    fun isVisible(): Boolean {
-        return visible == 1
-    }
-}
-
-enum class GameRecoverFailReason(val reason: Int) {
-    GAME_OVER(1); //游戏已结束,重连失败
-
-    companion object {
-        @JvmStatic
-        fun getReasonMessage(reason: Int): String {
-            return when (GameRecoverFailReason.values().find { it.reason == reason }) {
-                GAME_OVER -> {
-                    getCompatString(R.string.common_game_recover_fail_for_game_over)
-                }
-
-                null -> {
-                    ""
-                }
-            }
-        }
-    }
-}
-
-/**
- * 后端保存的用户默认麦位状态
- */
-enum class MicSwitchStatus(val status: Int) {
-    OFF(0), //关闭
-    OPEN(1), //打开
-}
-
-/**
- * 查询房间的用户麦位状态
- */
-data class GetPlayerMicStatusReq(
-    @SerializedName("gameId") val gameId: String,
-)
-
-/**
- * 查询房间的用户麦位状态返回
- */
-data class GetPlayerMicStatusRes(
-    @SerializedName("gameId") val gameId: String,
-    @SerializedName("micInfos") val micInfos: List<GameMicInfo>?, // 麦位开关状态
-)
-
-data class GameMicInfo(
-    @SerializedName("micUid") val micUid: Long,
-    @SerializedName("micStatus") val micStatus: Int
-)
-
-/**
- * 设置用户麦位状态
- */
-data class OpPlayerMicStatusReq(
-    @SerializedName("gameId") val gameId: String,
-    @SerializedName("roomId") val roomId: Long,
-    @SerializedName("status") val status: Int
-)
-
-data class GameMicNotify(
-    @SerializedName("roomId") val roomId: Long,//房间id
-    @SerializedName("gameId") val gameId: String,//游戏id
-    @SerializedName("serverTs") val serverTs: Long = 0,//服务器时间戳
-    @SerializedName("micInfos") val micInfos: List<GameMicInfo>, // 麦位开关状态
-)

+ 0 - 189
app/src/main/java/com/adealink/weparty/cocosgame/data/CocosNativeData.kt

@@ -1,189 +0,0 @@
-package com.adealink.weparty.cocosgame.data
-
-import android.os.Parcelable
-import com.google.gson.annotations.GsonNullable
-import com.google.gson.annotations.SerializedName
-import kotlinx.parcelize.Parcelize
-
-
-data class DialogIdData(@SerializedName("id") val id: Long)
-
-data class InitGameData(
-    val game: Game,
-    val avatarSizePx: Int
-)
-
-data class StartGameData(
-    @SerializedName("room_id") val roomId: Long,
-    @SerializedName("channel") val channel: String,
-    @SerializedName("game_id") val gameId: String,
-    @SerializedName("uid") val uid: Long,
-    @SerializedName("game_meta_data") val gameMetaData: String,
-    @SerializedName("game_players") val gamePlayers: List<GamePlayerInfo>,
-    @SerializedName("game_config") val gameConfig: GameConfigInfo? = null,
-
-    @Deprecated("废弃")
-    @SerializedName("local") val local: Boolean = false,
-
-    @SerializedName("game_record") val gameRecord: String = "",
-    @SerializedName("game_skins") var gameSkins: List<GameSkin>? = null,
-    @SerializedName("other_config") var otherConfig: GameOtherConfig? = null,
-    @SerializedName("start_room_type") val cocosRoomType: Int,
-    @SerializedName("creator_uid") val gameCreator: Long,
-    @SerializedName("self_audience") var selfAudience: Boolean = false,
-) {
-    val channelLong: Long
-        get() = channel.toLongOrNull() ?: 0
-
-    // =========== 玩家信息 ===========
-    var gamePlayerMap: Map<Long, GamePlayerInfo>? = null
-}
-
-@Parcelize
-data class GameConfigInfo(
-    @SerializedName("gameType") val game: Int, //参考 Game
-    @SerializedName("gameRoomType") val gameType: Int, //参考 LudoGameType, CarromGameType
-    @SerializedName("gameMode") val gameMode: Int, //参考 LudoGameMode, CarromGameMode
-    @SerializedName("magicMode") val magicMode: Int, //参考 LudoMagicMode, CarromMagicMode
-    @SerializedName("maxPlayerCount") val maxPlayerCount: Int, //参考 LudoPlayerCount, CarromPlayerCount
-    @SerializedName("startRoomType") val cocosRoomType: Int, //参考 CocosRoomType
-    @SerializedName("gameFee") val gameFee: Int, //游戏参与费用,0表示免费游戏 >0表示加入游戏的花费
-    @SerializedName("roomId") val roomId: Long = 0,//关联的语聊房间ID
-
-    @SerializedName("gameId") val gameId: String = "",//游戏ID
-    @SerializedName("channel") val channel: Long = 0,//游戏房间ID,用于游戏指令/状态广播
-    @SerializedName("gameMeta") val gameMeta: String? = null,//游戏元数据信息
-    @SerializedName("createTime") val createTime: Long = 0, //游戏创建时间
-    @SerializedName("gameCreator") val gameCreator: Long = 0, //游戏发起者ID
-    @SerializedName("gameState") val gameState: Int = -1,//游戏状态,0:准备,1:进行中,2:游戏结束
-    @SerializedName("gamePlayers") val gamePlayers: List<GamePlayerInfo> = listOf(),//参与游戏的玩家信息
-    @SerializedName("gameRewardInfoList") val gameRewardInfoList: List<GameRewardData> = listOf(),
-    @SerializedName("playerCount2FirstCoinRewardMap")
-    @GsonNullable
-    val playerCount2FirstCoinRewardMap: Map<String, Int>? = null,
-) : Parcelable
-
-data class GameOtherConfig(
-    @SerializedName("canShowNewUserDiceGet") val canShowNewUserDiceGet: Boolean, //是否可展示获取色子
-    @SerializedName("newUserDiceId") val newUserDiceId: Long, //新客专属色子id
-    @SerializedName("canShowNewUserTask") val canShowNewUserTask: Boolean, //可以展示新手任务
-    @SerializedName("selfDefaultGameSkin") var selfDefaultGameSkin: GameSkin?, //自己默认皮肤
-)
-
-@Parcelize
-data class GameRewardData(
-    @SerializedName("rank") val rank: Int,
-    @SerializedName("reward") val reward: Int,
-) : Parcelable
-
-fun GameRewardData?.areContentsTheSame(other: GameRewardData?): Boolean {
-    if (this == null && other == null) {
-        return true
-    }
-    return this?.rank == other?.rank
-            && this?.reward == other?.reward
-}
-
-fun List<GameRewardData>?.areContentsTheSame(other: List<GameRewardData>?): Boolean {
-    if (this == null && other == null) return true
-
-    if (this == null || other == null) return false
-
-    if (this.size != other.size) return false
-
-    return this.indices.all { index ->
-        this[index].areContentsTheSame(other[index])
-    }
-}
-
-data class GameSkin(
-    @SerializedName("playerId")
-    var playerId: Long = 0,
-    @SerializedName("board")
-    var board: String = "",
-    @SerializedName("chess")
-    var chess: String = "",
-    @SerializedName("diceId")
-    var diceId: Long = 0,
-    @SerializedName("dice")
-    var dice: String = "",
-    @SerializedName("dicePreview")
-    var dicePreview: String = "",
-)
-
-data class ExitGameData(
-    @SerializedName("game_room_id") val roomId: Long,
-    @SerializedName("player_id") val uid: Long,
-)
-
-class RestGameData
-
-data class PlayerData(
-    @SerializedName("uid") val uid: Long,
-)
-
-class EmptyData
-
-data class GameRecordData(@SerializedName("game_record") val gameRecord: String)
-
-
-data class JoinCodeData(val code: String, val expiredTs: Long)
-
-data class NetworkStatusData(
-    @SerializedName("available") val available: Boolean,
-)
-
-data class RoomGameJoinReq(
-    @SerializedName("gameType") val gameType: Int,//游戏类型
-    @SerializedName("micSeat") val micSeat: Int,//游戏房间麦位
-    @SerializedName("roomId") val roomId: Long,//游戏房间ID
-    @SerializedName("seqid") val seqId: Long = System.currentTimeMillis()
-)
-
-data class RoomGameReq(
-    @SerializedName("gameType") val gameType: Int,//游戏类型
-    @SerializedName("roomId") val roomId: Long,//游戏房间ID
-)
-
-data class RoomGameKickReq(
-    @SerializedName("gameType") val gameType: Int,//游戏类型
-    @SerializedName("micSeat") val micSeat: Int,//游戏房间麦位
-    @SerializedName("micUid") val micUid: Long,//麦位Uid
-    @SerializedName("roomId") val roomId: Long,//游戏房间ID
-    @SerializedName("seqid") val seqId: Long = System.currentTimeMillis()
-)
-
-data class RoomGameInviteReq(
-    @SerializedName("gameType") val gameType: Int,//游戏类型
-    @SerializedName("micSeat") val micSeat: Int,//游戏房间麦位
-    @SerializedName("playerIds") val playerIds: List<Long>,//被邀请的玩家ID
-    @SerializedName("roomId") val roomId: Long,//游戏房间ID
-    @SerializedName("inviteScene") val inviteScene: Int,
-    @SerializedName("seqid") val seqId: Long = System.currentTimeMillis()
-)
-
-data class GameStartReq(
-    @SerializedName("gameConfigInfo") val gameConfigInfo: GameTypeInfo,
-    @SerializedName("roomId") val roomId: Long,//游戏房间ID
-)
-
-data class GameTypeInfo(
-    @SerializedName("gameType") val game: Int,//游戏
-)
-
-data class GameClosetReq(
-    @SerializedName("gameType") val game: Int,//游戏
-    @SerializedName("roomId") val roomId: Long,//游戏房间ID
-)
-
-data class AudienceJoinReq(
-    @SerializedName("gameId") val gameId: String,//游戏ID
-    @SerializedName("gameMeta") val gameMeta: String,
-    @SerializedName("seqid") val seqId: Long = System.currentTimeMillis()
-)
-
-data class AudienceExitReq(
-    @SerializedName("gameId") val gameId: String,//游戏ID
-    @SerializedName("gameMeta") val gameMeta: String,
-    @SerializedName("seqid") val seqId: Long = System.currentTimeMillis()
-)

+ 0 - 126
app/src/main/java/com/adealink/weparty/cocosgame/data/CocosPlayerData.kt

@@ -1,126 +0,0 @@
-package com.adealink.weparty.cocosgame.data
-
-import android.os.Parcelable
-import com.google.gson.annotations.GsonNullable
-import com.google.gson.annotations.SerializedName
-import kotlinx.parcelize.Parcelize
-
-enum class PlayerStatus(val status: Int) {
-    GAME_IN(1),  //游戏中
-    GAME_EXIT(0); //退出游戏
-
-    companion object {
-        fun map(status: Int): PlayerStatus {
-            return PlayerStatus.values().firstOrNull { it.status == status } ?: GAME_EXIT
-        }
-    }
-
-}
-
-data class PlayerStatusData(@SerializedName("status") val status: Int)
-
-@Parcelize
-data class GamePlayerInfo(
-    @SerializedName("feeOrder") val feeOrder: String = "",//如果是付费场,则该字段记录用户的付费订单ID
-    @SerializedName("playerId") var playerId: Long = 0,//参与游戏的玩家ID
-    @SerializedName("playerAvatarUrl") var playerAvatarUrl: String = "",
-    @SerializedName("avatarDynamicUrl") var avatarDynamicUrl: String? = "",
-    @SerializedName("playerName") var playerName: String = "",
-    @SerializedName("rank") val rank: Int = 0,//排名
-    @SerializedName("teamCode") val teamCode: String = "",
-    @SerializedName("gameExpireTime") val codeExpireTime: Long = 0,
-    @SerializedName("channel") val channel: Long = 0,
-    @SerializedName("groupId") val groupId: Int = 0, //团队id,只有1和2取值
-    @SerializedName("teamCreatorId") var creatorUid: Long = 0, //创建者uid
-    @SerializedName("playerAvatarPath") var playerAvatarPath: String = "",//玩家头像本地路径
-    @GsonNullable
-    @SerializedName("useGameGoodsMap") var userGameGoodsMap: Map<Int, PlayerCommonConfigData>? = null,//用户佩戴的游戏商品
-    @SerializedName("score") var score: Int = 0, //玩家得分
-    @SerializedName("reward") var reward: Int = 0, //获得金币数
-    @SerializedName("exp") var exp: Int = 0, //经验值
-    @SerializedName("micSeat") val micSeat: Int = 0, //对应的麦位
-    @SerializedName("playerGameState") val playerGameState: Int = 0, //用户游戏状态
-
-    @GsonNullable
-    @SerializedName("extraInfo") val extraInfo: PlayerExtraInfoData? = null, //用户信息扩展字段
-
-) : Parcelable {
-
-    //客户端使用
-    var index: Int = 0
-    var selfTeam: Boolean = false //是否是队友
-    var myInvitor: Boolean = false //我的邀请者
-    var liked: Boolean = false //被点赞
-
-    val avatarUrl: String?
-        get() = if (this.avatarDynamicUrl?.isNotEmpty() == true) {
-            this.avatarDynamicUrl
-        } else {
-            this.playerAvatarUrl
-        }
-
-    fun isEmpty(): Boolean {
-        return playerId <= 0
-    }
-
-    fun isSelf(myUid: Long): Boolean {
-        return playerId == myUid
-    }
-
-    fun isCreator(): Boolean = creatorUid == playerId
-
-    fun isWin(): Boolean {
-        return rank <= 3
-    }
-
-    companion object {
-        @JvmStatic
-        fun emptyPlayer(): GamePlayerInfo {
-            return GamePlayerInfo()
-        }
-
-        @JvmStatic
-        fun gamePlayerInfo(playerId: Long, playerName: String): GamePlayerInfo {
-            return GamePlayerInfo().apply {
-                this.playerId = playerId
-                this.playerName = playerName
-            }
-        }
-    }
-
-}
-
-@Parcelize
-data class PlayerCommonConfigData(
-    @SerializedName("type") val type: Int, //配置类型
-    @SerializedName("intDataValue1") val intDataValue1: Long, //整型配置值1
-    @SerializedName("intDataValue2") val intDataValue2: Long, //整型配置值2
-    @SerializedName("intDataValue3") val intDataValue3: Long, //整型配置值3
-    @SerializedName("intDataValue4") val intDataValue4: Long, //整型配置值4
-    @SerializedName("intDataValue5") val intDataValue5: Long, //整型配置值5
-    @SerializedName("intDataValue6") val intDataValue6: Long, //整型配置值6
-    @SerializedName("intDataValue7") val intDataValue7: Long, //整型配置值7
-    @SerializedName("intDataValue8") val intDataValue8: Long, //整型配置值8
-    @SerializedName("intDataValue9") val intDataValue9: Long, //整型配置值9
-    @SerializedName("strDataValue1") var stringDataValue1: String, //字符串配置值1
-    @SerializedName("strDataValue2") val stringDataValue2: String, //字符串配置值2
-    @SerializedName("strDataValue3") val stringDataValue3: String, //字符串配置值3
-    @SerializedName("floatDataValue") val floatDataValue: Float, //浮点数配置值
-    @SerializedName("configValue") val configValue: String, //配置值--用于房间配置/客户端配置
-    @SerializedName("expireTime") val expireTime: Long, //配置过期时间, 传0或者null代表不过期, 否则传秒级过期时间戳
-    @SerializedName("ts") val ts: Long, //配置更新时间
-) : Parcelable
-
-
-@Parcelize
-data class PlayerExtraInfoData(
-    @SerializedName("undoItemList") val ludoItemList: List<UndoItemData>, //重摇道具
-    @SerializedName("undoItemCountLimit") val undoItemCountLimit: Int, //每回合使用重摇道具次数
-    @SerializedName("isUndoNewPlay") val isUndoNewPlay: Boolean, //免费使用1次重摇道具新用户
-) : Parcelable
-
-
-@Parcelize
-data class UndoItemData(
-    @SerializedName("diamond") val diamond: Int, //配置类型
-) : Parcelable

+ 0 - 12
app/src/main/java/com/adealink/weparty/cocosgame/data/CocosRoomType.kt

@@ -1,12 +0,0 @@
-package com.adealink.weparty.cocosgame.data
-
-enum class CocosRoomType(val type: Int) {
-    //GAME_ROOM(0), //游戏房( 暂无此功能 )
-    CHAT_ROOM(1); //语音房
-
-    companion object {
-        fun map(type: Int): CocosRoomType? {
-            return entries.firstOrNull { it.type == type }
-        }
-    }
-}

+ 0 - 212
app/src/main/java/com/adealink/weparty/cocosgame/data/CocosWindowViewData.kt

@@ -1,212 +0,0 @@
-package com.adealink.weparty.cocosgame.data
-
-import android.os.Parcelable
-import android.util.Size
-import com.adealink.frame.base.AppBase
-import com.adealink.frame.data.json.froJsonErrorNull
-import com.adealink.frame.data.json.toJsonErrorNull
-import com.adealink.frame.locale.country.getNewCountryCode
-import com.adealink.frame.router.Router
-import com.adealink.frame.util.PackageUtil
-import com.adealink.frame.util.getApiLevel
-import com.adealink.frame.util.getDeviceName
-import com.adealink.frame.util.getNetworkOperator
-import com.adealink.frame.util.getNetworkType
-import com.adealink.frame.util.getOsVersion
-import com.adealink.frame.util.isNetworkAvailable
-import com.adealink.weparty.App
-import com.adealink.weparty.channel.getChannel
-import com.adealink.weparty.module.attribution.AttributionModule
-import com.adealink.weparty.module.profile.ProfileModule
-import com.adealink.weparty.stat.StatConfig
-import com.google.gson.JsonDeserializationContext
-import com.google.gson.JsonDeserializer
-import com.google.gson.JsonElement
-import com.google.gson.JsonPrimitive
-import com.google.gson.JsonSerializationContext
-import com.google.gson.JsonSerializer
-import com.google.gson.annotations.GsonNullable
-import com.google.gson.annotations.JsonAdapter
-import com.google.gson.annotations.SerializedName
-import kotlinx.parcelize.Parcelize
-import java.lang.reflect.Type
-
-/*
- * Cocos窗口视图相关数据
- */
-
-/**
- * 游戏视图节点类型
- */
-enum class NodeViewType(val type: String) {
-    UNKNOWN("unknown"),
-    EMOTION_BTN("emotion_btn"),
-    MESSAGE_BTN("message_btn"),
-    RANK_BTN("rank_btn"),
-    SETTING_BTN("setting_btn"),
-
-    BOTTOM_BTNS_AREA("bottom_btns_area"), //底部按钮区
-    TOP_BAR_AREA("top_bar_area"), //顶部留白区域
-    BOTTOM_BAR_AREA("bottom_bar_area"); //底部留白区域
-
-    companion object {
-
-        fun getNodeViewType(type: String): NodeViewType {
-            for (entry in NodeViewType.values()) {
-                if (entry.type == type) {
-                    return entry
-                }
-            }
-            return UNKNOWN
-        }
-
-    }
-}
-
-data class NodeViewData(
-    @SerializedName("type") val type: String,
-)
-
-@JsonAdapter(InitNodeViewDataParser::class)
-data class InitNodeViewData(
-    @SerializedName("type") val type: NodeViewType,
-    @SerializedName("data") var data: CocosViewData?
-)
-
-object InitNodeViewDataParser : JsonDeserializer<InitNodeViewData>,
-    JsonSerializer<InitNodeViewData> {
-
-    override fun deserialize(
-        json: JsonElement?,
-        typeOfT: Type?,
-        context: JsonDeserializationContext?,
-    ): InitNodeViewData? {
-        val obj = json?.asJsonObject ?: return null
-        val typeString = obj.get("type")?.asString ?: return null
-        val type = NodeViewType.getNodeViewType(typeString)
-        return InitNodeViewData(
-            type,
-            froJsonErrorNull(obj.get("data")?.asJsonObject?.toString(), CocosViewData::class.java)
-        )
-    }
-
-    override fun serialize(
-        src: InitNodeViewData?,
-        typeOfSrc: Type?,
-        context: JsonSerializationContext?,
-    ): JsonElement? {
-        return if (src == null) null else JsonPrimitive(toJsonErrorNull(src))
-    }
-
-}
-
-@Parcelize
-data class CocosPosition(
-    @SerializedName("x") val x: Float,
-    @SerializedName("y") val y: Float,
-) : Parcelable {
-
-    companion object {
-        /**
-         * 转化为 Cocos坐标
-         * 坐标原点(左下角)
-         * ↑ Y轴
-         * → X轴
-         */
-        @JvmStatic
-        fun convertToCocosPosition(
-            x: Float, y: Float, //控件坐标(相对于游戏容器)
-            viewSize: Size,  //控件大小
-            gameContainerSize: Size //游戏容器大小
-        ): CocosPosition {
-            return CocosPosition(
-                x + viewSize.width / 2,
-                gameContainerSize.height - (y + viewSize.height / 2)
-            )
-        }
-    }
-
-}
-
-
-@Parcelize
-data class CocosViewSize(
-    @SerializedName("width") val width: Float,
-    @SerializedName("height") val height: Float,
-) : Parcelable
-
-
-/**
- * Cocos视图方位
- */
-enum class CocosViewLocation(val location: Int) {
-    CENTER(0b0000), //居中
-    TOP(0b0001), //上
-    BOTTOM(0b0010), //下
-    LEFT(0b0100), //左
-    RIGHT(0b1000), //右
-    TOP_LEFT(0b0101), //左上
-    TOP_RIGHT(0b1001), //右上
-    BOTTOM_LEFT(0b0110), //左下
-    BOTTOM_RIGHT(0b1010); //右下
-
-    companion object {
-        @JvmStatic
-        fun map(location: Int?): CocosViewLocation? {
-            location ?: return null
-            return CocosViewLocation.values().find { it.location == location }
-        }
-    }
-}
-
-/**
- * Cocos视图控件位置大小
- */
-data class CocosViewData(
-    @SerializedName("position") val position: CocosPosition,
-    @SerializedName("size") val size: CocosViewSize,
-    @GsonNullable
-    @SerializedName("location") val location: Int? = null
-)
-
-/**
- * Cocos游戏视图位置大小数据
- */
-data class CocosWindowViewData(
-    @SerializedName("sound_open") val soundOpen: Boolean,
-    @SerializedName("vibrate_open") val vibrateOpen: Boolean,
-    @SerializedName("lang_code") val langCode: String,
-    @SerializedName("view_size") val viewSize: CocosViewSize,
-    @SerializedName("safe_area") val safeArea: CocosWindowSafeArea,
-    @SerializedName("token") val token: String = "",
-    @SerializedName("baseUrl") val baseUrl: String = "",
-    @SerializedName("room_id") val roomId: Long = 0,
-    @SerializedName("scheme_host") val schemeHost: String = Router.getDeepLink(""),
-    @SerializedName("ws_url") val wsUrl: String = "",
-    @SerializedName("app_name") val appName: String = AppBase.appName,
-    @SerializedName("package_name") val packageName: String = PackageUtil.getPackageName(),
-    //埋点数据相关,跟StatConfig保持一致
-    @SerializedName("report_url") val reportUrl: String = "https://api-log-upload.wenext.technology/api/log",
-    @SerializedName("app") val app: String = "0",
-    @SerializedName("app_channel") val appChannel: String = getChannel(),
-    @SerializedName("background") val background: Int = 1,
-    @SerializedName("country_code") val countryCode: String = ProfileModule.getMyUserInfo()?.country ?: getNewCountryCode(),
-    @SerializedName("device_id") val deviceId: String = App.instance.deviceIdService.getLocalDeviceId(),
-    @SerializedName("device_name") val deviceName: String = getDeviceName(),
-    @SerializedName("network_available") val networkAvailable: Boolean = isNetworkAvailable(),
-    @SerializedName("network_operator") val networkOperator: String = getNetworkOperator(),
-    @SerializedName("network_type") val networkType: String = getNetworkType(),
-    @SerializedName("organic_install") val organicInstall: Boolean = !AttributionModule.isInorganicInstall(),
-    @SerializedName("os_version") val osVersion: String = getOsVersion(),
-    @SerializedName("api_level") val apiLevel: Int = getApiLevel(),
-    @SerializedName("platform") val platform: String = AppBase.platform,
-    @SerializedName("region") val region: String? = ProfileModule.getMyUserInfo()?.region,
-    @SerializedName("uid") val uid: Long = ProfileModule.getMyUid(),
-    @SerializedName("version_code") val versionCode: Int = PackageUtil.getVersionCode(),
-    @SerializedName("version_name") val versionName: String = PackageUtil.getVersionName()
-)
-
-data class CocosWindowSafeArea(
-    @SerializedName("position") val position: CocosPosition,
-    @SerializedName("size") val size: CocosViewSize,
-)

+ 0 - 27
app/src/main/java/com/adealink/weparty/cocosgame/data/Error.kt

@@ -1,27 +0,0 @@
-package com.adealink.weparty.cocosgame.data
-
-import com.adealink.frame.aab.util.getCompatString
-import com.adealink.frame.base.IError
-import com.adealink.weparty.R
-import com.adealink.weparty.module.network.data.ServerCode
-import com.adealink.weparty.module.wallet.data.CurrencyNotSufficientError
-import com.adealink.weparty.module.wallet.data.GameCoinNotSufficientError
-
-class CocosGameUnSupportError :
-    IError(msg = getCompatString(R.string.cocosgame_un_support_tip))
-
-class CocosGamingNotAcceptInvitationError :
-    IError(msg = getCompatString(R.string.cocosgame_gaming_not_accept_invitation))
-
-class CocosInGamingError(data: Any? = null) : IError(data = data)
-
-class GameTypeUnSupportError : IError()
-
-fun getErrorByServerError(error: IError): IError {
-    return when (error.serverCode) {
-        ServerCode.CURRENCY_NOT_ENOUGH.code -> CurrencyNotSufficientError()
-        ServerCode.GAME_IN_PROGRESS.code -> CocosInGamingError(error.data)
-        ServerCode.GAME_COIN_NOT_ENOUGH.code -> GameCoinNotSufficientError()
-        else -> error
-    }
-}

+ 0 - 20
app/src/main/java/com/adealink/weparty/cocosgame/data/GameConstants.kt

@@ -1,20 +0,0 @@
-package com.adealink.weparty.cocosgame.data
-
-sealed class PlayerGameState(val state: Int, val desc: String) {
-    data class Error(val s: Int) : PlayerGameState(s, "异常,类型不正确[$s]")
-    object Normal : PlayerGameState(1, "正常进行")
-    object Quit : PlayerGameState(2, "中通退出")
-    object OverTime : PlayerGameState(3, "超时托管")
-
-    companion object {
-        fun map(state: Int?): PlayerGameState {
-            return when (state) {
-                Normal.state -> Normal
-                Quit.state -> Quit
-                OverTime.state -> OverTime
-                else -> Error(state ?: -1)
-            }
-        }
-    }
-
-}

+ 0 - 331
app/src/main/java/com/adealink/weparty/cocosgame/data/GameData.kt

@@ -1,331 +0,0 @@
-package com.adealink.weparty.cocosgame.data
-
-import android.os.Parcelable
-import androidx.annotation.StringRes
-import com.adealink.frame.aab.util.getCompatString
-import com.adealink.frame.base.AppBase
-import com.adealink.frame.util.PackageUtil
-import com.adealink.weparty.R
-import com.google.gson.annotations.GsonNullable
-import com.google.gson.annotations.SerializedName
-import kotlinx.parcelize.Parcelize
-import org.json.JSONObject
-
-/**
- * @param type 游戏类型(和后端对齐)
- * @param code Cocos游戏码(唯一)
- */
-enum class Game(val type: Int, val code: String, val startMode: GameStartMode, val needDownloadResource: Boolean) {
-    LUDO(1, "ludo", GameStartMode.COCOS, true),
-    CARROM(2, "carrom", GameStartMode.WEB, true),
-    UNO(4, "uno", GameStartMode.COCOS, true);
-//    DOMINO(7, "domino", GameStartMode.WEB, true);
-
-    companion object {
-        fun map(type: Int?): Game? {
-            type ?: return null
-            return entries.firstOrNull { it.type == type }
-        }
-
-        fun getNameStrBy(game: Game): String {
-            return when (game) {
-                LUDO -> {
-                    getCompatString(R.string.game_hub_ludo)
-                }
-
-                CARROM -> {
-                    getCompatString(R.string.game_hub_carrom)
-                }
-
-//                SPY -> {
-//                    getCompatString(R.string.game_hub_spy)
-//                }
-
-                UNO -> {
-                    getCompatString(R.string.game_hub_uno)
-                }
-
-//                BRAIN_STORM -> {
-//                    getCompatString(R.string.game_hub_brainstorm)
-//                }
-
-//                GUESS_ANSWER -> {
-//                    getCompatString(R.string.game_hub_guess)
-//                }
-
-//                DOMINO -> {
-//                    getCompatString(R.string.game_hub_domino)
-//                }
-
-//                OKEY101 -> {
-//                    getCompatString(R.string.game_hub_101_okey)
-//                }
-
-//                JACKAROO -> {
-//                    getCompatString(R.string.game_hub_jackaroo)
-//                }
-            }
-        }
-
-        @JvmStatic
-        fun getGameHubGames(): List<Game> {
-            return Game.entries.toList()
-        }
-    }
-}
-
-enum class GameStartMode(val mode: Int) {
-    NATIVE(0), //原生APP开发的游戏
-    COCOS(1), //Cocos引擎启动的游戏
-    WEB(2) //Web手机浏览器启动的游戏
-}
-
-data class LuckyFruitShowRes(@SerializedName("show") val show: Boolean)
-
-enum class GameType(@StringRes val resId: Int) {
-    TEAM_PK(R.string.game_team_pk), //团战pk
-    MIC_PK(R.string.game_mic_pk)//麦位pk
-}
-
-data class GameShowConfigReq(
-    @SerializedName("configTypes") val configTypes: List<Int>,
-    @SerializedName("versionCode") val versionCode: Int,
-    @SerializedName("channel") val channel: String,
-    @SerializedName("platform") val platform: String = AppBase.platform,
-    @SerializedName("packageName") val packageName: String = PackageUtil.getPackageName(),
-)
-
-data class GameShowConfig(
-    @SerializedName("show") val show: Boolean,
-    @GsonNullable
-    @SerializedName("loadingUrl") val loadingUrl: String?,
-    @GsonNullable
-    @SerializedName("offlineUrl") val offlineUrl: String?,
-    @GsonNullable
-    @SerializedName("showNew") val showNew: Boolean?,
-    @GsonNullable
-    @SerializedName("showRed") val showRed: Boolean?,
-    @GsonNullable
-    @SerializedName("updateTs") val updateTs: Long?,
-)
-
-
-/**
- * @param gameType eg: [Game]
- * @param gameRoomType
- */
-data class GameBetCoinsReq(
-    @SerializedName("gameType")
-    val gameType: Int,
-
-    @GsonNullable
-    @SerializedName("gameRoomType")
-    val gameRoomType: Int? = null,
-)
-
-data class GameBetCoinsRes(
-    /**
-     * key: eg: [CarromGameType]
-     */
-    @SerializedName("gameRoomTypeMap")
-    val gameTypeConfig: Map<Int, GameModeBetConfigData>
-)
-
-data class GameModeBetConfigData(
-    /**
-     * key: eg: [CarromGameMode]
-     * value: 下注值
-     */
-    @SerializedName("configMap")
-    val gameModeConfig: Map<Int, List<Int>>,
-
-    /**
-     * key: eg: [CarromGameMode]
-     * value: 奖励值
-     */
-    @SerializedName("rewardConfigMap")
-    val rewardConfigMap: Map<Int, List<Int>>
-)
-
-data class ReceiveRewardReq(
-    @SerializedName("requestType") val requestType: Int = 0
-)
-
-data class CommonActivityRewardInfoReq(
-    @SerializedName("activityId") val activityId: Long = 0,
-    @SerializedName("requestType") val requestType: Int = 0,
-)
-
-data class GetUserLevelInfoReq(
-    @SerializedName("seqid") val seqid: Long = System.currentTimeMillis(),
-    @SerializedName("uids") val uids: List<Long>
-)
-
-interface RoomCommonOperatorData {
-
-    fun areItemsTheSame(newItem: RoomCommonOperatorData): Boolean = this == newItem
-
-    fun areContentsTheSame(newItem: RoomCommonOperatorData): Boolean
-
-    fun changeReceiveStatus(status: Int)
-}
-
-@Parcelize
-data class GameActivityRewardInfo(
-    @GsonNullable
-    @SerializedName("rewardTypeName") val rewardTypeName: String? = null,
-    @SerializedName("detailList") val detailList: List<RewardDetailSource>,
-    @SerializedName("rewardSourceContent") val rewardSourceContent: String
-) : RoomCommonOperatorData, Parcelable {
-    companion object {
-        //未领取
-        const val STATUS_UNRECEIVED = 0
-
-        //已领取
-        const val STATUS_RECEIVED = 1
-
-        //未达领取资格
-        const val STATUS_INSUFFICIENT = 2
-    }
-
-    override fun areContentsTheSame(newItem: RoomCommonOperatorData): Boolean {
-        if (newItem !is GameActivityRewardInfo) {
-            return false
-        }
-        return rewardTypeName == newItem.rewardTypeName && rewardSourceContent == newItem.rewardSourceContent
-    }
-
-    fun getLevel(): Int {
-        return try {
-            rewardSourceContent.toInt()
-        } catch (exception: Exception) {
-            0
-        }
-    }
-
-    fun hasRewardToReceived(): Boolean {
-        if (detailList.isEmpty()) {
-            return false
-        }
-        val rewardData = detailList[0]
-        return rewardData.receiveStatus == STATUS_UNRECEIVED && rewardData.rewardItemList?.isNotEmpty() == true
-    }
-
-    override fun changeReceiveStatus(status: Int) {
-        if (detailList.isEmpty()) {
-            return
-        }
-        detailList[0].receiveStatus = status
-    }
-
-    fun translateToRewardDetail(): RewardDetailData? {
-        if (detailList.isEmpty()) {
-            return null
-        }
-        val rewardList = mutableListOf<RewardItemData>()
-        detailList[0].rewardItemList?.forEach { rewardItem ->
-            rewardList.add(
-                RewardItemData(
-                    rewardItem.rewardResourceUrl,
-                    rewardItem.num,
-                    rewardItem.rewardResourceType,
-                    rewardItem.rewardResourceName,
-                    rewardItem.rewardValue
-                )
-            )
-        }
-        return RewardDetailData(
-            RoomPlayCenterOperatorType.LUCKY_GAME_REWARD,
-            rewardList
-        )
-    }
-}
-
-enum class RoomPlayCenterOperatorType {
-    //操作类型
-    LUCKY_GAME_REWARD,
-    LUCKY_GAME_RANK,
-}
-
-@Parcelize
-data class RewardDetailData(
-    val type: RoomPlayCenterOperatorType,
-    val rewardList: MutableList<RewardItemData>? = null
-) : Parcelable
-
-@Parcelize
-data class RewardDetailSource(
-    @SerializedName("date") val date: Long,
-    @GsonNullable
-    @SerializedName("rewardItemList") val rewardItemList: ArrayList<RewardItem>? = null,
-    @SerializedName("rewardSourceContent") val rewardSourceContent: String,
-    @SerializedName("receiveStatus") var receiveStatus: Int,
-) : Parcelable
-
-@Parcelize
-data class RewardItem(
-    @SerializedName("carveUpNum") val carveUpNum: Int,
-    @SerializedName("dynamicResourceUrl") val dynamicResourceUrl: String,
-    @SerializedName("goodIdLengthType") val goodIdLengthType: Int,
-    @SerializedName("id") val id: Int,
-    @SerializedName("issueToPackage") val issueToPackage: Int,
-    @SerializedName("jumpId") val jumpId: Int,
-    @SerializedName("num") val num: Int,
-    @SerializedName("packageId") val packageId: Int,
-    @SerializedName("probability") val probability: Float,
-    @SerializedName("rewardDuration") val rewardDuration: Int,
-    @SerializedName("rewardEffectTime") val rewardEffectTime: Int,
-    @SerializedName("rewardNum") val rewardNum: Int,
-    @SerializedName("rewardNumScale") val rewardNumScale: Float,
-    @SerializedName("rewardRate") val rewardRate: Float,
-    @SerializedName("rewardResourceId") val rewardResourceId: Int,
-    @GsonNullable
-    @SerializedName("rewardResourceName") val rewardResourceName: String? = null,
-    @SerializedName("rewardResourceType") val rewardResourceType: Int,
-    @GsonNullable
-    @SerializedName("rewardResourceUrl") val rewardResourceUrl: String? = null,
-    @SerializedName("rewardValue") val rewardValue: Int,
-    @SerializedName("source") val source: Int,
-    @SerializedName("status") val status: Int,
-) : Parcelable
-
-@Parcelize
-data class RewardItemData(
-    val rewardUrl: String? = null,
-    var rewardCount: Int = 0,
-    var rewardType: Int,
-    var rewardName: String? = null,
-    var rewardValue: Int = 0
-) : Parcelable {
-
-    fun getRewardName(language: String): String? {
-        try {
-            val json = this.rewardName?.let { JSONObject(it) }
-            return json?.optString(language) ?: ""
-        } catch (e: Exception) {
-            //doNothing
-        }
-        return this.rewardName
-    }
-}
-
-data class UserGameLevelInfoResult(
-    @SerializedName("seqid") val seqid: Long,
-    @GsonNullable
-    @SerializedName("userGameLevelInfoMap") val userGameLevelInfoMap: MutableMap<String, UserGameLevelInfo>? = null,
-)
-
-data class UserGameLevelInfo(
-    @SerializedName("uid") val uid: Long,
-    @SerializedName("gameLevel") val gameLevel: Int,
-    @SerializedName("expire") val expire: Long,
-    @SerializedName("score") val score: Long,
-    @SerializedName("starNum") val starNum: Int,
-    @SerializedName("lastGameLevel") val lastGameLevel: Int,
-    @SerializedName("lastScore") val lastScore: Long,
-    @SerializedName("nextGameLevel") val nextGameLevel: Int,
-    @SerializedName("nextScore") val nextScore: Long,
-    @SerializedName("levelTime") val levelTime: Long,
-    @SerializedName("createTime") val createTime: Long,
-
-    )

+ 0 - 218
app/src/main/java/com/adealink/weparty/cocosgame/data/GameToNativeOpData.kt

@@ -1,218 +0,0 @@
-package com.adealink.weparty.cocosgame.data
-
-import android.os.Parcelable
-import com.adealink.frame.data.json.froJsonErrorNull
-import com.adealink.frame.data.json.toJsonErrorNull
-import com.google.gson.JsonDeserializationContext
-import com.google.gson.JsonDeserializer
-import com.google.gson.JsonElement
-import com.google.gson.JsonPrimitive
-import com.google.gson.JsonSerializationContext
-import com.google.gson.JsonSerializer
-import com.google.gson.annotations.JsonAdapter
-import com.google.gson.annotations.SerializedName
-import kotlinx.parcelize.Parcelize
-import java.lang.reflect.Type
-
-/*
- * APP游戏操作Cocos
- */
-enum class GameToNativeOpType(var op: Int, val clazz: Class<*>?) {
-    UNKNOWN(0, UnknownOpData::class.java),
-    CLICK_AVATAR(1, ClickAvatarOpData::class.java), //点击头像
-    CLICK_HELP(2, ClickHelpOpData::class.java), //点击帮助
-    CLICK_SETTING(3, ClickSettingOpData::class.java), //点击设置
-    CLICK_EXIT(4, ClickExitOpData::class.java), //点击退出
-    CLICK_RESTART(5, ClickRestartOpData::class.java), //点击restart
-    VIBRATE(6, VibrateOpData::class.java), //振动
-    PLAY_SOUND(7, PlaySoundOpData::class.java), //播放音效
-    SWITCH_SOUND(8, SwitchSoundOpData::class.java), //音效开关
-    SWITCH_VIBRATE(9, SwitchVibrateOpData::class.java), //振动开关
-    CLICK_MIC(10, ClickMicOpData::class.java), //点击麦克风
-    STOP_SOUND(11, StopSoundOpData::class.java), //停止音效播放
-    CLICK_EMOTION(12, ClickEmotionOpData::class.java), //点击表情按钮
-    CLICK_MESSAGE(13, ClickMessageOpData::class.java), //点击消息按钮
-    SHOW_NEW_USER_TASK(14, ShowNewUserTaskOpData::class.java), //点击消息按钮
-    SHOW_GAME_RULE(15, ShowGameRuleOpData::class.java), //显示游戏规则
-    //SHOW_TROPHY(16, ShowTrophyOpData::class.java), //显示奖杯信息
-    CLICK_BACK_TO_HALL(17, BackToHallOpData::class.java), //返回游戏大厅
-    SHOW_RANK(18, ShowRankOpData::class.java), //显示排行榜
-    CLICK_START_GAME(19, StartGameOpData::class.java); //返回游戏大厅
-
-    companion object {
-
-        fun getGameToNativeOp(op: Int): GameToNativeOpType {
-            for (entry in values()) {
-                if (entry.op == op) {
-                    return entry
-                }
-            }
-            return UNKNOWN
-        }
-
-    }
-
-}
-
-@JsonAdapter(GameToNativeOpParser::class)
-class GameToNativeOp(@SerializedName("op") val op: GameToNativeOpType) {
-    @SerializedName("data")
-    var data: GameToNativeOpData? = null
-}
-
-object GameToNativeOpParser : JsonDeserializer<GameToNativeOp>,
-    JsonSerializer<GameToNativeOp> {
-
-    override fun deserialize(
-        json: JsonElement?,
-        typeOfT: Type?,
-        context: JsonDeserializationContext?,
-    ): GameToNativeOp? {
-        val obj = json?.asJsonObject ?: return null
-        val opInt = obj.get("op")?.asInt ?: return null
-        val op = GameToNativeOpType.getGameToNativeOp(opInt)
-        return GameToNativeOp(op).apply {
-            data = froJsonErrorNull(obj.get("data")?.asJsonObject?.toString(), op.clazz as Type)
-        }
-    }
-
-    override fun serialize(
-        src: GameToNativeOp?,
-        typeOfSrc: Type?,
-        context: JsonSerializationContext?,
-    ): JsonElement? {
-        return if (src == null) null else JsonPrimitive(toJsonErrorNull(src))
-    }
-
-}
-
-@Parcelize
-sealed class GameToNativeOpData : Parcelable
-
-/**
- * 未知操作数据
- */
-class UnknownOpData : GameToNativeOpData()
-
-/**
- * 点击头像
- */
-data class ClickAvatarOpData(@SerializedName("uid") val uid: Long) : GameToNativeOpData()
-
-/**
- * 点击帮助
- */
-class ClickHelpOpData : GameToNativeOpData()
-
-/**
- * 点击设置
- */
-class ClickSettingOpData : GameToNativeOpData()
-
-/**
- * 点击退出
- */
-class ClickExitOpData : GameToNativeOpData()
-
-/**
- * 点击重新开始
- */
-class ClickRestartOpData : GameToNativeOpData()
-
-enum class VibrateType(val duration: Long) {
-    LONG(-1),
-    SHORT(0),
-    CUSTOM(-2);
-
-    companion object {
-        fun map(duration: Long): VibrateType {
-            return VibrateType.values().firstOrNull { it.duration == duration } ?: CUSTOM
-        }
-    }
-}
-
-/**
- * 震动
- */
-data class VibrateOpData(@SerializedName("duration") val duration: Long /*单位:ms*/) :
-    GameToNativeOpData()
-
-/**
- * 播放音效
- */
-data class PlaySoundOpData(@SerializedName("sound_name") val soundName: String) :
-    GameToNativeOpData()
-
-/**
- * 停止播放音效
- */
-data class StopSoundOpData(@SerializedName("sound_name") val soundName: String) :
-    GameToNativeOpData()
-
-/**
- * 音效开关
- */
-class SwitchSoundOpData : GameToNativeOpData()
-
-/**
- * 振动开发
- */
-class SwitchVibrateOpData : GameToNativeOpData()
-
-/**
- * 点击麦克风
- */
-data class ClickMicOpData(@SerializedName("uid") val uid: Long) : GameToNativeOpData()
-
-/**
- * 点击表情按钮
- */
-data class ClickEmotionOpData(
-    @SerializedName("position") val position: CocosPosition,
-    @SerializedName("size") val size: CocosViewSize
-) : GameToNativeOpData()
-
-/**
- * 点击消息按钮
- */
-data class ClickMessageOpData(
-    @SerializedName("position") val position: CocosPosition,
-    @SerializedName("size") val size: CocosViewSize
-) : GameToNativeOpData()
-
-
-/**
- * 展示了新手任务
- */
-class ShowNewUserTaskOpData : GameToNativeOpData()
-
-
-/**
- * 展示游戏规则
- */
-class ShowGameRuleOpData : GameToNativeOpData()
-
-
-/**
- * 展示奖杯信息
- */
-class ShowTrophyOpData(
-    @SerializedName("position") val position: CocosPosition,
-    @SerializedName("size") val size: CocosViewSize
-) : GameToNativeOpData()
-
-
-/**
- * 返回游戏大厅
- */
-class BackToHallOpData : GameToNativeOpData()
-
-/**
- * 显示排行榜
- */
-class ShowRankOpData : GameToNativeOpData()
-
-/**
- * 启动游戏
- */
-class StartGameOpData : GameToNativeOpData()

+ 0 - 31
app/src/main/java/com/adealink/weparty/cocosgame/data/NativeToGameOpData.kt

@@ -1,31 +0,0 @@
-package com.adealink.weparty.cocosgame.data
-
-import com.google.gson.annotations.SerializedName
-
-/*
- * Cocos操作APP游戏
- */
-enum class NativeToGameOp(var op: Int) {
-    MIC_STATUS(2),      // 麦位状态
-    OPEN_MIC_TIPS(4),   // 引导用户开麦气泡
-}
-
-data class NativeToGameOpData(
-    @SerializedName("op") val op: Int,
-    @SerializedName("data") val data: BaseOpData,
-)
-
-sealed class BaseOpData
-
-enum class MicStatus(val status: Int) {
-    NORMAL(0), //正常
-    CLOSE(1), //关闭
-    SPEAKING(2) //说话
-}
-
-data class OpMicStatusData(
-    @SerializedName("uid") val uid: Long,
-    @SerializedName("status") val status: Int
-) : BaseOpData()
-
-class OpenMicTipsData : BaseOpData()

+ 0 - 15
app/src/main/java/com/adealink/weparty/cocosgame/data/Tags.kt

@@ -1,15 +0,0 @@
-package com.adealink.weparty.cocosgame.data
-
-const val TAG_COCOS_GAME = "tag_cocos_game"
-const val TAG_COCOS_GAME_FLOW = "${TAG_COCOS_GAME}_flow"
-const val TAG_COCOS_GAME_FLOW_ROOM = "${TAG_COCOS_GAME_FLOW}_room"
-const val TAG_COCOS_GAME_NETWORK = "${TAG_COCOS_GAME}_network"
-const val TAG_COCOS_GAME_MEDIA = "${TAG_COCOS_GAME}_media"
-const val TAG_COCOS_GAME_SEATS = "${TAG_COCOS_GAME}_seats"
-const val TAG_COCOS_GAME_MIC = "${TAG_COCOS_GAME}_mic"
-
-
-const val TAG_COCOS_GAME_WEB = "tag_cocos_web"
-const val TAG_COCOS_GAME_WEB_FLOW = "${TAG_COCOS_GAME_WEB}_flow"
-const val TAG_COCOS_GAME_WEB_NETWORK = "${TAG_COCOS_GAME_WEB}_network"
-const val TAG_COCOS_GAME_WEB_CALL = "${TAG_COCOS_GAME_WEB}_call"

+ 0 - 31
app/src/main/java/com/adealink/weparty/cocosgame/datasource/local/CocosGameLocalService.kt

@@ -1,31 +0,0 @@
-package com.adealink.weparty.cocosgame.datasource.local
-
-import android.content.Context
-import com.adealink.frame.storage.sp.TypeDelegationPrefs
-import com.adealink.frame.util.AppUtil
-import com.adealink.weparty.module.account.AccountModule
-
-object CocosGameLocalService : TypeDelegationPrefs(
-    prefs = {
-        AppUtil.appContext.getSharedPreferences("pref_cocosgame", Context.MODE_PRIVATE)
-    },
-    userId = {
-        AccountModule.uid.toString()
-    }
-) {
-
-    var recordAudioPermissionTipCount: Int by PrefUserKey(
-        "key_record_audio_permission_tip_count",
-        0
-    )
-
-    var bluetoothConnectPermissionTipCount: Int by PrefUserKey(
-        "key_bluetooth_connect_permission_tip_count",
-        0
-    )
-
-    var lastOpenGameMicTipsTime: Long by PrefUserKey(
-        "key_last_open_game_mic_tips_time",
-        0
-    )
-}

+ 0 - 166
app/src/main/java/com/adealink/weparty/cocosgame/datasource/remote/CommonGameHttpService.kt

@@ -1,166 +0,0 @@
-package com.adealink.weparty.cocosgame.datasource.remote
-
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.network.data.Res
-import com.adealink.weparty.cocosgame.data.AudienceExitReq
-import com.adealink.weparty.cocosgame.data.AudienceJoinReq
-import com.adealink.weparty.cocosgame.data.ExitGameReq
-import com.adealink.weparty.cocosgame.data.GameBetCoinsReq
-import com.adealink.weparty.cocosgame.data.GameBetCoinsRes
-import com.adealink.weparty.cocosgame.data.GameClosetReq
-import com.adealink.weparty.cocosgame.data.GameConfigInfo
-import com.adealink.weparty.cocosgame.data.GameConfigReq
-import com.adealink.weparty.cocosgame.data.GameDashboardReq
-import com.adealink.weparty.cocosgame.data.GameDashboardRes
-import com.adealink.weparty.cocosgame.data.GameStartNotify
-import com.adealink.weparty.cocosgame.data.GameStartReq
-import com.adealink.weparty.cocosgame.data.GetPlayerMicStatusReq
-import com.adealink.weparty.cocosgame.data.GetPlayerMicStatusRes
-import com.adealink.weparty.cocosgame.data.OpPlayerMicStatusReq
-import com.adealink.weparty.cocosgame.data.PlayerGameInfo
-import com.adealink.weparty.cocosgame.data.RoomGameInviteReq
-import com.adealink.weparty.cocosgame.data.RoomGameJoinReq
-import com.adealink.weparty.cocosgame.data.RoomGameKickReq
-import com.adealink.weparty.cocosgame.data.RoomGameReq
-import com.adealink.weparty.cocosgame.data.SingleRoomMatchReq
-import retrofit2.http.Body
-import retrofit2.http.Core
-import retrofit2.http.GET
-import retrofit2.http.POST
-
-interface CommonGameHttpService {
-
-    /**
-     * 获取下注金额
-     */
-    @Core
-    @POST("gamePlatform/common/coin/config")
-    suspend fun getBetCoins(@Body req: GameBetCoinsReq): Rlt<Res<GameBetCoinsRes>>
-
-    /**
-     * 开始单人匹配
-     */
-    @Core
-    @POST("gamePlatform/ludo/match/single/add")
-    suspend fun singleMatch(@Body req: GameConfigReq): Rlt<Res<GameConfigInfo>>
-
-    /**
-     * 取消单人匹配
-     */
-    @Core
-    @POST("gamePlatform/ludo/match/single/exit")
-    suspend fun cancelSingleMatch(): Rlt<Res<String>>
-
-    /**
-     * 房间游戏 初始化
-     */
-    @Core
-    @POST("gamePlatform/common/roomGame/init")
-    suspend fun initRoomGame(@Body req: GameConfigInfo): Rlt<Res<GameConfigInfo>>
-
-    /**
-     * 房间游戏 关闭
-     */
-    @Core
-    @POST("gamePlatform/common/roomGame/close")
-    suspend fun closeRoomGame(@Body req: RoomGameReq): Rlt<Res<Any>>
-
-    /**
-     * 玩家加入房间游戏(同加入游戏匹配、上麦)
-     */
-    @Core
-    @POST("gamePlatform/common/roomGame/join")
-    suspend fun joinRoomGame(@Body req: RoomGameJoinReq): Rlt<Res<Any>>
-
-    /**
-     * 踢出房间游戏(同踢出游戏匹配、踢下麦)
-     */
-    @Core
-    @POST("gamePlatform/common/roomGame/kick")
-    suspend fun kickRoomGame(@Body req: RoomGameKickReq): Rlt<Res<Any>>
-
-    /**
-     * 邀请加入房间游戏(同邀请加入游戏匹配、邀请上麦)
-     */
-    @Core
-    @POST("gamePlatform/common/roomGame/invite")
-    suspend fun inviteRoomGame(@Body req: RoomGameInviteReq): Rlt<Res<Any>>
-
-    /**
-     * 开始游戏
-     */
-    @Core
-    @POST("gamePlatform/common/start")
-    suspend fun start(@Body req: GameStartReq): Rlt<Res<GameConfigInfo>>
-
-    /**
-     * 关闭游戏(同取消房间游戏模式)
-     */
-    @Core
-    @POST("gamePlatform/common/roomGame/close")
-    suspend fun closeGame(@Body req: GameClosetReq): Rlt<Res<Any>>
-
-    /**
-     * 观众加入
-     */
-    @Core
-    @POST("gamePlatform/common/audience/join")
-    suspend fun audienceJoin(@Body req: AudienceJoinReq): Rlt<Res<GameStartNotify>>
-
-    /**
-     * 观众退出
-     */
-    @Core
-    @POST("gamePlatform/common/audience/exit")
-    suspend fun audienceExit(@Body req: AudienceExitReq): Rlt<Res<Any>>
-
-    /**
-     * 获取当前游戏状态数据
-     */
-    @Core
-    @GET("gamePlatform/player/playing_game_info")
-    suspend fun getPlayingGameInfo(): Rlt<Res<PlayerGameInfo>>
-
-    /**
-     * 退出游戏
-     */
-    @Core
-    @POST("gamePlatform/common/player/exit")
-    suspend fun exitGame(@Body req: ExitGameReq): Rlt<Res<Any>>
-
-    /**
-     * 游戏榜单
-     */
-    @Core
-    @POST("gamePlatform/common/dashboard")
-    suspend fun getRankBoard(@Body req: GameDashboardReq): Rlt<Res<GameDashboardRes>>
-
-    /**
-     * 开始单人匹配(语音房玩法)
-     */
-    @Core
-    @POST("gamePlatform/ludo/match/singleRoom/add")
-    suspend fun singleRoomMatch(@Body req: SingleRoomMatchReq): Rlt<Res<GameConfigInfo>>
-
-    /**
-     * 取消单人匹配(语音房玩法)
-     */
-    @Core
-    @POST("gamePlatform/ludo/match/singleRoom/exit")
-    suspend fun cancelSingleRoomMatch(): Rlt<Res<String>>
-
-    /**
-     * 获取游戏中玩家的麦位开关
-     */
-    @Core
-    @POST("gamePlatform/mic/get")
-    suspend fun getGetPlayerMicStatus(@Body req: GetPlayerMicStatusReq): Rlt<Res<GetPlayerMicStatusRes>>
-
-    /**
-     * 操作玩家的麦位开关
-     */
-    @Core
-    @POST("gamePlatform/mic/op")
-    suspend fun opPlayerMicStatus(@Body req: OpPlayerMicStatusReq): Rlt<Res<Any>>
-
-}

+ 0 - 81
app/src/main/java/com/adealink/weparty/cocosgame/gift/adapter/SendGiftInfoRollViewBinder.kt

@@ -1,81 +0,0 @@
-package com.adealink.weparty.cocosgame.gift.adapter
-
-import android.text.SpannableStringBuilder
-import android.text.Spanned
-import android.text.style.ForegroundColorSpan
-import android.view.LayoutInflater
-import android.view.ViewGroup
-import com.adealink.frame.aab.util.getCompatColor
-import com.adealink.frame.aab.util.getCompatString
-import com.adealink.frame.ext.safeSetSpan
-import com.adealink.weparty.R
-import com.adealink.weparty.commonui.recycleview.adapter.BindingViewHolder
-import com.adealink.weparty.commonui.recycleview.adapter.multitype.ItemViewBinder
-import com.adealink.weparty.databinding.ItemCocosgameSendGiftInfoRollBinding
-import com.adealink.weparty.module.gift.data.SendGiftItem
-
-class SendGiftInfoRollViewBinder :
-    ItemViewBinder<SendGiftItem, SendGiftInfoRollViewBinder.ViewHolder>() {
-
-    override fun onBindViewHolder(holder: ViewHolder, item: SendGiftItem) {
-        holder.update(item)
-    }
-
-    override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
-        return ViewHolder(ItemCocosgameSendGiftInfoRollBinding.inflate(inflater, parent, false))
-    }
-
-    inner class ViewHolder(binding: ItemCocosgameSendGiftInfoRollBinding) :
-        BindingViewHolder<ItemCocosgameSendGiftInfoRollBinding>(binding) {
-
-        private var sendGiftItem: SendGiftItem? = null
-
-        fun update(item: SendGiftItem) {
-            sendGiftItem = item
-            val fromMember = item.fromUserInfo
-            val toMember = item.toUserInfo
-            binding.ivAvtarGift.setImageUrl(fromMember?.url)
-            if (fromMember != null && toMember != null) {
-                val sendGiftText = getCompatString(
-                    R.string.cocosgame_send_gift_roll_msg,
-                    fromMember.name ?:"",
-                    toMember.name?:"",
-                )
-                binding.tvGiftInfo.text = SpannableStringBuilder(sendGiftText).apply {
-                    val fromMemberName = fromMember.name
-                    if (fromMemberName?.isNotEmpty()==true) {
-                        val fromMemberStart = sendGiftText.indexOf(fromMemberName)
-                        if (fromMemberStart >= 0) {
-                            safeSetSpan(
-                                ForegroundColorSpan(getCompatColor(R.color.white)),
-                                fromMemberStart,
-                                fromMemberStart + fromMemberName.length,
-                                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
-                            )
-                        }
-                    }
-
-                    val toMemberName = toMember.name
-                    if (toMemberName?.isNotEmpty()==true) {
-                        val toMemberStart = sendGiftText.indexOf(toMemberName)
-                        if (toMemberStart >= 0) {
-                            safeSetSpan(
-                                ForegroundColorSpan(getCompatColor(R.color.white)),
-                                toMemberStart,
-                                toMemberStart + toMemberName.length,
-                                Spanned.SPAN_EXCLUSIVE_EXCLUSIVE
-                            )
-                        }
-                    }
-                }
-            } else {
-                binding.tvGiftInfo.text = null
-            }
-
-            binding.ivGift.setImageUrl(item.iconUrl)
-            binding.tvGiftNum.text = getCompatString(R.string.commonui_count, item.count)
-        }
-
-    }
-
-}

+ 0 - 123
app/src/main/java/com/adealink/weparty/cocosgame/gift/comp/SendGiftComp.kt

@@ -1,123 +0,0 @@
-package com.adealink.weparty.cocosgame.gift.comp
-
-import androidx.lifecycle.LifecycleOwner
-import androidx.recyclerview.widget.LinearLayoutManager
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.base.fastLazy
-import com.adealink.frame.mvvm.view.ViewComponent
-import com.adealink.weparty.cocosgame.gift.adapter.SendGiftInfoRollViewBinder
-import com.adealink.weparty.commonui.ext.dp
-import com.adealink.weparty.commonui.ext.show
-import com.adealink.weparty.commonui.recycleview.AutoRollRecycleView
-import com.adealink.weparty.commonui.recycleview.adapter.MultiTypeListAdapter
-import com.adealink.weparty.commonui.recycleview.diffutil.BaseListDiffUtil
-import com.adealink.weparty.module.anchor.data.FromScene
-import com.adealink.weparty.module.gift.GiftModule
-import com.adealink.weparty.module.gift.combo.ComboGiftCounter
-import com.adealink.weparty.module.gift.combo.OnComboCallback
-import com.adealink.weparty.module.gift.data.SendGiftItem
-import com.adealink.weparty.module.gift.data.SendGiftNotify
-import com.adealink.weparty.module.gift.data.toSendGiftItems
-import com.adealink.weparty.module.profile.ProfileModule
-import com.adealink.weparty.module.profile.data.UserInfo
-
-class SendGiftComp(
-    lifecycleOwner: LifecycleOwner,
-    private val sendGiftsRollRv: AutoRollRecycleView,
-) : ViewComponent(lifecycleOwner), OnComboCallback {
-
-    private val giftViewModel by fastLazy { GiftModule.getGiftViewModel(viewModelStoreOwner) }
-    private val profileViewModel by fastLazy { ProfileModule.getProfileViewModel(viewModelStoreOwner) }
-
-    private val adapter by fastLazy { MultiTypeListAdapter(BaseListDiffUtil()) }
-    private val sendGiftItemList = arrayListOf<SendGiftItem>()
-    private val comboGiftCounter = ComboGiftCounter(this)
-
-    override fun onCreate() {
-        super.onCreate()
-        initViews()
-        observeViewModel()
-    }
-
-    override fun onDestroy() {
-        super.onDestroy()
-        comboGiftCounter.onCleared()
-    }
-
-    private fun initViews() {
-        sendGiftsRollRv.rollDistancePx = 28.dp()
-        sendGiftsRollRv.layoutManager =
-            LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false)
-        adapter.register(SendGiftInfoRollViewBinder())
-        sendGiftsRollRv.adapter = adapter
-    }
-
-    private fun observeViewModel() {
-        giftViewModel?.sendGiftNotifyLD?.observe(viewLifecycleOwner) { sendGiftNotify ->
-            if (sendGiftNotify.giftScene != FromScene.IN_ROOM.scene) {
-                return@observe
-            }
-            handleSendGiftNotify(sendGiftNotify)
-        }
-    }
-
-    private fun handleSendGiftNotify(sendGiftNotify: SendGiftNotify) {
-        if (!sendGiftNotify.gitInfo.isVisibleToUser()) {
-            //该礼物对用户不可见
-            return
-        }
-
-        val toUsersList = mutableListOf<UserInfo>()
-        sendGiftNotify.toUidSet.forEach { toUid ->
-            sendGiftNotify.notifyUserInfo?.get(toUid)?.let {
-                toUsersList.add(it)
-            }
-        }
-
-        if (sendGiftNotify.gitInfo.canCombo()) {
-            //combo礼物
-            comboGiftCounter.onGiftNotify(sendGiftNotify)
-        } else {
-            val sendGiftItems = sendGiftNotify.toSendGiftItems()
-            fillGiftInfo(sendGiftItems) {
-                sendGiftItemList.addAll(it)
-                adapter.submitList(sendGiftItemList)
-                sendGiftsRollRv.show()
-                sendGiftsRollRv.startRoll()
-            }
-        }
-    }
-
-    private fun fillGiftInfo(items: List<SendGiftItem>, callback: (gifts: List<SendGiftItem>) -> Unit) {
-        val reqUidList = mutableSetOf<Long>().apply {
-            items.onEach { item ->
-                this.add(item.fromUid)
-                this.add(item.toUid)
-            }
-        }
-        profileViewModel?.getUsersInfoByUid(reqUidList, true)?.observe(viewLifecycleOwner) {
-            val userInfoMap = (it as? Rlt.Success)?.data
-            items.onEach { item ->
-                item.fromUserInfo = userInfoMap?.get(item.fromUid)
-                item.toUserInfo = userInfoMap?.get(item.toUid)
-            }
-            callback.invoke(items)
-        } ?: let {
-            callback.invoke(items)
-        }
-
-    }
-
-    override fun onComboFinish(items: List<SendGiftItem>) {
-        if (!isValid) {
-            return
-        }
-        fillGiftInfo(items) {
-            sendGiftItemList.addAll(it)
-            adapter.submitList(sendGiftItemList)
-            sendGiftsRollRv.show()
-            sendGiftsRollRv.startRoll()
-        }
-    }
-
-}

+ 0 - 20
app/src/main/java/com/adealink/weparty/cocosgame/listener/ICocosGameOperateListener.kt

@@ -1,20 +0,0 @@
-package com.adealink.weparty.cocosgame.listener
-
-interface ICocosGameOperateListener {
-
-    /**
-     * 点击头像
-     */
-    fun onAvatarClick(uid: Long) {}
-
-    /**
-     * 自己是否为创建者
-     */
-    fun isIAmCreator(): Boolean = false
-
-    /**
-     * 点击麦克风
-     */
-    fun onMicClick(uid: Long) {}
-
-}

+ 0 - 342
app/src/main/java/com/adealink/weparty/cocosgame/manager/CocosWebGameManager.kt

@@ -1,342 +0,0 @@
-package com.adealink.weparty.cocosgame.manager
-
-import com.adealink.frame.coroutine.dispatcher.Dispatcher
-import com.adealink.frame.game.ICallback
-import com.adealink.frame.log.Log
-import com.adealink.frame.network.INotifyInterceptor
-import com.adealink.frame.util.OnNetworkListener
-import com.adealink.frame.util.registerNetworkListener
-import com.adealink.frame.util.unregisterNetworkListener
-import com.adealink.weparty.App
-import com.adealink.weparty.cocosgame.data.BaseOpData
-import com.adealink.weparty.cocosgame.data.CocosViewData
-import com.adealink.weparty.cocosgame.data.EmptyData
-import com.adealink.weparty.cocosgame.data.Game
-import com.adealink.weparty.cocosgame.data.GamePlayerInfo
-import com.adealink.weparty.cocosgame.data.GameRecordData
-import com.adealink.weparty.cocosgame.data.InitGameData
-import com.adealink.weparty.cocosgame.data.NativeToGameOp
-import com.adealink.weparty.cocosgame.data.NativeToGameOpData
-import com.adealink.weparty.cocosgame.data.NetworkStatusData
-import com.adealink.weparty.cocosgame.data.NodeViewData
-import com.adealink.weparty.cocosgame.data.NodeViewType
-import com.adealink.weparty.cocosgame.data.PlayerData
-import com.adealink.weparty.cocosgame.data.PlayerStatus
-import com.adealink.weparty.cocosgame.data.PlayerStatusData
-import com.adealink.weparty.cocosgame.data.RestGameData
-import com.adealink.weparty.cocosgame.data.StartGameData
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB_CALL
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB_FLOW
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB_NETWORK
-import com.adealink.weparty.cocosgame.manager.listener.ICocosGameListener
-import com.adealink.weparty.cocosgame.method.OnDeeplinkJsMethod
-import com.adealink.weparty.cocosgame.method.OnDismissJsMethod
-import com.adealink.weparty.cocosgame.method.OnGameEndJsMethod
-import com.adealink.weparty.cocosgame.method.OnGameOpJsMethod
-import com.adealink.weparty.cocosgame.method.OnGameRecoverFailJsMethod
-import com.adealink.weparty.cocosgame.method.OnGameStartJsMethod
-import com.adealink.weparty.cocosgame.method.OnGetAppEnvJsMethod
-import com.adealink.weparty.cocosgame.method.OnGetCurrencyJsMethod
-import com.adealink.weparty.cocosgame.method.OnGetGameViewJsMethod
-import com.adealink.weparty.cocosgame.method.OnInitNodeViewJsMethod
-import com.adealink.weparty.cocosgame.method.OnLogJsMethod
-import com.adealink.weparty.cocosgame.method.OnNetworkRequestJsMethod
-import com.adealink.weparty.cocosgame.method.OnNodeVisibleChangedJsMethod
-import com.adealink.weparty.cocosgame.method.OnStatJsMethod
-import com.adealink.weparty.cocosgame.method.PauseDialogManagerJSNativeMethod
-import com.adealink.weparty.cocosgame.method.ResumeDialogManagerJSNativeMethod
-import com.adealink.weparty.cocosgame.web.CocosGameWebView
-import com.adealink.weparty.module.gamehub.carrom.method.OnCarromShowDialogJsMethod
-import com.adealink.weparty.module.gamehub.ludo.method.OnLudoShowDialogJsMethod
-import com.adealink.weparty.module.gamehub.uno.method.OnUnoShowDialogJsMethod
-import com.adealink.weparty.webview.jsbridge.method.KVStorageSetJSNativeMethod
-import com.adealink.weparty.webview.jsnativemethod.KVStorageGetJSNativeMethod
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.launch
-import java.lang.ref.WeakReference
-
-
-/**
- * Cocos游戏服务通知
- * game_[游戏代码]_XXX ---> 小写的是游戏底层通知
- *
- * GAME_[游戏代码]_XXX ---> 大写的是游戏业务上层通知
- */
-const val COCOS_NOTIFY_PREFIX = "game"
-
-const val COCOS_TRICKY_EMOTION_NOTIFY = "game_ludo_emotion_broadcast"
-
-class CocosWebGameManager(private val l: ICocosGameListener) :
-    ICocosWebGameManager,
-    OnNetworkListener {
-
-    private var webViewRef: WeakReference<CocosGameWebView>? = null
-
-    @Volatile
-    private var gameInit: Boolean = false
-    private var startGameData: StartGameData? = null
-    private var gameMetaDataJson: String? = null
-    private var gameId: String? = null
-    private var gamePlayerMap: MutableMap<Long, GamePlayerInfo> = hashMapOf()
-    private var playerAvatarSizePx: Int = 0
-
-    //用于区分游戏广播
-    private var gameCode: String? = null
-
-    private val notifyInterceptor = object : INotifyInterceptor {
-
-        override fun intercept(uri: String, data: String, msg: String): Boolean {
-            Log.d(TAG_COCOS_GAME_WEB_NETWORK, "notifyInterceptor, uri:$uri, data:$data, msg: $msg")
-            if (uri == COCOS_TRICKY_EMOTION_NOTIFY) {
-                //游戏内整蛊表情
-                networkNotify(msg)
-                return true
-            }
-            val currentGameCode = gameCode
-            if (currentGameCode.isNullOrEmpty()) {
-                Log.d(TAG_COCOS_GAME_WEB_NETWORK, "notifyInterceptor, uri:$uri, intercept")
-                return true
-            }
-            val uriSplits = uri.split("_")
-            if (uriSplits.size < 3) {
-                Log.d(TAG_COCOS_GAME_WEB_NETWORK, "notifyInterceptor, uri:$uri, uri is not valid")
-                return false
-            }
-
-            val handle = COCOS_NOTIFY_PREFIX == uriSplits[0] && currentGameCode == uriSplits[1]
-            if (handle && uriSplits[2] == "start") {
-                /**
-                 * game_XXX_start 交由业务上层处理, 底层不处理
-                 */
-                Log.d(TAG_COCOS_GAME_WEB_NETWORK, "notifyInterceptor, uri:$uri, game start notify")
-                return false
-            }
-
-            if (handle) {
-                networkNotify(msg)
-            }
-            Log.d(TAG_COCOS_GAME_WEB_NETWORK, "notifyInterceptor, uri:$uri, handle:$handle")
-            return handle
-        }
-
-    }
-
-    override fun setWebView(webView: CocosGameWebView) {
-        webViewRef = WeakReference(webView)
-    }
-
-    override fun onWebBroadcast(data: String) {
-        Log.i(TAG_COCOS_GAME_WEB_FLOW, "onWebBroadcast, data:${data}")
-        callGame("onWebBroadcast", data)
-    }
-
-    override fun initGame(data: InitGameData) {
-        Log.i(TAG_COCOS_GAME_WEB_FLOW, "initGame, data:${data}")
-        gameCode = data.game.code
-        playerAvatarSizePx = data.avatarSizePx
-        val webView = webViewRef?.get()
-        if (webView != null) {
-            //游戏生命进程回调
-            webView.addJSNativeMethod(OnGetGameViewJsMethod(l) {
-                onGameInit()
-            })
-            webView.addJSNativeMethod(OnGameStartJsMethod(l))
-            webView.addJSNativeMethod(OnInitNodeViewJsMethod(l))
-            webView.addJSNativeMethod(OnGameEndJsMethod(l))
-            webView.addJSNativeMethod(OnNetworkRequestJsMethod {
-                gameMetaDataJson
-            })
-
-            //游戏业务回调
-            webView.addJSNativeMethod(OnGameOpJsMethod(l))
-            webView.addJSNativeMethod(OnGetCurrencyJsMethod())
-            when (data.game) {
-                Game.LUDO -> {
-                    webView.addJSNativeMethod(OnLudoShowDialogJsMethod(l) {
-                        return@OnLudoShowDialogJsMethod gamePlayerMap.toMap()
-                    })
-                }
-                Game.CARROM -> {
-                    webView.addJSNativeMethod(OnCarromShowDialogJsMethod(l) {
-                        return@OnCarromShowDialogJsMethod gamePlayerMap.toMap()
-                    })
-                }
-                Game.UNO -> {
-                    webView.addJSNativeMethod(OnUnoShowDialogJsMethod(l) {
-                        return@OnUnoShowDialogJsMethod gamePlayerMap.toMap()
-                    })
-                }
-//                Game.DOMINO -> {
-//                    webView.addJSNativeMethod(OnDominoShowDialogJsMethod(l) {
-//                        return@OnDominoShowDialogJsMethod gamePlayerMap.toMap()
-//                    })
-//                }
-            }
-            webView.addJSNativeMethod(OnDismissJsMethod(l))
-            webView.addJSNativeMethod(OnDeeplinkJsMethod(webView))
-            webView.addJSNativeMethod(OnLogJsMethod())
-            webView.addJSNativeMethod(OnStatJsMethod())
-            webView.addJSNativeMethod(OnGameRecoverFailJsMethod(l))
-            webView.addJSNativeMethod(OnGetAppEnvJsMethod())
-            webView.addJSNativeMethod(OnNodeVisibleChangedJsMethod(l))
-            webView.addJSNativeMethod(KVStorageGetJSNativeMethod())
-            webView.addJSNativeMethod(KVStorageSetJSNativeMethod())
-            webView.addJSNativeMethod(PauseDialogManagerJSNativeMethod())
-            webView.addJSNativeMethod(ResumeDialogManagerJSNativeMethod())
-            App.instance.networkService.addNotifyInterceptor(notifyInterceptor)
-            registerNetworkListener(this)
-        }
-    }
-
-    override fun isGameInit(): Boolean {
-        return gameInit
-    }
-
-    fun onGameInit() {
-        Log.i(TAG_COCOS_GAME_WEB_FLOW, "onGameInit")
-        gameInit = true
-        l.onGameInit()
-        val startGameData = startGameData ?: return
-        doStartGame(startGameData)
-        this.startGameData = null
-    }
-
-    override fun startGame(data: StartGameData) {
-        CoroutineScope(Dispatcher.UI).launch {
-            Log.i(TAG_COCOS_GAME_WEB_FLOW, "startGame, data:${data}")
-            gameId = data.gameId
-            gamePlayerMap = data.gamePlayerMap?.toMutableMap() ?: mutableMapOf()
-            gameMetaDataJson = data.gameMetaData
-            Log.i(TAG_COCOS_GAME_WEB_FLOW, "enterGame, data:${data}")
-            if (gameInit) {
-                doStartGame(data)
-            } else {
-                startGameData = data
-            }
-        }
-    }
-
-    private fun doStartGame(data: StartGameData) {
-        Log.i(TAG_COCOS_GAME_WEB_FLOW, "doStartGame, data:${data}")
-        resetGame(RestGameData())
-        callGame("startGame", data)
-    }
-
-    override fun opGame(op: NativeToGameOp, data: BaseOpData, callback: ICallback<Any>?) {
-        callGame("opGame", NativeToGameOpData(op.op, data), callback)
-    }
-
-    override fun networkNotify(data: String) {
-        Log.i(TAG_COCOS_GAME_WEB_NETWORK, "notify, data:$data")
-        callGame("networkNotify", data)
-    }
-
-    override fun resetGame(data: RestGameData) {
-        Log.i(TAG_COCOS_GAME_WEB_FLOW, "resetGame, data:${data}")
-        callGame("resetGame", data)
-    }
-
-    override fun getGamePlayers(): Map<Long, GamePlayerInfo> {
-        return gamePlayerMap
-    }
-
-    @Suppress("UNCHECKED_CAST")
-    override fun getPlayerGameStatus(uid: Long, callback: ICallback<PlayerStatus>) {
-
-        val c = object : ICallback<PlayerStatusData> {
-
-            override fun onSuccess(data: PlayerStatusData) {
-                callback.onSuccess(PlayerStatus.map(data.status))
-            }
-
-            override fun onFailed(code: Int) {
-                callback.onFailed(code)
-            }
-
-        }
-        callGame("getPlayerGameStatus", PlayerData(uid), c as ICallback<Any>)
-    }
-
-    override fun getPlayerAvatarSizeInPx(): Int {
-        return playerAvatarSizePx
-    }
-
-    @Suppress("UNCHECKED_CAST")
-    override fun getPlayerAvatarView(uid: Long, callback: ICallback<CocosViewData>) {
-        val c = object : ICallback<CocosViewData> {
-
-            override fun onSuccess(data: CocosViewData) {
-                callback.onSuccess(data)
-            }
-
-            override fun onFailed(code: Int) {
-                callback.onFailed(code)
-            }
-
-        }
-        callGame("getPlayerAvatarView", PlayerData(uid), c as ICallback<Any>)
-    }
-
-    @Suppress("UNCHECKED_CAST")
-    override fun getNodeView(type: NodeViewType, callback: ICallback<CocosViewData>) {
-        val c = object : ICallback<CocosViewData> {
-
-            override fun onSuccess(data: CocosViewData) {
-                callback.onSuccess(data)
-            }
-
-            override fun onFailed(code: Int) {
-                callback.onFailed(code)
-            }
-
-        }
-        callGame("getNodeView", NodeViewData(type.type), c as ICallback<Any>)
-    }
-
-    @Suppress("UNCHECKED_CAST")
-    override fun getGameRecord(callback: ICallback<GameRecordData>) {
-        val c = object : ICallback<GameRecordData> {
-
-            override fun onSuccess(data: GameRecordData) {
-                callback.onSuccess(data)
-            }
-
-            override fun onFailed(code: Int) {
-                callback.onFailed(code)
-            }
-
-        }
-        callGame("getGameRecord", EmptyData(), c as ICallback<Any>)
-    }
-
-    override fun onNetChanged(available: Boolean) {
-        callGame("networkStatus", NetworkStatusData(available))
-    }
-
-    private fun callGame(
-        methodName: String,
-        data: Any,
-        callback: ICallback<Any>? = null
-    ) {
-        if (!gameInit) {
-            Log.e(
-                TAG_COCOS_GAME_WEB_CALL,
-                "callGame, game not init, methodName:${methodName} data:${data}"
-            )
-            return
-        }
-
-        val jsBridge = webViewRef?.get()?.getJsBridge()
-        jsBridge?.callGame(methodName, data, callback)
-    }
-
-
-    override fun destroyGame() {
-        Log.i(TAG_COCOS_GAME_WEB_FLOW, "destroyGame")
-        App.instance.networkService.removeNotifyInterceptor(notifyInterceptor)
-        unregisterNetworkListener(this)
-        gameInit = false
-        gameId = null
-        gameCode = null
-    }
-}

+ 0 - 47
app/src/main/java/com/adealink/weparty/cocosgame/manager/ICocosWebGameManager.kt

@@ -1,47 +0,0 @@
-package com.adealink.weparty.cocosgame.manager
-
-import com.adealink.frame.game.ICallback
-import com.adealink.weparty.cocosgame.data.BaseOpData
-import com.adealink.weparty.cocosgame.data.CocosViewData
-import com.adealink.weparty.cocosgame.data.GamePlayerInfo
-import com.adealink.weparty.cocosgame.data.GameRecordData
-import com.adealink.weparty.cocosgame.data.InitGameData
-import com.adealink.weparty.cocosgame.data.NativeToGameOp
-import com.adealink.weparty.cocosgame.data.NodeViewType
-import com.adealink.weparty.cocosgame.data.PlayerStatus
-import com.adealink.weparty.cocosgame.data.RestGameData
-import com.adealink.weparty.cocosgame.data.StartGameData
-import com.adealink.weparty.cocosgame.web.CocosGameWebView
-
-interface ICocosWebGameManager {
-
-    fun initGame(data: InitGameData)
-
-    fun isGameInit(): Boolean
-
-    fun startGame(data: StartGameData)
-
-    fun opGame(op: NativeToGameOp, data: BaseOpData, callback: ICallback<Any>?)
-
-    fun networkNotify(data: String)
-
-    fun resetGame(data: RestGameData)
-
-    fun getGamePlayers(): Map<Long, GamePlayerInfo>
-
-    fun getPlayerGameStatus(uid: Long, callback: ICallback<PlayerStatus>)
-
-    fun getPlayerAvatarSizeInPx(): Int
-
-    fun getPlayerAvatarView(uid: Long, callback: ICallback<CocosViewData>)
-
-    fun getNodeView(type: NodeViewType, callback: ICallback<CocosViewData>)
-
-    fun getGameRecord(callback: ICallback<GameRecordData>)
-
-    fun destroyGame()
-
-    fun setWebView(webView: CocosGameWebView)
-
-    fun onWebBroadcast(data: String)
-}

+ 0 - 42
app/src/main/java/com/adealink/weparty/cocosgame/manager/listener/ICocosGameListener.kt

@@ -1,42 +0,0 @@
-package com.adealink.weparty.cocosgame.manager.listener
-
-import com.adealink.frame.game.ICallback
-import com.adealink.weparty.cocosgame.data.CocosWindowViewData
-import com.adealink.weparty.cocosgame.data.DialogData
-import com.adealink.weparty.cocosgame.data.GameRecoverFailData
-import com.adealink.weparty.cocosgame.data.GameToNativeOpData
-import com.adealink.weparty.cocosgame.data.InitNodeViewData
-import com.adealink.weparty.cocosgame.data.OnNodeVisibleChangedData
-
-interface ICocosGameListener {
-
-    fun onGetGameView(callback: ICallback<CocosWindowViewData>)
-
-    fun onGameInit()
-
-    /**
-     * 游戏开始
-     */
-    fun onGameStart()
-
-    /**
-     * 游戏结束
-     */
-    fun onGameEnd()
-
-    fun onGameOp(data: GameToNativeOpData)
-
-    fun onShowDialog(data: DialogData)
-
-    fun onDismissDialog(id: Long)
-
-    /**
-     * 初始化游戏节点视图
-     */
-    fun onInitNodeView(data: InitNodeViewData)
-
-    fun onGameRecoverFail(data: GameRecoverFailData)
-
-    fun onNodeVisibleChanged(data: OnNodeVisibleChangedData)
-
-}

+ 0 - 36
app/src/main/java/com/adealink/weparty/cocosgame/method/OnDeeplink.kt

@@ -1,36 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import androidx.core.net.toUri
-import com.adealink.frame.log.Log
-import com.adealink.frame.util.AppUtil
-import com.adealink.frame.util.getParamsFromUri
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB
-import com.adealink.weparty.util.goLocalLinkPage
-import com.adealink.weparty.webview.IWebView
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-import com.google.gson.annotations.SerializedName
-
-private const val METHOD_NAME = "onDeeplink"
-
-data class DeeplinkData(@SerializedName("deeplink") val deeplink: String)
-
-class OnDeeplinkJsMethod(private val webView: IWebView) : JSNativeMethod<DeeplinkData, Any> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: DeeplinkData, callback: JSBridgeCallback<Any>?) {
-        Log.d(TAG_COCOS_GAME_WEB, "onDeeplink, data:${data}")
-        val deeplink = data.deeplink
-        // 是否关闭当前Web窗口(默认值:false)
-        if (deeplink.isNotEmpty()) {
-            val params = getParamsFromUri(deeplink.toUri())
-            val closePrev = params["closePrev"]?.toBooleanStrictOrNull() ?: false
-            if (closePrev) webView.webViewCallback?.closeWebView()
-        }
-        AppUtil.currentActivity?.let {
-            goLocalLinkPage(it, deeplink)
-        }
-    }
-
-}

+ 0 - 22
app/src/main/java/com/adealink/weparty/cocosgame/method/OnDismissDialog.kt

@@ -1,22 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.log.Log
-import com.adealink.weparty.cocosgame.data.DialogIdData
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB
-import com.adealink.weparty.cocosgame.manager.listener.ICocosGameListener
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-
-
-private const val METHOD_NAME = "dismissDialog"
-
-class OnDismissJsMethod(private val c: ICocosGameListener?) : JSNativeMethod<DialogIdData, Any> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: DialogIdData, callback: JSBridgeCallback<Any>?) {
-        Log.d(TAG_COCOS_GAME_WEB, "dismissDialog, data:${data}")
-        c?.onDismissDialog(data.id)
-    }
-
-}

+ 0 - 21
app/src/main/java/com/adealink/weparty/cocosgame/method/OnGameEnd.kt

@@ -1,21 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.log.Log
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB
-import com.adealink.weparty.cocosgame.manager.listener.ICocosGameListener
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-
-
-private const val METHOD_NAME = "onGameEnd"
-
-class OnGameEndJsMethod(private val c: ICocosGameListener?) : JSNativeMethod<Any, Any> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: Any, callback: JSBridgeCallback<Any>?) {
-        Log.d(TAG_COCOS_GAME_WEB, "onGameEnd, data:${data}")
-        c?.onGameEnd()
-    }
-
-}

+ 0 - 22
app/src/main/java/com/adealink/weparty/cocosgame/method/OnGameOp.kt

@@ -1,22 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.log.Log
-import com.adealink.weparty.cocosgame.data.GameToNativeOp
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB
-import com.adealink.weparty.cocosgame.manager.listener.ICocosGameListener
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-
-private const val METHOD_NAME = "onGameOp"
-
-class OnGameOpJsMethod(private val c: ICocosGameListener?) : JSNativeMethod<GameToNativeOp, Any> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: GameToNativeOp, callback: JSBridgeCallback<Any>?) {
-        val opData = data.data ?: return
-        Log.d(TAG_COCOS_GAME_WEB, "onGameOp, data:${opData}")
-        c?.onGameOp(opData)
-    }
-
-}

+ 0 - 24
app/src/main/java/com/adealink/weparty/cocosgame/method/OnGameRecoverFail.kt

@@ -1,24 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.log.Log
-import com.adealink.weparty.cocosgame.data.GameRecoverFailData
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_FLOW
-import com.adealink.weparty.cocosgame.manager.listener.ICocosGameListener
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-
-private const val METHOD_NAME = "onGameRecoverFail"
-
-class OnGameRecoverFailJsMethod(
-    private val c: ICocosGameListener?,
-) : JSNativeMethod<GameRecoverFailData, Any> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: GameRecoverFailData, callback: JSBridgeCallback<Any>?) {
-        Log.d(TAG_COCOS_GAME_FLOW, "OnGameRecoverFail, data:${data}")
-        c?.onGameRecoverFail(data)
-        callback?.resolve(Any())
-    }
-
-}

+ 0 - 20
app/src/main/java/com/adealink/weparty/cocosgame/method/OnGameStart.kt

@@ -1,20 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.log.Log
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB
-import com.adealink.weparty.cocosgame.manager.listener.ICocosGameListener
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-
-private const val METHOD_NAME = "onGameStart"
-
-class OnGameStartJsMethod(private val c: ICocosGameListener?) : JSNativeMethod<Any, Any> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: Any, callback: JSBridgeCallback<Any>?) {
-        Log.d(TAG_COCOS_GAME_WEB, "onGameStart, data:${data}")
-        c?.onGameStart()
-    }
-
-}

+ 0 - 31
app/src/main/java/com/adealink/weparty/cocosgame/method/OnGetAppEnv.kt

@@ -1,31 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.base.AppBase
-import com.adealink.frame.log.Log
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_FLOW
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-import com.google.gson.annotations.SerializedName
-
-/**
- * author : qimingfeng
- * e-mail : qimingfengwy@163.com
- * time   : 2024/9/18
- * desc   : 获取App的环境参数桥接方法
- * version: 1.0
- */
-
-private const val METHOD_NAME = "onGetAppEnv"
-
-data class EnvInfo(@SerializedName("isDebug") val isDebug: Boolean)
-
-class OnGetAppEnvJsMethod: JSNativeMethod<Any, EnvInfo> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: Any, callback: JSBridgeCallback<EnvInfo>?) {
-        Log.d(TAG_COCOS_GAME_FLOW, "$METHOD_NAME, data:${data}")
-        callback?.resolve(EnvInfo(AppBase.isRelease.not()))
-    }
-
-}

+ 0 - 45
app/src/main/java/com/adealink/weparty/cocosgame/method/OnGetCurrency.kt

@@ -1,45 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.coroutine.dispatcher.Dispatcher
-import com.adealink.frame.log.Log
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB
-import com.adealink.weparty.module.wallet.WalletModule
-import com.adealink.weparty.module.wallet.data.Currency
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-import com.google.gson.annotations.SerializedName
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.launch
-
-private const val METHOD_NAME = "onGetCurrency"
-
-data class CurrencyReq(@SerializedName("type") val type: Int)
-
-data class CurrencyRes(@SerializedName("count") val count: Long, @SerializedName("type") val type: Int)
-
-class OnGetCurrencyJsMethod : JSNativeMethod<CurrencyReq, CurrencyRes> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: CurrencyReq, callback: JSBridgeCallback<CurrencyRes>?) {
-        Log.d(TAG_COCOS_GAME_WEB, "onGetCurrency, data:${data}")
-        CoroutineScope(Dispatcher.WENEXT_THREAD_POOL).launch {
-            val currency = Currency.getCurrencyByValue(data.type.toByte())
-            if (currency == null) {
-                callback?.resolve(CurrencyRes(0, data.type))
-                return@launch
-            }
-            when (val result = WalletModule.getCurrencyCount(currency)) {
-                is Rlt.Success -> {
-                    callback?.resolve(CurrencyRes(result.data, data.type))
-                }
-
-                is Rlt.Failed -> {
-                    callback?.resolve(CurrencyRes(0, data.type))
-                }
-            }
-        }
-    }
-
-}

+ 0 - 35
app/src/main/java/com/adealink/weparty/cocosgame/method/OnGetGameView.kt

@@ -1,35 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.game.ICallback
-import com.adealink.frame.log.Log
-import com.adealink.weparty.cocosgame.data.CocosWindowViewData
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB
-import com.adealink.weparty.cocosgame.manager.listener.ICocosGameListener
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.data.JSResponse
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-
-private const val METHOD_NAME = "onGetGameView"
-
-class OnGetGameViewJsMethod(private val c: ICocosGameListener?, private val onGameInit: () -> Unit) :
-    JSNativeMethod<Any, CocosWindowViewData> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: Any, callback: JSBridgeCallback<CocosWindowViewData>?) {
-        Log.d(TAG_COCOS_GAME_WEB, "onGetGameView, data:${data}")
-        c?.onGetGameView(object : ICallback<CocosWindowViewData> {
-
-            override fun onSuccess(data: CocosWindowViewData) {
-                callback?.resolve(data)
-                onGameInit()
-            }
-
-            override fun onFailed(code: Int) {
-                callback?.reject(JSResponse.JSError.CLIENT_ERROR)
-            }
-
-        })
-    }
-
-}

+ 0 - 22
app/src/main/java/com/adealink/weparty/cocosgame/method/OnInitNodeView.kt

@@ -1,22 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.log.Log
-import com.adealink.weparty.cocosgame.data.InitNodeViewData
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB
-import com.adealink.weparty.cocosgame.manager.listener.ICocosGameListener
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-
-private const val METHOD_NAME = "onInitNodeView"
-
-
-class OnInitNodeViewJsMethod(private val c: ICocosGameListener?) : JSNativeMethod<InitNodeViewData, Any> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: InitNodeViewData, callback: JSBridgeCallback<Any>?) {
-        Log.d(TAG_COCOS_GAME_WEB, "onInitNodeView, data:${data}")
-        c?.onInitNodeView(data)
-    }
-
-}

+ 0 - 29
app/src/main/java/com/adealink/weparty/cocosgame/method/OnLog.kt

@@ -1,29 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.log.Log
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-import com.google.gson.annotations.GsonNullable
-import com.google.gson.annotations.SerializedName
-
-private const val METHOD_NAME = "log"
-
-//{tag: "tag_cocos_carrom", msg: `${message}`, xlog: true}
-data class CocosLog(
-    @GsonNullable
-    @SerializedName("tag")
-    val tag: String?,
-    @GsonNullable
-    @SerializedName("msg")
-    val msg: String?,
-)
-
-class OnLogJsMethod : JSNativeMethod<CocosLog, Any> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: CocosLog, callback: JSBridgeCallback<Any>?) {
-        Log.d(data.tag ?: "tag_cocos_web", data.msg ?: "")
-    }
-
-}

+ 0 - 106
app/src/main/java/com/adealink/weparty/cocosgame/method/OnNetworkRequest.kt

@@ -1,106 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.base.Callback
-import com.adealink.frame.game.GameErrorCode
-import com.adealink.frame.log.Log
-import com.adealink.frame.util.getJSONObject
-import com.adealink.weparty.App
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-import com.google.gson.annotations.SerializedName
-import retrofit2.Constants
-
-private const val METHOD_NAME = "onNetworkRequest"
-
-data class NetworkData(
-    @SerializedName("data") val data: String,
-)
-
-enum class NetworkType(var type: Int) {
-    UNKNOWN(-1),
-    HTTP(0),
-    SOCKET(1);
-
-    companion object {
-        fun map(type: Int?): NetworkType {
-            return values().firstOrNull { it.type == type } ?: UNKNOWN
-        }
-    }
-}
-
-class OnNetworkRequestJsMethod(val getGameMeta: () -> String?) :
-    JSNativeMethod<String, NetworkData> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: String, callback: JSBridgeCallback<NetworkData>?) {
-        Log.d(TAG_COCOS_GAME_WEB, "onNetworkRequest, data:${data}")
-        val dataJSONObject = data.getJSONObject()
-        if (dataJSONObject == null) {
-            callback?.reject(GameErrorCode.DATA_PARSE_ERROR.code)
-            return
-        }
-
-        val dataJson = dataJSONObject.optJSONObject("data")?.toString()
-        if (dataJson.isNullOrEmpty()) {
-            callback?.reject(GameErrorCode.DATA_PARSE_ERROR.code)
-            return
-        }
-
-        val type = dataJSONObject.optInt("type")
-        when (NetworkType.map(type)) {
-            NetworkType.HTTP -> {
-                val method = dataJSONObject.optString("method").ifEmpty { "POST" }
-                val path = dataJSONObject.optString("path")
-                if (path.isNullOrEmpty()) {
-                    callback?.reject(GameErrorCode.HTTP_PATH_NULL_ERROR.code)
-                    return
-                }
-
-                val url = "${App.instance.networkService.baseUrl}${path.removePrefix("api/")}"
-                val headers = hashMapOf<String, String>()
-                getGameMeta()?.let {
-                    headers["game_meta_data"] = it
-                    headers[Constants.KEY_CORE_REQ] = Constants.CORE_REQ_VALUE
-                }
-                App.instance.networkService.http(
-                    method,
-                    url,
-                    headers,
-                    dataJson,
-                    null,
-                    object : Callback<String> {
-
-                        override fun onCall(t: String?) {
-                            if (t.isNullOrEmpty()) {
-                                callback?.reject(GameErrorCode.DATA_NULL_ERROR.code)
-                                return
-                            }
-
-                            callback?.resolve(NetworkData(t))
-                        }
-
-                    })
-            }
-
-            NetworkType.SOCKET -> {
-                App.instance.networkService.send(dataJson, object : Callback<String> {
-                    override fun onCall(t: String?) {
-                        if (t.isNullOrEmpty()) {
-                            callback?.reject(GameErrorCode.DATA_NULL_ERROR.code)
-                            return
-                        }
-
-                        callback?.resolve(NetworkData(t))
-                    }
-                })
-            }
-
-            NetworkType.UNKNOWN -> {
-                callback?.reject(GameErrorCode.UNKNOWN_NETWORK_TYPE.code)
-            }
-        }
-    }
-
-}

+ 0 - 25
app/src/main/java/com/adealink/weparty/cocosgame/method/OnNodeVisibleChanged.kt

@@ -1,25 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.log.Log
-import com.adealink.weparty.cocosgame.data.OnNodeVisibleChangedData
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_FLOW
-import com.adealink.weparty.cocosgame.manager.listener.ICocosGameListener
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-
-private const val METHOD_NAME = "onNodeVisibleChanged"
-
-
-class OnNodeVisibleChangedJsMethod(
-    private val c: ICocosGameListener?,
-) : JSNativeMethod<OnNodeVisibleChangedData, Any> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: OnNodeVisibleChangedData, callback: JSBridgeCallback<Any>?) {
-        Log.d(TAG_COCOS_GAME_FLOW, "OnNodeVisibleChanged, data:${data}")
-        c?.onNodeVisibleChanged(data)
-        callback?.resolve(Any())
-    }
-
-}

+ 0 - 38
app/src/main/java/com/adealink/weparty/cocosgame/method/OnStat.kt

@@ -1,38 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.frame.log.Log
-import com.adealink.frame.statistics.BaseStatEvent
-import com.adealink.frame.statistics.CommonEventKey
-import com.adealink.frame.statistics.IEventValue
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-import com.google.gson.annotations.Must
-import com.google.gson.annotations.SerializedName
-
-private const val METHOD_NAME = "stat"
-
-data class StatReq(
-    @Must
-    @SerializedName("event_id") val eventId: String,
-    @Must
-    @SerializedName("events") val events: Map<String, String>)
-
-class OnStatJsMethod : JSNativeMethod<StatReq, Any> {
-
-    override val methodName: String = METHOD_NAME
-
-    override fun handleMethodCall(data: StatReq, callback: JSBridgeCallback<Any>?) {
-        Log.d(TAG_COCOS_GAME_WEB, "OnStat, data:${data}")
-        val event = object : BaseStatEvent(data.eventId) {
-            override val action = object : IEventValue {
-                override val value: String = data.events.getOrElse(CommonEventKey.ACTION) { "" }
-                override val desc: String = ""
-            }
-        }
-        event.addEventMap(data.events)
-        event.send()
-        callback?.resolve(Any())
-    }
-
-}

+ 0 - 26
app/src/main/java/com/adealink/weparty/cocosgame/method/PauseDialogManagerJSNativeMethod.kt

@@ -1,26 +0,0 @@
-package com.adealink.weparty.cocosgame.method
-
-import com.adealink.weparty.commonui.dialogchain.DialogShowManager
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-
-/**
- * 调用了pause之后,必须记得resume
- * Created by XiaoDongLin.
- * Date: 2025/7/15
- */
-class PauseDialogManagerJSNativeMethod : JSNativeMethod<Any, Any> {
-    override val methodName: String = "PauseDialogManager"
-
-    override fun handleMethodCall(data: Any, callback: JSBridgeCallback<Any>?) {
-        DialogShowManager.pause()
-    }
-}
-
-class ResumeDialogManagerJSNativeMethod : JSNativeMethod<Any, Any> {
-    override val methodName: String = "ResumeDialogManager"
-
-    override fun handleMethodCall(data: Any, callback: JSBridgeCallback<Any>?) {
-        DialogShowManager.resume()
-    }
-}

+ 0 - 39
app/src/main/java/com/adealink/weparty/cocosgame/util/CocosGameUtil.kt

@@ -1,39 +0,0 @@
-package com.adealink.weparty.cocosgame.util
-
-
-//fun GamePlayerInfo.getUserCommonConfigInfo(): Map<Int, UserCommonConfigInfo> {
-//    val map = userGameGoodsMap ?: return emptyMap()
-//    val userCommonConfigMap = mutableMapOf<Int, UserCommonConfigInfo>()
-//    map.onEach {
-//        userCommonConfigMap[it.key] = UserCommonConfigInfo(
-//            it.value.type,
-//            it.value.intDataValue1,
-//            it.value.intDataValue2,
-//            it.value.intDataValue3,
-//            it.value.intDataValue4,
-//            it.value.intDataValue5,
-//            it.value.intDataValue6,
-//            it.value.intDataValue7,
-//            it.value.intDataValue8,
-//            it.value.intDataValue9,
-//            it.value.stringDataValue1,
-//            it.value.stringDataValue2,
-//            it.value.stringDataValue3,
-//            it.value.floatDataValue,
-//            it.value.configValue,
-//            it.value.expireTime,
-//            it.value.ts
-//        )
-//    }
-//    return userCommonConfigMap
-//}
-//
-//
-//fun UserInfo.getGamePlayerInfo(): GamePlayerInfo {
-//    return GamePlayerInfo().apply {
-//        playerId = uid
-//        playerAvatarUrl = url ?: ""
-//        avatarDynamicUrl = avatarDynamicUrl ?: ""
-//        playerName = name ?: ""
-//    }
-//}

+ 0 - 370
app/src/main/java/com/adealink/weparty/cocosgame/viewmodel/BaseCocosWebGameViewModel.kt

@@ -1,370 +0,0 @@
-package com.adealink.weparty.cocosgame.viewmodel
-
-import android.annotation.SuppressLint
-import android.content.Context
-import android.os.Vibrator
-import android.view.View
-import androidx.annotation.CallSuper
-import androidx.lifecycle.LiveData
-import com.adealink.frame.base.AppBase
-import com.adealink.frame.base.IError
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.ext.doOnGlobalLayout
-import com.adealink.frame.game.ICallback
-import com.adealink.frame.locale.language.languageManager
-import com.adealink.frame.log.Log
-import com.adealink.frame.mvvm.livedata.ExtLiveData
-import com.adealink.frame.mvvm.livedata.ExtMutableLiveData
-import com.adealink.frame.mvvm.livedata.OnceMutableLiveData
-import com.adealink.frame.mvvm.viewmodel.BaseViewModel
-import com.adealink.frame.util.AppUtil
-import com.adealink.frame.util.getHost
-import com.adealink.frame.util.getLocationInWindow
-import com.adealink.frame.util.runOnUiThread
-import com.adealink.weparty.App
-import com.adealink.weparty.cocosgame.data.BaseOpData
-import com.adealink.weparty.cocosgame.data.CocosPosition
-import com.adealink.weparty.cocosgame.data.CocosViewData
-import com.adealink.weparty.cocosgame.data.CocosViewSize
-import com.adealink.weparty.cocosgame.data.CocosWindowSafeArea
-import com.adealink.weparty.cocosgame.data.CocosWindowViewData
-import com.adealink.weparty.cocosgame.data.DialogData
-import com.adealink.weparty.cocosgame.data.Game
-import com.adealink.weparty.cocosgame.data.GamePlayerInfo
-import com.adealink.weparty.cocosgame.data.GameRecoverFailData
-import com.adealink.weparty.cocosgame.data.GameToNativeOpData
-import com.adealink.weparty.cocosgame.data.InitGameData
-import com.adealink.weparty.cocosgame.data.InitNodeViewData
-import com.adealink.weparty.cocosgame.data.NativeToGameOp
-import com.adealink.weparty.cocosgame.data.NodeViewType
-import com.adealink.weparty.cocosgame.data.OnNodeVisibleChangedData
-import com.adealink.weparty.cocosgame.data.OpMicStatusData
-import com.adealink.weparty.cocosgame.data.PlaySoundOpData
-import com.adealink.weparty.cocosgame.data.PlayerStatus
-import com.adealink.weparty.cocosgame.data.StopSoundOpData
-import com.adealink.weparty.cocosgame.data.SwitchSoundOpData
-import com.adealink.weparty.cocosgame.data.SwitchVibrateOpData
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB_FLOW
-import com.adealink.weparty.cocosgame.data.VibrateOpData
-import com.adealink.weparty.cocosgame.data.VibrateType
-import com.adealink.weparty.cocosgame.manager.CocosWebGameManager
-import com.adealink.weparty.cocosgame.manager.listener.ICocosGameListener
-import com.adealink.weparty.cocosgame.web.CocosGameWebView
-import com.adealink.weparty.module.account.AccountModule
-import com.adealink.weparty.module.room.RoomModule
-import com.adealink.weparty.module.sound.data.getGameSound
-import com.adealink.weparty.module.webview.WebModule
-import com.adealink.weparty.module.webview.listener.IWebBroadcastListener
-import com.adealink.weparty.sound.SoundScene
-import com.adealink.weparty.sound.manager.soundManager
-import com.adealink.weparty.webview.jsbridge.data.WebBroadcastData
-
-@SuppressLint("StaticFieldLeak")
-abstract class BaseCocosWebGameViewModel<GameType, GameMode, MagicMode, PlayerCount> :
-    BaseViewModel(),
-    IBaseCocosWebGameViewModel<GameType, GameMode, MagicMode, PlayerCount>,
-    ICocosGameListener, IWebBroadcastListener {
-
-    abstract val game: Game
-
-    override val gameTypeLD: ExtLiveData<GameType> = ExtMutableLiveData()
-    override val gameModelLD: ExtLiveData<GameMode> = ExtMutableLiveData()
-    override val magicModeLD: ExtLiveData<MagicMode> = ExtMutableLiveData()
-    override val playerCountLD: ExtLiveData<PlayerCount> = ExtMutableLiveData()
-
-    override val onGameInitLD: ExtLiveData<Unit> = ExtMutableLiveData()
-    override val gameToNativeOpLD: ExtLiveData<GameToNativeOpData> = ExtMutableLiveData()
-    override val showDialogLD: ExtLiveData<DialogData> = ExtMutableLiveData()
-    override val dismissDialogLD: ExtLiveData<Long> = ExtMutableLiveData()
-    override val emotionBtnNodeViewLD: ExtLiveData<CocosViewData> = ExtMutableLiveData()
-    override val emotionBtnNodeVisibleLD: ExtLiveData<Boolean> = ExtMutableLiveData()
-    override val messageBtnNodeViewLD: ExtLiveData<CocosViewData> = ExtMutableLiveData()
-    override val messageBtnNodeVisibleLD: ExtLiveData<Boolean> = ExtMutableLiveData()
-    override val rankBtnNodeViewLD: ExtLiveData<CocosViewData> = ExtMutableLiveData()
-    override val settingBtnNodeViewLD: ExtLiveData<CocosViewData> = ExtMutableLiveData()
-    override val bottomBtnsAreaNodeViewLD: ExtLiveData<CocosViewData> = ExtMutableLiveData()
-    override val topBarAreaNodeViewLD: ExtLiveData<CocosViewData> = ExtMutableLiveData()
-    override val bottomBarAreaNodeViewLD: ExtLiveData<CocosViewData> = ExtMutableLiveData()
-
-    override val gameRecoverFailLD: ExtLiveData<GameRecoverFailData> = ExtMutableLiveData()
-
-    private var gameContainer: CocosGameWebView? = null
-    private var safeView: View? = null
-    val cocosGameManager by lazy { CocosWebGameManager(this) }
-
-    private val vibrator: Vibrator? by lazy {
-        AppUtil.getSystemService<Vibrator>(Context.VIBRATOR_SERVICE)
-    }
-
-    @CallSuper
-    override fun onCleared() {
-        super.onCleared()
-        gameContainer = null
-        safeView = null
-        WebModule.unRegisterBroadcast(this)
-    }
-
-    open fun onCreate() {
-
-    }
-
-    open fun onDestroy() {
-
-    }
-
-    @CallSuper
-    override fun initGame(gameContainer: CocosGameWebView, boardView: View, data: InitGameData) {
-        Log.d(TAG_COCOS_GAME_WEB_FLOW, "initGame, boardView:$boardView, data:$data")
-        this.gameContainer = gameContainer
-        this.safeView = boardView
-        cocosGameManager.setWebView(gameContainer)
-        cocosGameManager.initGame(data)
-    }
-
-    override fun onGameInit() {
-        onGameInitLD.send(Unit)
-    }
-
-    override fun onGetGameView(callback: ICallback<CocosWindowViewData>) {
-        Log.d(TAG_COCOS_GAME_WEB_FLOW, "onGetGameView()")
-        runOnUiThread {
-            val container = gameContainer ?: return@runOnUiThread
-            val gameViewWidth = container.measuredWidth
-            val gameViewHeight = container.measuredHeight
-            if (gameViewWidth > 0 && gameViewHeight > 0) {
-                onGameContainerSizeGet(
-                    CocosViewSize(
-                        gameViewWidth.toFloat(),
-                        gameViewHeight.toFloat()
-                    ), callback
-                )
-            } else {
-                container.doOnGlobalLayout {
-                    onGameContainerSizeGet(
-                        CocosViewSize(
-                            container.measuredWidth.toFloat(),
-                            container.measuredHeight.toFloat()
-                        ), callback
-                    )
-                }
-            }
-        }
-    }
-
-    private fun onGameContainerSizeGet(
-        viewSize: CocosViewSize,
-        callback: ICallback<CocosWindowViewData>
-    ) {
-        Log.d(TAG_COCOS_GAME_WEB_FLOW, "onGameContainerSizeGet()")
-        val safeView = safeView ?: return
-        val safeViewWidth = safeView.measuredWidth
-        val safeViewHeight = safeView.measuredHeight
-        if (safeViewWidth > 0 && safeViewHeight > 0) {
-            val pos = safeView.getLocationInWindow()
-            onAllGameViewSizeGet(
-                viewSize,
-                CocosWindowSafeArea(
-                    CocosPosition(pos[0].toFloat(), pos[1].toFloat()),
-                    CocosViewSize(safeViewWidth.toFloat(), safeViewHeight.toFloat())
-                ),
-                callback
-            )
-        } else {
-            safeView.doOnGlobalLayout {
-                val pos = safeView.getLocationInWindow()
-                onAllGameViewSizeGet(
-                    viewSize, CocosWindowSafeArea(
-                        CocosPosition(pos[0].toFloat(), pos[1].toFloat()),
-                        CocosViewSize(safeViewWidth.toFloat(), safeViewHeight.toFloat())
-                    ), callback
-                )
-            }
-        }
-    }
-
-    private fun onAllGameViewSizeGet(
-        viewSize: CocosViewSize,
-        safeArea: CocosWindowSafeArea,
-        callback: ICallback<CocosWindowViewData>,
-    ) {
-        callback.onSuccess(
-            CocosWindowViewData(
-                soundManager.isSoundOpen(SoundScene.GameTab),
-                soundManager.isVibrationOpen(SoundScene.GameTab),
-                languageManager?.getLanguageCode() ?: "en",
-                viewSize,
-                safeArea,
-                AccountModule.token,
-                App.instance.networkService.baseUrl,
-                RoomModule.getJoinedRoomId() ?: 0,
-                wsUrl = when {
-                    AppBase.isProdEnv -> "wss://${getHost(App.instance.networkService.baseUrl)}/api/gamewebsocket"
-                    else -> "ws://${getHost(App.instance.networkService.baseUrl)}/api/gamewebsocket"
-                }
-            )
-        )
-    }
-
-    override fun onGameStart() {
-        Log.d(TAG_COCOS_GAME_WEB_FLOW, "onGameStart")
-        RoomModule.getRoomGamePlayerMicStatus().onEach {
-            opGame(NativeToGameOp.MIC_STATUS, OpMicStatusData(it.uid, it.micStatus.status))
-        }
-    }
-
-    override fun onGameOp(data: GameToNativeOpData) {
-        Log.d(TAG_COCOS_GAME_WEB_FLOW, "onGameOp, $data")
-        when (data) {
-            is VibrateOpData -> vibrate(data)
-            is PlaySoundOpData -> {
-                App.instance.soundPlayer.play(getGameSound(game, data.soundName))
-            }
-
-            is StopSoundOpData -> {
-                App.instance.soundPlayer.stop(getGameSound(game, data.soundName))
-            }
-
-            is SwitchSoundOpData -> soundManager.switchSound(SoundScene.GameTab)
-            is SwitchVibrateOpData -> soundManager.switchVibration(SoundScene.GameTab)
-            else -> gameToNativeOpLD.send(data, false)
-        }
-    }
-
-    private fun vibrate(data: VibrateOpData) {
-        if (!soundManager.isVibrationOpen(SoundScene.GameTab)) {
-            return
-        }
-
-        if (vibrator?.hasVibrator() != true) {
-            return
-        }
-
-        try {
-            when (VibrateType.map(data.duration)) {
-                VibrateType.LONG -> {
-                    vibrator?.vibrate(500)
-                }
-
-                VibrateType.SHORT -> {
-                    vibrator?.vibrate(200)
-                }
-
-                VibrateType.CUSTOM -> {
-                    vibrator?.vibrate(data.duration)
-                }
-            }
-        } catch (_: Exception) {
-
-        }
-    }
-
-    override fun onShowDialog(data: DialogData) {
-        Log.d(TAG_COCOS_GAME_WEB_FLOW, "onShowDialog, $data")
-        showDialogLD.send(data, false)
-    }
-
-    override fun onDismissDialog(id: Long) {
-        Log.d(TAG_COCOS_GAME_WEB_FLOW, "onDismissDialog, $id")
-        dismissDialogLD.send(id, false)
-    }
-
-    override fun onInitNodeView(data: InitNodeViewData) {
-        Log.d(TAG_COCOS_GAME_WEB_FLOW, "onInitNodeView, $data")
-        val view = data.data ?: return
-        when (data.type) {
-            NodeViewType.EMOTION_BTN -> emotionBtnNodeViewLD.send(view, false)
-            NodeViewType.MESSAGE_BTN -> messageBtnNodeViewLD.send(view, false)
-            NodeViewType.RANK_BTN -> rankBtnNodeViewLD.send(view, false)
-            NodeViewType.SETTING_BTN -> settingBtnNodeViewLD.send(view, false)
-            NodeViewType.BOTTOM_BTNS_AREA -> bottomBtnsAreaNodeViewLD.send(view, false)
-            NodeViewType.TOP_BAR_AREA -> topBarAreaNodeViewLD.send(view, false)
-            NodeViewType.BOTTOM_BAR_AREA -> bottomBarAreaNodeViewLD.send(view, false)
-            NodeViewType.UNKNOWN -> {}
-        }
-    }
-
-    override fun onNodeVisibleChanged(data: OnNodeVisibleChangedData) {
-        Log.d(TAG_COCOS_GAME_WEB_FLOW, "onNodeVisibleChanged, $data")
-        when (data.type) {
-            NodeViewType.EMOTION_BTN.type -> emotionBtnNodeVisibleLD.send(data.isVisible(), false)
-            NodeViewType.MESSAGE_BTN.type -> messageBtnNodeVisibleLD.send(data.isVisible(), false)
-        }
-    }
-
-    override fun onGameEnd() {
-        Log.d(TAG_COCOS_GAME_WEB_FLOW, "onGameEnd")
-    }
-
-    override fun opGame(op: NativeToGameOp, data: BaseOpData) {
-        Log.d(TAG_COCOS_GAME_WEB_FLOW, "opGame, op:$op, data:$data")
-        cocosGameManager.opGame(op, data, null)
-    }
-
-    override fun getPlayerAvatarView(playerId: Long): LiveData<Rlt<CocosViewData>> {
-        val liveData = OnceMutableLiveData<Rlt<CocosViewData>>()
-        cocosGameManager.getPlayerAvatarView(playerId, object : ICallback<CocosViewData> {
-
-            override fun onSuccess(data: CocosViewData) {
-                liveData.send(Rlt.Success(data))
-            }
-
-            override fun onFailed(code: Int) {
-                liveData.send(Rlt.Failed(IError(serverCode = code)))
-            }
-
-        })
-        return liveData
-    }
-
-    override fun getNodeView(type: NodeViewType): LiveData<Rlt<CocosViewData>> {
-        val liveData = OnceMutableLiveData<Rlt<CocosViewData>>()
-        cocosGameManager.getNodeView(type, object : ICallback<CocosViewData> {
-
-            override fun onSuccess(data: CocosViewData) {
-                liveData.send(Rlt.Success(data))
-            }
-
-            override fun onFailed(code: Int) {
-                liveData.send(Rlt.Failed(IError(serverCode = code)))
-            }
-
-        })
-        return liveData
-    }
-
-    override fun getPlayerGameStatus(uid: Long): LiveData<PlayerStatus> {
-        val liveData = OnceMutableLiveData<PlayerStatus>()
-        cocosGameManager.getPlayerGameStatus(uid, object : ICallback<PlayerStatus> {
-
-            override fun onSuccess(data: PlayerStatus) {
-                liveData.send(data)
-            }
-
-            override fun onFailed(code: Int) {
-                liveData.send(PlayerStatus.GAME_EXIT)
-            }
-
-        })
-        return liveData
-    }
-
-    override fun getPlayerInfo(uid: Long): GamePlayerInfo? {
-        return cocosGameManager.getGamePlayers()[uid]
-    }
-
-    override fun onGameRecoverFail(data: GameRecoverFailData) {
-        gameRecoverFailLD.send(data)
-    }
-
-    override fun webBroadcast(data: WebBroadcastData) {
-        WebModule.webBroadcast(data)
-    }
-
-    override fun onWebBroadcast(data: WebBroadcastData) {
-        cocosGameManager.onWebBroadcast(data.data)
-    }
-
-    override fun getSenderId(): String {
-        return hashCode().toString()
-    }
-}

+ 0 - 42
app/src/main/java/com/adealink/weparty/cocosgame/viewmodel/CocosGameUserLeagueViewModel.kt

@@ -1,42 +0,0 @@
-package com.adealink.weparty.cocosgame.viewmodel
-
-import androidx.lifecycle.LiveData
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.base.fastLazy
-import com.adealink.frame.mvvm.livedata.OnceMutableLiveData
-import com.adealink.frame.mvvm.viewmodel.BaseViewModel
-import com.adealink.frame.network.data.NetworkResultNullError
-import com.adealink.weparty.App
-import com.adealink.weparty.cocosgame.data.GameDashboardReq
-import com.adealink.weparty.cocosgame.data.GameDashboardRes
-import com.adealink.weparty.cocosgame.datasource.remote.CommonGameHttpService
-import kotlinx.coroutines.launch
-
-class CocosGameUserLeagueViewModel : BaseViewModel() {
-
-    private val commonGameHttpService by fastLazy {
-        App.instance.networkService.getHttpService(CommonGameHttpService::class.java)
-    }
-
-    fun getGameDashBoard(type: Int): LiveData<Rlt<GameDashboardRes>> {
-        val liveData = OnceMutableLiveData<Rlt<GameDashboardRes>>()
-        viewModelScope.launch {
-            when (val result = commonGameHttpService.getRankBoard(GameDashboardReq(type))) {
-                is Rlt.Success -> {
-                    val res = result.data.data
-                    if (res == null) {
-                        liveData.send(Rlt.Failed(NetworkResultNullError()))
-                    } else {
-                        liveData.send(Rlt.Success(res))
-                    }
-                }
-
-                is Rlt.Failed -> {
-                    liveData.send(Rlt.Failed(result.error))
-                }
-            }
-        }
-        return liveData
-    }
-
-}

+ 0 - 80
app/src/main/java/com/adealink/weparty/cocosgame/viewmodel/IBaseCocosWebGameViewModel.kt

@@ -1,80 +0,0 @@
-package com.adealink.weparty.cocosgame.viewmodel
-
-import android.view.View
-import androidx.lifecycle.LiveData
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.mvvm.livedata.ExtLiveData
-import com.adealink.weparty.cocosgame.data.CocosViewData
-import com.adealink.weparty.cocosgame.data.DialogData
-import com.adealink.weparty.cocosgame.data.GameRecoverFailData
-import com.adealink.weparty.cocosgame.data.GameRewardData
-import com.adealink.weparty.cocosgame.data.GameStartNotify
-import com.adealink.weparty.cocosgame.data.GameToNativeOpData
-import com.adealink.weparty.cocosgame.data.InitGameData
-import com.adealink.weparty.cocosgame.data.NodeViewType
-import com.adealink.weparty.cocosgame.data.PlayerStatus
-import com.adealink.weparty.cocosgame.web.CocosGameWebView
-import com.adealink.weparty.module.gamehub.ludo.data.LudoGameType
-
-/**
- * Cocos游戏基础业务上层基础ViewModel
- *
- * @param GameType 游戏类型, 由上层游戏自行定义, 参见 [LudoGameType]
- * @param GameMode 游戏模式, 由上层游戏自行定义, 参见 [LudoGameMode]
- * @param MagicMode 游戏魔法模式, 由上层游戏自行定义, 参见 [LudoMagicMode]
- * @param PlayerCount 玩家数量, 由上层游戏自行定义, 参见 [LudoPlayerCount]
- */
-interface IBaseCocosWebGameViewModel<GameType, GameMode, MagicMode, PlayerCount>: ICocosGameViewModel {
-
-    /*
-     * 游戏信息
-     */
-    val gameModelLD: ExtLiveData<GameMode>
-    val gameTypeLD: ExtLiveData<GameType>
-    val magicModeLD: ExtLiveData<MagicMode>
-    val playerCountLD: ExtLiveData<PlayerCount>
-
-    /*
-     * 游戏回调
-     */
-    val onGameInitLD: ExtLiveData<Unit>
-    val gameToNativeOpLD: ExtLiveData<GameToNativeOpData>
-    val gameStartNotifyLD: ExtLiveData<GameStartNotify?>
-    val showDialogLD: ExtLiveData<DialogData>
-    val dismissDialogLD: ExtLiveData<Long>
-    val emotionBtnNodeViewLD: ExtLiveData<CocosViewData>
-    val messageBtnNodeViewLD: ExtLiveData<CocosViewData>
-    val rankBtnNodeViewLD: ExtLiveData<CocosViewData>
-    val settingBtnNodeViewLD: ExtLiveData<CocosViewData>
-    val bottomBtnsAreaNodeViewLD: ExtLiveData<CocosViewData>
-    val topBarAreaNodeViewLD: ExtLiveData<CocosViewData>
-    val bottomBarAreaNodeViewLD: ExtLiveData<CocosViewData>
-    val emotionBtnNodeVisibleLD: ExtLiveData<Boolean>
-    val messageBtnNodeVisibleLD: ExtLiveData<Boolean>
-
-    val gameType: GameType
-    val gameMode: GameMode
-    val magicMode: MagicMode
-    val gamePlayerCount: PlayerCount
-
-    val betsCoins: List<Int>
-    val betsCoinsCount: Int
-
-    val rankRewards: List<GameRewardData>
-    val rankRewardsLD: ExtLiveData<List<GameRewardData>>
-
-    val gameRecoverFailLD: ExtLiveData<GameRecoverFailData>
-
-    fun initGame(gameContainer: CocosGameWebView, boardView: View, data: InitGameData)
-    fun getPlayerAvatarView(playerId: Long): LiveData<Rlt<CocosViewData>>
-    fun getNodeView(type: NodeViewType): LiveData<Rlt<CocosViewData>>
-    fun getPlayerGameStatus(uid: Long): LiveData<PlayerStatus>
-
-    fun setGameType(type: GameType)
-    fun setGameMode(mode: GameMode)
-    fun setMagicMode(mode: MagicMode)
-    fun setPlayerCount(count: PlayerCount)
-    fun setGameModeBetsCoinsCount(gameMode: GameMode, betCoins: Int)
-    fun getGameTitle(gameType: Int, gameMode: Int? = null, magicMode: Int? = null): String
-
-}

+ 0 - 47
app/src/main/java/com/adealink/weparty/cocosgame/viewmodel/ICocosGameViewModel.kt

@@ -1,47 +0,0 @@
-package com.adealink.weparty.cocosgame.viewmodel
-
-import androidx.lifecycle.LiveData
-import com.adealink.frame.base.Rlt
-import com.adealink.weparty.cocosgame.data.BaseOpData
-import com.adealink.weparty.cocosgame.data.GamePlayerInfo
-import com.adealink.weparty.cocosgame.data.NativeToGameOp
-import com.adealink.weparty.cocosgame.data.StartGameData
-
-/**
- * Cocos游戏基础业务上层基础ViewModel
- */
-interface ICocosGameViewModel  {
-
-    /**
-     * 进入游戏
-     */
-    fun enterGame(data: StartGameData)
-
-    /**
-     * 操作游戏
-     */
-    fun opGame(op: NativeToGameOp, data: BaseOpData)
-
-    /**
-     * 退出游戏
-     */
-    fun exitGame(): LiveData<Rlt<Any>>
-
-    /**
-     * 重置游戏
-     */
-    fun resetGame()
-
-    /**
-     * 销毁游戏
-     */
-    fun destroyGame()
-
-    /**
-     * 玩家信息
-     */
-    fun getPlayerInfo(uid: Long): GamePlayerInfo?
-
-    fun getBetCoins(): LiveData<Rlt<Any>>
-
-}

+ 0 - 161
app/src/main/java/com/adealink/weparty/cocosgame/web/CocosGameWebView.kt

@@ -1,161 +0,0 @@
-package com.adealink.weparty.cocosgame.web
-
-import android.annotation.SuppressLint
-import android.content.Context
-import android.os.Build
-import android.util.AttributeSet
-import android.view.ViewGroup
-import android.webkit.WebSettings
-import android.webkit.WebView
-import com.adealink.frame.base.AppBase
-import com.adealink.frame.base.fastLazy
-import com.adealink.frame.log.Log
-import com.adealink.weparty.App
-import com.adealink.weparty.webview.CommonWebChromeClient
-import com.adealink.weparty.webview.CommonWebViewClient
-import com.adealink.weparty.webview.IWebView
-import com.adealink.weparty.webview.callback.IWebViewCallback
-import com.adealink.weparty.webview.constant.COCOS_GAME_JS_BRIDGE
-import com.adealink.weparty.webview.constant.TAG_WEB_VIEW
-import com.adealink.weparty.webview.jsbridge.JSBridge
-import com.adealink.weparty.webview.jsbridge.data.NativeMessage
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-import com.ushareit.easysdk.web.view.SPWebView
-
-class CocosGameWebView : SPWebView, IWebView {
-    constructor(context: Context) : super(context) {
-        init()
-    }
-
-    constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
-        init()
-    }
-
-    constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) :
-            super(context, attrs, defStyleAttr) {
-        init()
-    }
-
-    private lateinit var jsBridge: CocosJSBridgeImpl
-    override var webViewCallback: IWebViewCallback? = null
-    private var commonWebViewClient: CommonWebViewClient? = null
-    private var commonWebChromeClient: CommonWebChromeClient? = null
-
-    private var lUrl: String? = null
-
-    private fun init() {
-        initWebViewSetting()
-        initJSBridge()
-        initWebViewClient()
-        initWebChromeClient()
-    }
-
-    @SuppressLint("SetJavaScriptEnabled")
-    private fun initWebViewSetting() {
-        settings.domStorageEnabled = true
-        settings.javaScriptEnabled = true
-        settings.useWideViewPort = true
-        settings.defaultTextEncodingName = "utf-8"
-        settings.cacheMode = WebSettings.LOAD_DEFAULT
-        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
-            //5.0以上开启混合模式加载
-            settings.mixedContentMode = WebSettings.MIXED_CONTENT_ALWAYS_ALLOW
-        }
-        if (!AppBase.isRelease && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-            setWebContentsDebuggingEnabled(true)
-        }
-        settings.builtInZoomControls = false
-        settings.setSupportZoom(false)
-        settings.saveFormData = false
-        settings.savePassword = false
-        settings.allowFileAccess = true
-        settings.useWideViewPort = true
-        settings.loadWithOverviewMode = true
-        settings.javaScriptCanOpenWindowsAutomatically = true
-    }
-
-    @SuppressLint("JavascriptInterface")
-    private fun initJSBridge() {
-        val jsBridge = CocosJSBridgeImpl(this, COCOS_GAME_JS_BRIDGE)
-            .apply { jsBridge = this }
-        Log.i(
-            TAG_WEB_VIEW,
-            "initJSBridge, jsBridge:$jsBridge, interfaceName:${jsBridge.interfaceName()}"
-        )
-        addJavascriptInterface(jsBridge as Any, jsBridge.interfaceName())
-        addJSNativeMethods(jsBridge)
-    }
-
-    private fun addJSNativeMethods(jsBridge: JSBridge) {}
-
-    fun addJSNativeMethod(method: JSNativeMethod<*, *>) {
-        jsBridge.addNativeMethod(method)
-    }
-
-    private fun <T> notifyNativeMessage(message: NativeMessage<T>) {
-        jsBridge.notifyNativeMessage(message)
-    }
-
-    override fun shouldReloadUrl(url: String): Boolean {
-        return false
-    }
-
-    private fun initWebChromeClient() {
-        commonWebChromeClient = CommonWebChromeClient(this)
-        webChromeClient = commonWebChromeClient
-    }
-
-    private fun initWebViewClient() {
-        commonWebViewClient = CommonWebViewClient(this)
-        val constWebViewClient = commonWebViewClient ?: return
-        webViewClient = constWebViewClient
-    }
-
-    fun getJsBridge(): CocosJSBridgeImpl {
-        return jsBridge
-    }
-
-    override fun getLoadUrl(): String? {
-        return lUrl
-    }
-
-    override fun getCommonWebChromeClient(): CommonWebChromeClient? {
-        return commonWebChromeClient
-    }
-
-    override fun getCommonWebViewClient(): CommonWebViewClient? {
-        return commonWebViewClient
-    }
-
-    override fun getWebView(): WebView {
-        return this
-    }
-
-    private val soundNameSet by fastLazy {
-        mutableSetOf<String>()
-    }
-
-    override fun onSoundPlayed(soundName: String) {
-        soundNameSet.add(soundName)
-    }
-
-    override fun onDetachedFromWindow() {
-        super.onDetachedFromWindow()
-        soundNameSet.forEach {
-            App.instance.soundPlayer.stop(it)
-        }
-    }
-
-    fun onDestroy() {
-        try {
-            loadDataWithBaseURL(null, "", "text/html", "utf-8", null)
-            (parent as? ViewGroup)?.removeView(this@CocosGameWebView)
-            removeAllViewsInLayout()
-            removeAllViews()
-            webChromeClient = null
-            destroy()
-        } catch (e: Exception) {
-            Log.e(TAG_WEB_VIEW, "release webview fail, for ${e.message}")
-        }
-    }
-}

+ 0 - 309
app/src/main/java/com/adealink/weparty/cocosgame/web/CocosJSBridgeImpl.kt

@@ -1,309 +0,0 @@
-package com.adealink.weparty.cocosgame.web
-
-import android.os.Build
-import android.webkit.JavascriptInterface
-import androidx.annotation.UiThread
-import com.adealink.frame.data.json.froJsonErrorNull
-import com.adealink.frame.data.json.toJsonErrorNull
-import com.adealink.frame.frame.BaseFrame
-import com.adealink.frame.frame.IListener
-import com.adealink.frame.game.CallbackInfo
-import com.adealink.frame.game.GameErrorCode
-import com.adealink.frame.game.ICallback
-import com.adealink.frame.game.SendToGameData
-import com.adealink.frame.game.TAG_GAME_CALL_GAME
-import com.adealink.frame.log.Log
-import com.adealink.frame.util.getJSONObject
-import com.adealink.frame.util.runOnUiThread
-import com.adealink.weparty.cocosgame.data.TAG_COCOS_GAME_WEB_CALL
-import com.adealink.weparty.cocosgame.web.data.CocosJSRequest
-import com.adealink.weparty.webview.IWebView
-import com.adealink.weparty.webview.constant.TAG_WEB_VIEW_JS_BRIDGE
-import com.adealink.weparty.webview.jsbridge.JSBridge
-import com.adealink.weparty.webview.jsbridge.callback.JSBridgeCallback
-import com.adealink.weparty.webview.jsbridge.data.JSResponse
-import com.adealink.weparty.webview.jsbridge.data.NativeMessage
-import com.adealink.weparty.webview.jsbridge.method.JSNativeMethod
-import com.google.gson.annotations.SerializedName
-import java.util.concurrent.ConcurrentHashMap
-import java.util.concurrent.atomic.AtomicLong
-
-
-/**
- * Cocos游戏Web桥接
- */
-class CocosJSBridgeImpl(val webView: IWebView, private val interfaceName: String) :
-    BaseFrame<IListener>(), JSBridge {
-
-    companion object {
-        private const val CALLBACK_TIMEOUT = 10_000L //10s
-    }
-
-    private val callbackId = AtomicLong(System.currentTimeMillis())
-    private val methodMap = hashMapOf<String, JSNativeMethod<Any, Any>>() //key: method name
-    private val callbackMap = ConcurrentHashMap<String, CallbackInfo>()
-
-    override fun interfaceName(): String {
-        return interfaceName
-    }
-
-    @Suppress("UNCHECKED_CAST")
-    @UiThread
-    override fun <T, R> addNativeMethod(method: JSNativeMethod<T, R>) {
-        methodMap[method.methodName] = method as JSNativeMethod<Any, Any>
-    }
-
-    @UiThread
-    override fun removeNativeMethod(methodName: String) {
-        methodMap.remove(methodName)
-    }
-
-    override fun <T> notifyNativeMessage(message: NativeMessage<T>) {
-        val messageStr = toJsonErrorNull(message)
-        if (messageStr.isNullOrEmpty()) {
-            Log.e(
-                TAG_WEB_VIEW_JS_BRIDGE,
-                "notifyNativeMessage, message is empty"
-            )
-            return
-        }
-        val script = "javascript:window.notifyMessage('$messageStr')"
-        runOnUiThread {
-            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-                webView.evaluateJavascript(script, null)
-            } else {
-                webView.loadUrl(script)
-            }
-        }
-    }
-
-    override fun onWebBroadcast(data: String) {
-        val methodReq = CocosGameMethod("onWebBroadcast", data)
-        val methodReqJson = toJsonErrorNull(methodReq)
-        callJavascript("javascript:callGameMethod($methodReqJson)")
-    }
-
-    /**
-     * 这里的处理方式要参考 GameAppImpl.onScript
-     */
-    @JavascriptInterface
-    fun callNativeMethod(json: String?) {
-        runOnUiThread { handleJSMessage(json) }
-    }
-
-    @UiThread
-    private fun handleJSMessage(json: String?) {
-        Log.d(TAG_WEB_VIEW_JS_BRIDGE, "handleJSMessage, json:${json}")
-        val jsRequest = CocosJSRequest.parseJson(json)
-
-        val callbackInfo = callbackMap.remove(jsRequest.methodName)
-        if (callbackInfo != null) {
-            doInvokeCallback(jsRequest, callbackInfo)
-            return
-        }
-
-        val callbackBridge = CallbackBridge(jsRequest.callbackMethod ?: "", jsRequest.methodName)
-        doInvokeMethod(jsRequest, callbackBridge)
-    }
-
-    private fun doInvokeCallback(jsRequest: CocosJSRequest, callbackInfo: CallbackInfo) {
-        removeFromSerialHandler(callbackInfo.runnable)
-        val nativeCallback = callbackInfo.callback
-        val dataJSONObject = jsRequest.data?.getJSONObject()
-        if (dataJSONObject == null) {
-            nativeCallback.onFailed(GameErrorCode.CALLBACK_DATA_NULL.code)
-            return
-        }
-
-        val code = dataJSONObject.optInt("code")
-        if (code != GameErrorCode.SUCCESS.code) {
-            nativeCallback.onFailed(code)
-            return
-        }
-
-        val clazz = ICallback.classOfT(nativeCallback)
-        if (clazz == null) {
-            nativeCallback.onFailed(GameErrorCode.DATA_TYPE_ERROR.code)
-            return
-        }
-
-        if (clazz == Any::class.java) {
-            nativeCallback.onSuccess(Any())
-            return
-        }
-
-        val dataJson = dataJSONObject.optJSONObject("data")?.toString()
-        val result =
-            if (clazz == Nothing::class.java || clazz == Void::class.java || dataJson.isNullOrEmpty()) {
-                null
-            } else if (clazz == String::class.java) {
-                dataJson
-            } else {
-                froJsonErrorNull(dataJson, clazz)
-            }
-        if (result == null) {
-            nativeCallback.onFailed(GameErrorCode.DATA_PARSE_ERROR.code)
-            return
-        }
-
-        nativeCallback.onSuccess(result)
-    }
-
-    private fun doInvokeMethod(jsRequest: CocosJSRequest, callbackBridge: CallbackBridge) {
-        val methodName = jsRequest.methodName
-        if (methodName.isEmpty()) {
-            callbackBridge.reject(JSResponse.JSError.REQUEST_METHOD_NAME_NULL)
-            return
-        }
-
-        val nativeMethod = methodMap[methodName]
-        if (nativeMethod == null) {
-            callbackBridge.reject(JSResponse.JSError.CLIENT_NO_REGISTER_HANDLE_METHOD)
-            return
-        }
-
-        val clazz = JSNativeMethod.classOfT(nativeMethod)
-        if (clazz == null) {
-            callbackBridge.reject(JSResponse.JSError.CLIENT_HANDLE_REQUEST_DATA_TYPE_ERROR)
-            return
-        }
-
-        val dataStr = jsRequest.data
-        if (clazz == Any::class.java) {
-            nativeMethod.handleMethodCall(Any(), callbackBridge)
-            return
-        }
-
-        val data =
-            if (clazz == Nothing::class.java || clazz == Void::class.java || dataStr.isNullOrEmpty()) {
-                null
-            } else if (clazz == String::class.java) {
-                dataStr
-            } else {
-                froJsonErrorNull(dataStr, clazz)
-            }
-
-        if (data == null) {
-            callbackBridge.reject(JSResponse.JSError.CLIENT_HANDLE_REQUEST_DATA_PARSE_ERROR)
-            return
-        }
-
-        nativeMethod.handleMethodCall(data, callbackBridge)
-    }
-
-    private fun newCallbackId(): String {
-        return callbackId.incrementAndGet().toString()
-    }
-
-    fun callGame(
-        methodName: String,
-        data: Any,
-        callback: ICallback<Any>? = null
-    ) {
-        Log.i(
-            TAG_COCOS_GAME_WEB_CALL,
-            "callGame start, methodName:${methodName} data:${data}"
-        )
-        var callbackId: String? = null
-        if (callback != null) {
-            callbackId = newCallbackId()
-        }
-        val sendToGameData = SendToGameData(callbackId, data)
-        val dataJson = toJsonErrorNull(sendToGameData)
-        if (dataJson.isNullOrEmpty()) {
-            Log.e(TAG_COCOS_GAME_WEB_CALL, "callGame, data:${data} to json is null")
-            callback?.onFailed(GameErrorCode.DATA_TO_JSON_ERROR.code)
-            return
-        }
-
-        if (callback != null) {
-            val timeoutRunnable = Runnable {
-                Log.e(TAG_GAME_CALL_GAME, "callGame, data:${data} callback timeout")
-                callbackMap.remove(callbackId)
-                callback.onFailed(GameErrorCode.CALLBACK_TIMEOUT.code)
-            }
-            val callbackInfo = CallbackInfo(callback, timeoutRunnable)
-            callbackMap[callbackId!!] = callbackInfo
-            runOnSerialHandler(timeoutRunnable, CALLBACK_TIMEOUT)
-        }
-
-        val methodReq = CocosGameMethod(methodName, dataJson)
-        val methodReqJson = toJsonErrorNull(methodReq)
-        callJavascript("javascript:callGameMethod($methodReqJson)")
-    }
-
-    inner class CocosGameMethod(
-        @SerializedName("method")
-        val method: String,
-        @SerializedName("data")
-        val data: String? = null //CocosGameMethodData
-    )
-
-    private fun callJavascript(script: String) {
-        val webView = webView.getWebView()
-        if (!webView.isAttachedToWindow) {
-            Log.e(
-                TAG_COCOS_GAME_WEB_CALL,
-                "callJavascript, webview is null or invalid"
-            )
-            return
-        }
-        Log.d(
-            TAG_COCOS_GAME_WEB_CALL,
-            "callJavascript, script:$script"
-        )
-        webView.post {
-            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
-                webView.evaluateJavascript(script, null)
-            } else {
-                webView.loadUrl(script)
-            }
-        }
-    }
-
-    inner class CallbackBridge(override val callbackId: String, val methodName: String?) :
-        JSBridgeCallback<Any> {
-
-        private fun sendResponseToJS(response: JSResponse<Any>) {
-            if (callbackId.isEmpty()) {
-                Log.w(
-                    TAG_WEB_VIEW_JS_BRIDGE,
-                    "sendResponseToJS, methodName:${methodName}, response:${response}, callbackId is empty"
-                )
-                return
-            }
-
-            runOnUiThread {
-                callGame(
-                    callbackId, response
-                )
-            }
-        }
-
-        override fun resolve(data: Any) {
-            Log.d(
-                TAG_WEB_VIEW_JS_BRIDGE,
-                "resolve, methodName:${methodName}, callbackId:${callbackId}, data:${data}"
-            )
-            sendResponseToJS(JSResponse(callbackId = this@CallbackBridge.callbackId, data = data))
-        }
-
-        override fun reject(error: JSResponse.JSError) {
-            Log.e(
-                TAG_WEB_VIEW_JS_BRIDGE,
-                "reject, methodName:${methodName}, callbackId:${callbackId}, error:${error.message}"
-            )
-            sendResponseToJS(JSResponse(error.code, error.message, this@CallbackBridge.callbackId))
-        }
-
-        override fun reject(errorCode: Int, message: String?) {
-            Log.e(
-                TAG_WEB_VIEW_JS_BRIDGE,
-                "reject, methodName:${methodName}, callbackId:${callbackId}, error:${message ?: ""}"
-            )
-            sendResponseToJS(JSResponse(errorCode, message ?: "", this@CallbackBridge.callbackId))
-        }
-
-    }
-
-}

+ 0 - 37
app/src/main/java/com/adealink/weparty/cocosgame/web/data/CocosJSRequest.kt

@@ -1,37 +0,0 @@
-package com.adealink.weparty.cocosgame.web.data
-
-import org.json.JSONObject
-
-data class CocosJSRequest(
-    val methodName: String = "",
-    var data: String? = null,
-
-    val callbackMethod: String? = null,
-) {
-
-    companion object {
-
-        private const val KET_METHOD = "method"
-        private const val KET_DATA = "data"
-
-        private const val KET_CALLBACK_METHOD = "callback_method"
-
-        fun parseJson(json: String?): CocosJSRequest {
-            if (json.isNullOrEmpty()) {
-                return CocosJSRequest("", "", null)
-            }
-
-            return try {
-                val jsonObject = JSONObject(json)
-                val methodName = jsonObject.optString(KET_METHOD, "")
-                val dataJSONObject = jsonObject.optJSONObject(KET_DATA)
-                val callbackMethod = jsonObject.optString(KET_CALLBACK_METHOD, "")
-                CocosJSRequest(methodName, dataJSONObject?.toString(), callbackMethod)
-            } catch (e: Exception) {
-                CocosJSRequest("", null, null)
-            }
-        }
-    }
-
-
-}

+ 0 - 590
app/src/main/java/com/adealink/weparty/commonui/datepicker/CustomDatePicker.kt

@@ -1,590 +0,0 @@
-package com.adealink.weparty.commonui.datepicker
-
-import android.annotation.SuppressLint
-import android.graphics.Color
-import android.graphics.drawable.ColorDrawable
-import android.os.Bundle
-import android.text.TextUtils
-import android.view.Gravity
-import android.view.View
-import android.view.Window
-import android.view.WindowManager
-import com.adealink.frame.ext.isViewBindingValid
-import com.adealink.frame.mvvm.view.viewBinding
-import com.adealink.weparty.commonui.datepicker.DateFormatUtils.str2Long
-import com.adealink.weparty.R
-import com.adealink.weparty.commonui.ext.gone
-import com.adealink.weparty.commonui.ext.show
-import com.adealink.weparty.commonui.widget.BottomDialogFragment
-import java.text.DecimalFormat
-import java.util.Calendar
-import com.adealink.weparty.databinding.DialogDatePickerBinding
-import com.adealink.weparty.ui.listener.setOnGameClick
-
-class CustomDatePicker :
-    BottomDialogFragment(R.layout.dialog_date_picker), PickerView.OnSelectListener {
-    companion object {
-        val SIMPLE_NAME: String = CustomDatePicker::class.java.simpleName
-        /**
-         * 时间单位:时、分
-         */
-        private const val SCROLL_UNIT_HOUR = 1
-        private const val SCROLL_UNIT_MINUTE = 2
-
-        /**
-         * 时间单位的最大显示值
-         */
-        private const val MAX_MINUTE_UNIT = 59
-        private const val MAX_HOUR_UNIT = 23
-        private const val MAX_MONTH_UNIT = 12
-
-        /**
-         * 级联滚动延迟时间
-         */
-        private const val LINKAGE_DELAY_DEFAULT = 100L
-
-        private const val EXTRA_BEGIN_TIME_STAMP = "extra_begin_time_stamp"
-        private const val EXTRA_END_TIME_STAMP = "extra_end_time_stamp"
-        private const val EXTRA_SELECTED_TIME_STAMP = "extra_selected_time_stamp"
-        private const val EXTRA_CAN_SHOW_PRECISE_TIME = "extra_canShow_precise_time"
-        private const val EXTRA_CAN_SHOW_DAY = "extra_canShow_day"
-        fun newInstance(beginTimestamp :Long,endTimestamp:Long, selectedTimestamp: Long, canShowPreciseTime:Boolean, canShowDay:Boolean): CustomDatePicker {
-            val bundle = Bundle()
-            bundle.putLong(EXTRA_BEGIN_TIME_STAMP, beginTimestamp)
-            bundle.putLong(EXTRA_END_TIME_STAMP, endTimestamp)
-            bundle.putLong(EXTRA_SELECTED_TIME_STAMP, selectedTimestamp)
-            bundle.putBoolean(EXTRA_CAN_SHOW_PRECISE_TIME, canShowPreciseTime)
-            bundle.putBoolean(EXTRA_CAN_SHOW_DAY, canShowDay)
-            val fragment = CustomDatePicker()
-            fragment.arguments = bundle
-            return fragment
-        }
-    }
-
-    private val binding by viewBinding(DialogDatePickerBinding::bind)
-    var mCallback: Callback? = null
-
-    private var mBeginTime: Calendar = Calendar.getInstance()
-    private var mEndTime: Calendar = Calendar.getInstance()
-    private var mSelectedTime: Calendar = Calendar.getInstance()
-
-    private var mBeginYear = 0
-    private var mBeginMonth = 0
-    private var mBeginDay = 0
-    private var mBeginHour = 0
-    private var mBeginMinute = 0
-    private var mEndYear = 0
-    private var mEndMonth = 0
-    private var mEndDay = 0
-    private var mEndHour = 0
-    private var mEndMinute = 0
-    private val mYearUnits: MutableList<String> = ArrayList()
-    private val mMonthUnits: MutableList<String> = ArrayList()
-    private val mDayUnits: MutableList<String> = ArrayList()
-    private val mHourUnits: MutableList<String> = ArrayList()
-    private val mMinuteUnits: MutableList<String> = ArrayList()
-    private val mDecimalFormat = DecimalFormat("00")
-
-    private var mCanShowPreciseTime = false
-    private var mScrollUnits = SCROLL_UNIT_HOUR + SCROLL_UNIT_MINUTE
-
-    /**
-     * 时间选择结果回调接口
-     */
-    interface Callback {
-        fun onTimeSelected(timestamp: Long)
-    }
-
-    override fun initViews() {
-        super.initViews()
-        parseIntent()
-        initView()
-        initData()
-        setSelectedTime(mSelectedTime.timeInMillis, false)
-    }
-
-    private fun parseIntent() {
-        arguments?.getLong(EXTRA_BEGIN_TIME_STAMP)?.let {
-            mBeginTime.timeInMillis = it
-        }
-        arguments?.getLong(EXTRA_END_TIME_STAMP)?.let {
-            mEndTime.timeInMillis = it
-        }
-        arguments?.getLong(EXTRA_SELECTED_TIME_STAMP)?.let {
-            if(it != 0L && it >= mBeginTime.timeInMillis && it <= mEndTime.timeInMillis) {
-                mSelectedTime.timeInMillis = it
-            } else {
-                mSelectedTime.timeInMillis = mBeginTime.timeInMillis
-            }
-        }
-        val showPreciseTime = arguments?.getBoolean(EXTRA_CAN_SHOW_PRECISE_TIME) ?: true
-        val showDay = arguments?.getBoolean(EXTRA_CAN_SHOW_DAY) ?: true
-        setCanShowPreciseTime(showPreciseTime, showDay)
-    }
-
-    private fun initView() {
-        binding.tvCancel.setOnGameClick {
-            dismiss()
-        }
-        binding.tvConfirm.setOnGameClick {
-            mCallback?.onTimeSelected(mSelectedTime.timeInMillis)
-            dismiss()
-        }
-
-        binding.dpvYear.setOnSelectListener(this)
-        binding.dpvMonth.setOnSelectListener(this)
-        binding.dpvDay.setOnSelectListener(this)
-        binding.dpvHour.setOnSelectListener(this)
-        binding.dpvMinute.setOnSelectListener(this)
-    }
-
-
-    override fun onSelect(view: View?, selected: String?) {
-        if (view == null || TextUtils.isEmpty(selected)) return
-
-        val timeUnit: Int
-        try {
-            timeUnit = selected?.toInt() ?: 0
-        } catch (ignored: Throwable) {
-            return
-        }
-
-        when (view) {
-            binding.dpvYear -> {
-                mSelectedTime[Calendar.YEAR] = timeUnit
-                linkageMonthUnit(true, LINKAGE_DELAY_DEFAULT)
-            }
-
-            binding.dpvMonth -> {
-                // 防止类似 2018/12/31 滚动到11月时因溢出变成 2018/12/01
-                val lastSelectedMonth = mSelectedTime[Calendar.MONTH] + 1
-                mSelectedTime.add(Calendar.MONTH, timeUnit - lastSelectedMonth)
-                linkageDayUnit(true, LINKAGE_DELAY_DEFAULT)
-            }
-
-            binding.dpvDay -> {
-                mSelectedTime[Calendar.DAY_OF_MONTH] = timeUnit
-                linkageHourUnit(true, LINKAGE_DELAY_DEFAULT)
-            }
-
-            binding.dpvHour -> {
-                mSelectedTime[Calendar.HOUR_OF_DAY] = timeUnit
-                linkageMinuteUnit(true)
-            }
-            binding.dpvMinute -> mSelectedTime[Calendar.MINUTE] = timeUnit
-        }
-    }
-
-    private fun initData() {
-        mBeginYear = mBeginTime[Calendar.YEAR]
-        // Calendar.MONTH 值为 0-11
-        mBeginMonth = mBeginTime[Calendar.MONTH] + 1
-        mBeginDay = mBeginTime[Calendar.DAY_OF_MONTH]
-        mBeginHour = mBeginTime[Calendar.HOUR_OF_DAY]
-        mBeginMinute = mBeginTime[Calendar.MINUTE]
-
-        mEndYear = mEndTime[Calendar.YEAR]
-        mEndMonth = mEndTime[Calendar.MONTH] + 1
-        mEndDay = mEndTime[Calendar.DAY_OF_MONTH]
-        mEndHour = mEndTime[Calendar.HOUR_OF_DAY]
-        mEndMinute = mEndTime[Calendar.MINUTE]
-
-        val canSpanYear = mBeginYear != mEndYear
-        val canSpanMon = !canSpanYear && mBeginMonth != mEndMonth
-        val canSpanDay = !canSpanMon && mBeginDay != mEndDay
-        val canSpanHour = !canSpanDay && mBeginHour != mEndHour
-        val canSpanMinute = !canSpanHour && mBeginMinute != mEndMinute
-        if (canSpanYear) {
-            initDateUnits(
-                MAX_MONTH_UNIT,
-                mBeginTime.getActualMaximum(Calendar.DAY_OF_MONTH),
-                MAX_HOUR_UNIT,
-                MAX_MINUTE_UNIT
-            )
-        } else if (canSpanMon) {
-            initDateUnits(
-                mEndMonth,
-                mBeginTime.getActualMaximum(Calendar.DAY_OF_MONTH),
-                MAX_HOUR_UNIT,
-                MAX_MINUTE_UNIT
-            )
-        } else if (canSpanDay) {
-            initDateUnits(mEndMonth, mEndDay, MAX_HOUR_UNIT, MAX_MINUTE_UNIT)
-        } else if (canSpanHour) {
-            initDateUnits(mEndMonth, mEndDay, mEndHour, MAX_MINUTE_UNIT)
-        } else if (canSpanMinute) {
-            initDateUnits(mEndMonth, mEndDay, mEndHour, mEndMinute)
-        }
-    }
-
-    @SuppressLint("DefaultLocale")
-    private fun initDateUnits(endMonth: Int, endDay: Int, endHour: Int, endMinute: Int) {
-        for (i in mBeginYear..mEndYear) {
-            mYearUnits.add(i.toString())
-        }
-
-        for (i in mBeginMonth..endMonth) {
-            mMonthUnits.add(i.toString())
-
-        }
-
-        for (i in mBeginDay..endDay) {
-            mDayUnits.add(i.toString())
-        }
-
-        if ((mScrollUnits and SCROLL_UNIT_HOUR) != SCROLL_UNIT_HOUR) {
-            mHourUnits.add(mBeginHour.toString())
-        } else {
-            for (i in mBeginHour..endHour) {
-                mHourUnits.add(i.toString())
-            }
-        }
-
-        if ((mScrollUnits and SCROLL_UNIT_MINUTE) != SCROLL_UNIT_MINUTE) {
-            mMinuteUnits.add(mBeginMinute.toString())
-        } else {
-            for (i in mBeginMinute..endMinute) {
-                mMinuteUnits.add(i.toString())
-            }
-        }
-        binding.dpvYear.setDataList(mYearUnits)
-        binding.dpvYear.setSelected(0)
-        binding.dpvMonth.setDataList(mMonthUnits)
-        binding.dpvMonth.setSelected(0)
-        binding.dpvDay.setDataList(mDayUnits)
-        binding.dpvDay.setSelected(0)
-        binding.dpvHour.setDataList(mHourUnits)
-        binding.dpvHour.setSelected(0)
-        binding.dpvMinute.setDataList(mMinuteUnits)
-        binding.dpvMinute.setSelected(0)
-        setCanScroll()
-    }
-
-    private fun setCanScroll() {
-        binding.dpvYear.setCanScroll(mYearUnits.size > 1)
-        binding.dpvMonth.setCanScroll(mMonthUnits.size > 1)
-        binding.dpvDay.setCanScroll(mDayUnits.size > 1)
-        binding.dpvHour.setCanScroll(mHourUnits.size > 1 && (mScrollUnits and SCROLL_UNIT_HOUR) == SCROLL_UNIT_HOUR)
-        binding.dpvMinute.setCanScroll(mMinuteUnits.size > 1 && (mScrollUnits and SCROLL_UNIT_MINUTE) == SCROLL_UNIT_MINUTE)
-    }
-
-    /**
-     * 联动“月”变化
-     *
-     * @param showAnim 是否展示滚动动画
-     * @param delay    联动下一级延迟时间
-     */
-    @SuppressLint("DefaultLocale")
-    private fun linkageMonthUnit(showAnim: Boolean, delay: Long) {
-        val minMonth: Int
-        val maxMonth: Int
-        val selectedYear = mSelectedTime[Calendar.YEAR]
-        if (mBeginYear == mEndYear) {
-            minMonth = mBeginMonth
-            maxMonth = mEndMonth
-        } else if (selectedYear == mBeginYear) {
-            minMonth = mBeginMonth
-            maxMonth = MAX_MONTH_UNIT
-        } else if (selectedYear == mEndYear) {
-            minMonth = 1
-            maxMonth = mEndMonth
-        } else {
-            minMonth = 1
-            maxMonth = MAX_MONTH_UNIT
-        }
-
-        // 重新初始化时间单元容器
-        mMonthUnits.clear()
-        for (i in minMonth..maxMonth) {
-            mMonthUnits.add(i.toString())
-        }
-        binding.dpvMonth.setDataList(mMonthUnits)
-
-        // 确保联动时不会溢出或改变关联选中值
-        val selectedMonth = getValueInRange(mSelectedTime[Calendar.MONTH] + 1, minMonth, maxMonth)
-        mSelectedTime[Calendar.MONTH] = selectedMonth - 1
-        binding.dpvMonth.setSelected(selectedMonth - minMonth)
-        if (showAnim) {
-            binding.dpvMonth.startAnim()
-        }
-
-        // 联动“日”变化
-        binding.dpvMonth.postDelayed({ linkageDayUnit(showAnim, delay) }, delay)
-    }
-
-    /**
-     * 联动“日”变化
-     *
-     * @param showAnim 是否展示滚动动画
-     * @param delay    联动下一级延迟时间
-     */
-    private fun linkageDayUnit(showAnim: Boolean, delay: Long) {
-        if (!isViewBindingValid()) {
-            return
-        }
-        val minDay: Int
-        val maxDay: Int
-        val selectedYear = mSelectedTime[Calendar.YEAR]
-        val selectedMonth = mSelectedTime[Calendar.MONTH] + 1
-        if (mBeginYear == mEndYear && mBeginMonth == mEndMonth) {
-            minDay = mBeginDay
-            maxDay = mEndDay
-        } else if (selectedYear == mBeginYear && selectedMonth == mBeginMonth) {
-            minDay = mBeginDay
-            maxDay = mSelectedTime.getActualMaximum(Calendar.DAY_OF_MONTH)
-        } else if (selectedYear == mEndYear && selectedMonth == mEndMonth) {
-            minDay = 1
-            maxDay = mEndDay
-        } else {
-            minDay = 1
-            maxDay = mSelectedTime.getActualMaximum(Calendar.DAY_OF_MONTH)
-        }
-
-        mDayUnits.clear()
-        for (i in minDay..maxDay) {
-            mDayUnits.add(i.toString())
-        }
-        binding.dpvDay.setDataList(mDayUnits)
-
-        val selectedDay = getValueInRange(mSelectedTime[Calendar.DAY_OF_MONTH], minDay, maxDay)
-        mSelectedTime[Calendar.DAY_OF_MONTH] = selectedDay
-        binding.dpvDay.setSelected(selectedDay - minDay)
-        if (showAnim) {
-            binding.dpvDay.startAnim()
-        }
-
-        binding.dpvDay.postDelayed({ linkageHourUnit(showAnim, delay) }, delay)
-    }
-
-    /**
-     * 联动“时”变化
-     *
-     * @param showAnim 是否展示滚动动画
-     * @param delay    联动下一级延迟时间
-     */
-    @SuppressLint("DefaultLocale")
-    private fun linkageHourUnit(showAnim: Boolean, delay: Long) {
-        if (!isViewBindingValid()) {
-            return
-        }
-        if ((mScrollUnits and SCROLL_UNIT_HOUR) == SCROLL_UNIT_HOUR) {
-            val minHour: Int
-            val maxHour: Int
-            val selectedYear = mSelectedTime[Calendar.YEAR]
-            val selectedMonth = mSelectedTime[Calendar.MONTH] + 1
-            val selectedDay = mSelectedTime[Calendar.DAY_OF_MONTH]
-            if (mBeginYear == mEndYear && mBeginMonth == mEndMonth && mBeginDay == mEndDay) {
-                minHour = mBeginHour
-                maxHour = mEndHour
-            } else if (selectedYear == mBeginYear && selectedMonth == mBeginMonth && selectedDay == mBeginDay) {
-                minHour = mBeginHour
-                maxHour = MAX_HOUR_UNIT
-            } else if (selectedYear == mEndYear && selectedMonth == mEndMonth && selectedDay == mEndDay) {
-                minHour = 0
-                maxHour = mEndHour
-            } else {
-                minHour = 0
-                maxHour = MAX_HOUR_UNIT
-            }
-
-            mHourUnits.clear()
-            for (i in minHour..maxHour) {
-                mHourUnits.add(i.toString())
-            }
-            binding.dpvHour.setDataList(mHourUnits)
-
-            val selectedHour =
-                getValueInRange(mSelectedTime[Calendar.HOUR_OF_DAY], minHour, maxHour)
-            mSelectedTime[Calendar.HOUR_OF_DAY] = selectedHour
-            binding.dpvHour.setSelected(selectedHour - minHour)
-            if (showAnim) {
-                binding.dpvHour.startAnim()
-            }
-        }
-
-        binding.dpvHour.postDelayed({ linkageMinuteUnit(showAnim) }, delay)
-    }
-
-    /**
-     * 联动“分”变化
-     *
-     * @param showAnim 是否展示滚动动画
-     */
-    private fun linkageMinuteUnit(showAnim: Boolean) {
-        if (!isViewBindingValid()) {
-            return
-        }
-        if ((mScrollUnits and SCROLL_UNIT_MINUTE) == SCROLL_UNIT_MINUTE) {
-            val minMinute: Int
-            val maxMinute: Int
-            val selectedYear = mSelectedTime[Calendar.YEAR]
-            val selectedMonth = mSelectedTime[Calendar.MONTH] + 1
-            val selectedDay = mSelectedTime[Calendar.DAY_OF_MONTH]
-            val selectedHour = mSelectedTime[Calendar.HOUR_OF_DAY]
-            if (mBeginYear == mEndYear && mBeginMonth == mEndMonth && mBeginDay == mEndDay && mBeginHour == mEndHour) {
-                minMinute = mBeginMinute
-                maxMinute = mEndMinute
-            } else if (selectedYear == mBeginYear && selectedMonth == mBeginMonth && selectedDay == mBeginDay && selectedHour == mBeginHour) {
-                minMinute = mBeginMinute
-                maxMinute = MAX_MINUTE_UNIT
-            } else if (selectedYear == mEndYear && selectedMonth == mEndMonth && selectedDay == mEndDay && selectedHour == mEndHour) {
-                minMinute = 0
-                maxMinute = mEndMinute
-            } else {
-                minMinute = 0
-                maxMinute = MAX_MINUTE_UNIT
-            }
-
-            mMinuteUnits.clear()
-            for (i in minMinute..maxMinute) {
-                mMinuteUnits.add(i.toString())
-            }
-            binding.dpvMinute.setDataList(mMinuteUnits)
-            val selectedMinute =
-                getValueInRange(mSelectedTime[Calendar.MINUTE], minMinute, maxMinute)
-            mSelectedTime[Calendar.MINUTE] = selectedMinute
-            binding.dpvMinute.setSelected(selectedMinute - minMinute)
-            if (showAnim) {
-                binding.dpvMinute.startAnim()
-            }
-        }
-
-        setCanScroll()
-    }
-
-    private fun getValueInRange(value: Int, minValue: Int, maxValue: Int): Int {
-        return if (value < minValue) {
-            minValue
-        } else if (value > maxValue) {
-            maxValue
-        } else {
-            value
-        }
-    }
-
-    /**
-     * 设置日期选择器的选中时间
-     *
-     * @param dateStr  日期字符串
-     * @param showAnim 是否展示动画
-     * @return 是否设置成功
-     */
-    fun setSelectedTime(dateStr: String?, showAnim: Boolean): Boolean {
-        return (!TextUtils.isEmpty(dateStr)
-                && setSelectedTime(
-            str2Long(
-                dateStr ?: "", mCanShowPreciseTime
-            ), showAnim
-        ))
-    }
-
-    /**
-     * 设置日期选择器的选中时间
-     *
-     * @param timestamp 毫秒级时间戳
-     * @param showAnim  是否展示动画
-     * @return 是否设置成功
-     */
-    fun setSelectedTime(timestamp: Long, showAnim: Boolean): Boolean {
-        var timestamp = timestamp
-
-        if (timestamp < mBeginTime.timeInMillis) {
-            timestamp = mBeginTime.timeInMillis
-        } else if (timestamp > mEndTime.timeInMillis) {
-            timestamp = mEndTime.timeInMillis
-        }
-        mSelectedTime.timeInMillis = timestamp
-
-        mYearUnits.clear()
-        for (i in mBeginYear..mEndYear) {
-            mYearUnits.add(i.toString())
-        }
-        binding.dpvYear.setDataList(mYearUnits)
-        binding.dpvYear.setSelected(mSelectedTime[Calendar.YEAR] - mBeginYear)
-        linkageMonthUnit(showAnim, if (showAnim) LINKAGE_DELAY_DEFAULT else 0)
-        return true
-    }
-
-    /**
-     * 设置是否允许点击屏幕或物理返回键关闭
-     */
-//    override fun setCancelable(cancelable: Boolean) {
-//        this.isCancelable = cancelable
-//    }
-
-    /**
-     * 设置日期控件是否显示日、时和分
-     */
-    private fun setCanShowPreciseTime(canShowPreciseTime: Boolean, canShowDay: Boolean) {
-        if (canShowPreciseTime) {
-            initScrollUnit()
-            binding.dpvHour.show()
-            binding.tvMinDivider.show()
-            binding.dpvMinute.show()
-        } else {
-            initScrollUnit(SCROLL_UNIT_HOUR, SCROLL_UNIT_MINUTE)
-            binding.tvHourDivider.gone()
-            binding.dpvHour.gone()
-            binding.tvMinDivider.gone()
-            binding.dpvMinute.gone()
-        }
-        if(canShowDay) {
-            binding.tvDayDivider.show()
-            binding.dpvDay.show()
-        } else {
-            binding.tvDayDivider.gone()
-            binding.dpvDay.gone()
-        }
-        mCanShowPreciseTime = canShowPreciseTime
-    }
-
-    private fun initScrollUnit(vararg units: Int) {
-        if (units.isEmpty()) {
-            mScrollUnits = SCROLL_UNIT_HOUR + SCROLL_UNIT_MINUTE
-        } else {
-            for (unit in units) {
-                mScrollUnits = mScrollUnits xor unit
-            }
-        }
-    }
-
-    /**
-     * 设置日期控件是否可以循环滚动
-     */
-    fun setScrollLoop(canLoop: Boolean) {
-//        if (!canShow()) return
-
-        binding.dpvYear.setCanScrollLoop(canLoop)
-        binding.dpvMonth.setCanScrollLoop(canLoop)
-        binding.dpvDay.setCanScrollLoop(canLoop)
-        binding.dpvHour.setCanScrollLoop(canLoop)
-        binding.dpvMinute.setCanScrollLoop(canLoop)
-    }
-
-    /**
-     * 设置日期控件是否展示滚动动画
-     */
-    fun setCanShowAnim(canShowAnim: Boolean) {
-//        if (!canShow()) return
-
-        binding.dpvYear.setCanShowAnim(canShowAnim)
-        binding.dpvMonth.setCanShowAnim(canShowAnim)
-        binding.dpvDay.setCanShowAnim(canShowAnim)
-        binding.dpvHour.setCanShowAnim(canShowAnim)
-        binding.dpvMinute.setCanShowAnim(canShowAnim)
-    }
-
-    override fun resetWindowAttributes(window: Window) {
-        super.resetWindowAttributes(window)
-        window.setLayout(
-            WindowManager.LayoutParams.MATCH_PARENT,
-            WindowManager.LayoutParams.WRAP_CONTENT
-        )
-        window.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
-        val attr = window.attributes
-        attr.dimAmount = 0.7f
-        attr.gravity = Gravity.CENTER
-        window.attributes = attr
-    }
-
-}

+ 0 - 52
app/src/main/java/com/adealink/weparty/commonui/datepicker/DateFormatUtils.kt

@@ -1,52 +0,0 @@
-package com.adealink.weparty.commonui.datepicker
-
-import java.text.SimpleDateFormat
-import java.util.Date
-import java.util.Locale
-
-object DateFormatUtils {
-    private const val DATE_FORMAT_PATTERN_YMD = "yyyy-MM-dd"
-    private const val DATE_FORMAT_PATTERN_YMD_HM = "yyyy-MM-dd HH:mm"
-
-    /**
-     * 时间戳转字符串
-     *
-     * @param timestamp     时间戳
-     * @param isPreciseTime 是否包含时分
-     * @return 格式化的日期字符串
-     */
-    fun long2Str(timestamp: Long, isPreciseTime: Boolean): String {
-        return long2Str(timestamp, getFormatPattern(isPreciseTime))
-    }
-
-    private fun long2Str(timestamp: Long, pattern: String): String {
-        return SimpleDateFormat(pattern, Locale.CHINA).format(Date(timestamp))
-    }
-
-    /**
-     * 字符串转时间戳
-     *
-     * @param dateStr       日期字符串
-     * @param isPreciseTime 是否包含时分
-     * @return 时间戳
-     */
-    fun str2Long(dateStr: String, isPreciseTime: Boolean): Long {
-        return str2Long(dateStr, getFormatPattern(isPreciseTime))
-    }
-
-    private fun str2Long(dateStr: String, pattern: String): Long {
-        try {
-            return SimpleDateFormat(pattern, Locale.ENGLISH).parse(dateStr).time
-        } catch (ignored: Throwable) {
-        }
-        return 0
-    }
-
-    private fun getFormatPattern(showSpecificTime: Boolean): String {
-        return if (showSpecificTime) {
-            DATE_FORMAT_PATTERN_YMD_HM
-        } else {
-            DATE_FORMAT_PATTERN_YMD
-        }
-    }
-}

+ 0 - 363
app/src/main/java/com/adealink/weparty/commonui/datepicker/PickerView.kt

@@ -1,363 +0,0 @@
-package com.adealink.weparty.commonui.datepicker
-
-import android.animation.ObjectAnimator
-import android.animation.PropertyValuesHolder
-import android.content.Context
-import android.graphics.Canvas
-import android.graphics.Paint
-import android.os.Handler
-import android.os.Message
-import android.text.TextUtils
-import android.util.AttributeSet
-import android.view.MotionEvent
-import android.view.View
-import androidx.core.content.ContextCompat
-import com.adealink.weparty.R
-import java.lang.ref.WeakReference
-import java.util.Timer
-import java.util.TimerTask
-import kotlin.math.abs
-import kotlin.math.pow
-
-class PickerView(private val mContext: Context, attrs: AttributeSet?) :
-    View(mContext, attrs) {
-    private var mPaint: Paint? = null
-    private var mLightColor = 0
-    private var mDarkColor = 0
-    private var mHalfWidth = 0f
-    private var mHalfHeight = 0f
-    private var mQuarterHeight = 0f
-    private var mMinTextSize = 0f
-    private var mTextSizeRange = 0f
-    private var mTextSpacing = 0f
-    private var mHalfTextSpacing = 0f
-
-    private var mScrollDistance = 0f
-    private var mLastTouchY = 0f
-    private var mDataList: MutableList<String> = ArrayList()
-    private var mSelectedIndex = 0
-    private var mCanScroll = true
-    private var mCanScrollLoop = true
-    private var mOnSelectListener: OnSelectListener? = null
-    private var mScrollAnim: ObjectAnimator? = null
-    private var mCanShowAnim = true
-
-    private var mTimer: Timer? = Timer()
-    private var mTimerTask: TimerTask? = null
-    private val mHandler: Handler = ScrollHandler(this)
-
-    /**
-     * 选择结果回调接口
-     */
-    interface OnSelectListener {
-        fun onSelect(view: View?, selected: String?)
-    }
-
-    private class ScrollTimerTask(handler: Handler) : TimerTask() {
-        private val mWeakHandler = WeakReference(handler)
-
-        override fun run() {
-            val handler = mWeakHandler.get() ?: return
-
-            handler.sendEmptyMessage(0)
-        }
-    }
-
-    private class ScrollHandler(view: PickerView) : Handler() {
-        private val mWeakView = WeakReference(view)
-
-        override fun handleMessage(msg: Message) {
-            val view = mWeakView.get() ?: return
-
-            view.keepScrolling()
-        }
-    }
-
-    init {
-        initPaint()
-    }
-
-    private fun initPaint() {
-        mPaint = Paint(Paint.ANTI_ALIAS_FLAG)
-        mPaint?.style = Paint.Style.FILL
-        mPaint?.textAlign = Paint.Align.CENTER
-        mLightColor = ContextCompat.getColor(mContext, R.color.color_222222)
-        mDarkColor = ContextCompat.getColor(mContext, R.color.color_FFAAAAAA)
-    }
-
-    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
-        super.onMeasure(widthMeasureSpec, heightMeasureSpec)
-
-        mHalfWidth = measuredWidth / 2f
-        val height = measuredHeight
-        mHalfHeight = height / 2f
-        mQuarterHeight = height / 4f
-        val maxTextSize = height / 7f
-        mMinTextSize = maxTextSize / 2.2f
-        mTextSizeRange = maxTextSize - mMinTextSize
-        mTextSpacing = mMinTextSize * 2.8f
-        mHalfTextSpacing = mTextSpacing / 2f
-    }
-
-    override fun onDraw(canvas: Canvas) {
-        super.onDraw(canvas)
-
-        if (mSelectedIndex >= mDataList.size) return
-
-        // 绘制选中的 text
-        drawText(canvas, mLightColor, mScrollDistance, mDataList[mSelectedIndex])
-
-        // 绘制选中上方的 text
-        for (i in 1..mSelectedIndex) {
-            drawText(
-                canvas, mDarkColor, mScrollDistance - i * mTextSpacing,
-                mDataList[mSelectedIndex - i]
-            )
-        }
-
-        // 绘制选中下方的 text
-        val size = mDataList.size - mSelectedIndex
-        for (i in 1 until size) {
-            drawText(
-                canvas, mDarkColor, mScrollDistance + i * mTextSpacing,
-                mDataList[mSelectedIndex + i]
-            )
-        }
-    }
-
-    private fun drawText(canvas: Canvas, textColor: Int, offsetY: Float, text: String) {
-        if (TextUtils.isEmpty(text)) return
-        val mPaint = mPaint ?: return
-        var scale = 1 - (offsetY / mQuarterHeight).pow(2)
-        scale = if (scale < 0) 0f else scale
-        mPaint.textSize = mMinTextSize + mTextSizeRange * scale
-        mPaint.color = textColor
-        mPaint.alpha = TEXT_ALPHA_MIN + (TEXT_ALPHA_RANGE * scale).toInt()
-
-        // text 居中绘制,mHalfHeight + offsetY 是 text 的中心坐标
-        val fm = mPaint.fontMetrics ?: return
-        val baseline = mHalfHeight + offsetY - (fm.top + fm.bottom) / 2f
-        canvas.drawText(text, mHalfWidth, baseline, mPaint)
-    }
-
-    override fun dispatchTouchEvent(event: MotionEvent): Boolean {
-        return mCanScroll && super.dispatchTouchEvent(event)
-    }
-
-    override fun onTouchEvent(event: MotionEvent): Boolean {
-        when (event.actionMasked) {
-            MotionEvent.ACTION_DOWN -> {
-                cancelTimerTask()
-                mLastTouchY = event.y
-            }
-
-            MotionEvent.ACTION_MOVE -> {
-                val offsetY = event.y
-                mScrollDistance += offsetY - mLastTouchY
-                if (mScrollDistance > mHalfTextSpacing) {
-                    if (!mCanScrollLoop) {
-                        if (mSelectedIndex == 0) {
-                            mLastTouchY = offsetY
-                            invalidate()
-                            return true // 替代 break,直接返回
-                        } else {
-                            mSelectedIndex--
-                        }
-                    } else {
-                        // 往下滑超过离开距离,将末尾元素移到首位
-                        moveTailToHead()
-                    }
-                    mScrollDistance -= mTextSpacing
-                } else if (mScrollDistance < -mHalfTextSpacing) {
-                    if (!mCanScrollLoop) {
-                        if (mSelectedIndex == mDataList.size - 1) {
-                            mLastTouchY = offsetY
-                            invalidate()
-                            return true // 替代 break,直接返回
-                        } else {
-                            mSelectedIndex++
-                        }
-                    } else {
-                        // 往上滑超过离开距离,将首位元素移到末尾
-                        moveHeadToTail()
-                    }
-                    mScrollDistance += mTextSpacing
-                }
-                mLastTouchY = offsetY
-                invalidate()
-            }
-
-            MotionEvent.ACTION_UP -> {
-                // 抬起手后 mSelectedIndex 由当前位置滚动到中间选中位置
-                if (abs(mScrollDistance.toDouble()) < 0.01) {
-                    mScrollDistance = 0f
-                    return true // 替代 break,直接返回
-                }
-                cancelTimerTask()
-                mTimerTask = ScrollTimerTask(mHandler)
-                mTimer?.schedule(mTimerTask, 0, 10)
-            }
-        }
-        return true
-    }
-
-
-    private fun cancelTimerTask() {
-        if (mTimerTask != null) {
-            mTimerTask?.cancel()
-            mTimerTask = null
-        }
-        if (mTimer != null) {
-            mTimer?.purge()
-        }
-    }
-
-    private fun moveTailToHead() {
-        if (!mCanScrollLoop || mDataList.isEmpty()) return
-
-        val tail = mDataList[mDataList.size - 1]
-        mDataList.removeAt(mDataList.size - 1)
-        mDataList.add(0, tail)
-    }
-
-    private fun moveHeadToTail() {
-        if (!mCanScrollLoop || mDataList.isEmpty()) return
-
-        val head = mDataList[0]
-        mDataList.removeAt(0)
-        mDataList.add(head)
-    }
-
-    private fun keepScrolling() {
-        if (abs(mScrollDistance.toDouble()) < AUTO_SCROLL_SPEED) {
-            mScrollDistance = 0f
-            if (mTimerTask != null) {
-                cancelTimerTask()
-
-                if (mOnSelectListener != null && mSelectedIndex < mDataList.size) {
-                    mOnSelectListener?.onSelect(this, mDataList[mSelectedIndex])
-                }
-            }
-        } else if (mScrollDistance > 0) {
-            // 向下滚动
-            mScrollDistance -= AUTO_SCROLL_SPEED
-        } else {
-            // 向上滚动
-            mScrollDistance += AUTO_SCROLL_SPEED
-        }
-        invalidate()
-    }
-
-    /**
-     * 设置数据
-     */
-    fun setDataList(list: MutableList<String>?) {
-        if (list.isNullOrEmpty()) return
-
-        mDataList = list
-        // 重置 mSelectedIndex,防止溢出
-        mSelectedIndex = 0
-        invalidate()
-    }
-
-    /**
-     * 选择选中项
-     */
-    fun setSelected(index: Int) {
-        if (index >= mDataList.size) return
-
-        mSelectedIndex = index
-        if (mCanScrollLoop) {
-            // 可循环滚动时,mSelectedIndex 值固定为 mDataList / 2
-            val position = mDataList.size / 2 - mSelectedIndex
-            if (position < 0) {
-                for (i in 0 until -position) {
-                    moveHeadToTail()
-                    mSelectedIndex--
-                }
-            } else if (position > 0) {
-                for (i in 0 until position) {
-                    moveTailToHead()
-                    mSelectedIndex++
-                }
-            }
-        }
-        invalidate()
-    }
-
-    /**
-     * 设置选择结果监听
-     */
-    fun setOnSelectListener(listener: OnSelectListener?) {
-        mOnSelectListener = listener
-    }
-
-    /**
-     * 是否允许滚动
-     */
-    fun setCanScroll(canScroll: Boolean) {
-        mCanScroll = canScroll
-    }
-
-    /**
-     * 是否允许循环滚动
-     */
-    fun setCanScrollLoop(canLoop: Boolean) {
-        mCanScrollLoop = canLoop
-    }
-
-    /**
-     * 执行滚动动画
-     */
-    fun startAnim() {
-        if (!mCanShowAnim) return
-
-        if (mScrollAnim == null) {
-            val alpha = PropertyValuesHolder.ofFloat("alpha", 1f, 0f, 1f)
-            val scaleX = PropertyValuesHolder.ofFloat("scaleX", 1f, 1.3f, 1f)
-            val scaleY = PropertyValuesHolder.ofFloat("scaleY", 1f, 1.3f, 1f)
-            mScrollAnim =
-                ObjectAnimator.ofPropertyValuesHolder(this, alpha, scaleX, scaleY).setDuration(200)
-        }
-
-        if (mScrollAnim?.isRunning != true) {
-            mScrollAnim?.start()
-        }
-    }
-
-    /**
-     * 是否允许滚动动画
-     */
-    fun setCanShowAnim(canShowAnim: Boolean) {
-        mCanShowAnim = canShowAnim
-    }
-
-    /**
-     * 销毁资源
-     */
-    fun onDestroy() {
-        mOnSelectListener = null
-        mHandler.removeCallbacksAndMessages(null)
-        if (mScrollAnim != null && mScrollAnim?.isRunning == true) {
-            mScrollAnim?.cancel()
-        }
-        cancelTimerTask()
-        if (mTimer != null) {
-            mTimer?.cancel()
-            mTimer = null
-        }
-    }
-
-    companion object {
-        /**
-         * 自动回滚到中间的速度
-         */
-        private const val AUTO_SCROLL_SPEED = 10f
-
-        /**
-         * 透明度:最小 120,最大 255,极差 135
-         */
-        private const val TEXT_ALPHA_MIN = 120
-        private const val TEXT_ALPHA_RANGE = 135
-    }
-}

+ 0 - 184
app/src/main/java/com/adealink/weparty/commonui/dialogchain/BaseDialogData.kt

@@ -1,184 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain
-
-import android.os.Parcelable
-import com.adealink.weparty.module.anchor.data.AnchorMessage
-import com.adealink.weparty.module.anchor.data.CommonActivityRewardMessage
-import com.adealink.weparty.module.level.data.CommonLevelChangeNotify
-import com.adealink.weparty.module.level.data.LevelUpgradeNotify
-import com.adealink.weparty.module.operation.signinreward.data.DailySignInRewardsRes
-import com.adealink.weparty.module.task.CommonTaskCompleteRewardNotify
-import com.adealink.weparty.module.task.invite.InviteNewRewardNotify
-import com.adealink.weparty.module.userlist.data.UserInfoItemData
-import com.adealink.weparty.module.family.data.FamilyInfo
-import com.adealink.weparty.module.profile.data.UserInfo
-import io.rong.imlib.model.Message
-import com.adealink.weparty.module.level.data.VipNewFeatureData
-import kotlinx.parcelize.Parcelize
-
-
-/** 基础的弹窗数据
- * Created by XiaoDongLin.
- * Date: 2025/3/28
- */
-
-sealed class BaseDialogData(
-    val tag: String,
-) : Parcelable {
-
-    @Parcelize
-    class SignInDialogData(
-        val dialogData: DailySignInRewardsRes
-    ) : Parcelable, BaseDialogData("SignInDialog") {
-
-    }
-
-    @Parcelize
-    class CommonTaskRewardDialogData(
-        val notify: CommonTaskCompleteRewardNotify
-    ) : Parcelable, BaseDialogData("TaskRewardDialog")
-
-    @Parcelize
-    object WomenChatDiamondDialogData : Parcelable,
-        BaseDialogData("WomenChatDiamondDialog")
-
-
-    @Parcelize
-    object CompleteProfileDialogData : Parcelable,
-        BaseDialogData("CompleteProfileDialog")
-
-    //奖励数量
-    @Parcelize
-    data class WelcomeRewardDialogData(val rewardCount: Int, val endTime: Long, val dotCount: Int) :
-        Parcelable,
-        BaseDialogData("WelcomeRewardDialog")
-
-    //新客奖励弹窗
-    @Parcelize
-    data class NewUserRewardDialogData(
-        val coins: Int,
-        val chatTimes: Int,
-    ) : Parcelable, BaseDialogData("NewUserRewardDialog")
-
-    //新客抽奖弹窗
-    @Parcelize
-    object NewUserLotteryDialogData : Parcelable,
-        BaseDialogData("NewUserLotteryDialogData")
-
-    //打招呼弹窗
-    @Parcelize
-    data class NewUserGreetingDialogData(
-        val userInfoList: List<UserInfoItemData>,
-    ) : Parcelable, BaseDialogData("NewUserGreetingDialog")
-
-    @Parcelize
-    class InviteNewRewardDialogData(
-        val notify: InviteNewRewardNotify
-    ) : Parcelable, BaseDialogData("InviteNewRewardDialog")
-
-    @Parcelize
-    class WealthLevelUpgradeDialogData(
-        val notify: LevelUpgradeNotify
-    ) : Parcelable, BaseDialogData("WealthLevelUpgradeDialog")
-
-    @Parcelize
-    class VipRechargeLevelUpgradeDialogData(
-        val notify: CommonLevelChangeNotify
-    ) : Parcelable, BaseDialogData("VipRechargeLevelUpgradeDialog")
-
-    @Parcelize
-    class CharmLevelUpgradeDialogData(
-        val notify: CommonLevelChangeNotify
-    ) : Parcelable, BaseDialogData("CharmLevelUpgradeDialog")
-
-    @Parcelize
-    class MedalAchieveDialogData(
-        val medalId: Long,
-        val medalUrl: String,
-        val medalDynamicUrl: String?,
-        val medalLevel: Int,
-        val medalSubLevel: Int,
-        val medalName: String,
-        val medalDesc: String?
-    ) : Parcelable, BaseDialogData("MedalAchieveDialog")
-
-
-    @Parcelize
-    class AnchorDiamondRewardDialogData(val message: AnchorMessage) : Parcelable,
-        BaseDialogData("AnchorDiamondRewardDialog")
-
-    @Parcelize
-    object UploadAvatarGuideDialogData : Parcelable, BaseDialogData("UploadAvatarDialog")
-
-    @Parcelize
-    object LowQualityAvatarDialogData: Parcelable, BaseDialogData("LowQualityAvatarDialog") {
-        // 低质量头像弹窗数据
-    }
-
-    /**
-     * 性别变更弹窗
-     */
-    @Parcelize
-    data class GenderChangeDialogData(
-        val messageId: Long = 0,
-        val messageType: Int = 0,
-        val title: CharSequence?,
-        val content: CharSequence?,
-        val positiveText: CharSequence?,
-        val negativeText: CharSequence?,
-    ) : Parcelable, BaseDialogData("GenderChangeDialog")
-
-    @Parcelize
-    data class SafetyNotificationData(
-        val messageId: Long,
-        val messageType: Int
-    ) : Parcelable, BaseDialogData("SafetyNotificationDialog")
-    @Parcelize
-    class GreetSettingGuideDialogData(val extraToUid: Long) : Parcelable,
-        BaseDialogData("GreetSettingGuideDialog")
-
-    @Parcelize
-    class TodayFateDialogData(val recommendId: String, val userInfos: List<UserInfo>) : Parcelable,
-        BaseDialogData("TodayFateDialog")
-
-    @Parcelize
-    class MessageReminderDialogData(val message: Message) : Parcelable, BaseDialogData("MessageReminderDialog")
-
-    @Parcelize
-    class MessageIncomeReminderDialogData(val content: String, val sender: UserInfo) : Parcelable,
-        BaseDialogData("MessageIncomeReminderDialog")
-
-    @Parcelize
-    class DailyMsgLimitReminderDialogData(val curCount: Long, val totalCount: Long) : Parcelable,
-        BaseDialogData("DailyMsgLimitReminderDialog")
-
-    @Parcelize
-    class MsgSendFailedDialogData(val countDownTime: Long, val totalCount: Long) : Parcelable,
-        BaseDialogData("MsgSendFailedDialog")
-
-    @Parcelize
-    data class CommonActivityDialogData(
-        val messageId: Long,
-        val messageType: Int,
-        val rewareMessage : CommonActivityRewardMessage
-    ) : Parcelable, BaseDialogData("CommonActivityDialog")
-
-    @Parcelize
-    data class FamilyJoinSuccessData(
-        val messageId: Long,
-        val messageType: Int,
-        val familyInfo: FamilyInfo
-    ) : Parcelable, BaseDialogData("FamilyJoinSuccessDialog")
-
-    @Parcelize
-    data class FamilyLevelUpgradeData(
-        val messageId: Long,
-        val messageType: Int,
-        val level: Int
-    ) : Parcelable, BaseDialogData("FamilyLevelUpgradeDialog")
-
-    @Parcelize
-    data class VipNewFeatureDialogData(
-        val vipNewFeatureData: VipNewFeatureData
-    ) : Parcelable, BaseDialogData("VipNewFeatureDialog")
-}
-

+ 0 - 29
app/src/main/java/com/adealink/weparty/commonui/dialogchain/BaseDialogTask.kt

@@ -1,29 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain
-
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.Rlt
-
-/**
- * Created by XiaoDongLin.
- * Date: 2025/4/21
- */
-
-abstract class BaseDialogTask<DATA : BaseDialogData>() {
-    abstract val priority: Int
-    abstract val tag: String // 用于去重等
-
-    abstract suspend fun canShow(): Rlt<DATA>
-    abstract fun showDialog(dialogData: DATA, fragmentActivity: FragmentActivity): Int?
-
-    //某个弹窗任务只在指定的一组 Activity 页面中才允许展示。(默认弹窗是当前可见activity就会弹)
-    open val onlyShowInActivities: List<String> = listOf()
-    
-    //不允许显示弹窗的Activity页面列表(优先级高于onlyShowInActivities)
-    open val excludeActivities: List<String> = listOf()
-
-    //不允许显示弹窗的Fragment页面列表(优先级高于onlyShowInActivities)
-    open val excludeFragments: List<String> = listOf()
-
-    //生成的弹窗数据
-    var dialogData: BaseDialogData? = null
-}

+ 0 - 10
app/src/main/java/com/adealink/weparty/commonui/dialogchain/DialogScope.kt

@@ -1,10 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain
-
-/**
- * Created by XiaoDongLin.
- * Date: 2025/5/10
- */
-class DialogScope {
-
-
-}

+ 0 - 221
app/src/main/java/com/adealink/weparty/commonui/dialogchain/DialogShowManager.kt

@@ -1,221 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain
-
-import android.app.Activity
-import android.os.Bundle
-import android.util.Log
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.util.ActivityLifecycleCallbacksExt
-import com.adealink.frame.util.AppUtil
-import com.adealink.frame.util.runOnUiThread
-import com.adealink.weparty.App
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.commonui.ext.isUiValid
-
-
-/**
- * DialogShowManager进行消费,交由对应的DialogQueue进行处理。
- * Created by XiaoDongLin.
- * Date: 2025/4/21
- */
-interface IDialogShowManager {
-
-    fun submit(task: BaseDialogTask<BaseDialogData>, dialogData: BaseDialogData)
-
-
-    /**
-     * 当前页面弹窗关闭后,可以尝试展示下一个弹窗
-     */
-    fun tryShowNextDialog(activity: FragmentActivity)
-
-    fun removeSelfAndTryShowNextDialog(dialogFragment: BaseDialogFragment)
-
-    fun logout()
-
-    /**
-     * 手动暂停/恢复弹窗分发
-     */
-    fun pause()
-
-    fun resume()
-
-    fun removeWaitToShowDialog(predicate: (BaseDialogTask<BaseDialogData>) -> Boolean)
-}
-
-object DialogShowManager : IDialogShowManager {
-
-    private const val TAG = "DialogShowManager"
-
-    //等待展示的弹窗列表
-    private val waitToShowDialogQueue = mutableListOf<BaseDialogTask<BaseDialogData>>()
-
-    //key,页面hashCode,value,正在展示的弹窗
-    private val showingDialogMap = mutableMapOf<Int, Int?>()
-
-
-    init {
-        App.instance.registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacksExt {
-
-            override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
-                super.onActivityCreated(activity, savedInstanceState)
-                Log.d(TAG, "onActivityCreated: ${activity.javaClass.simpleName}")
-//                todo:有问题,没监听到?先通过BaseDialogFragment.onDismiss手动触发
-//                if (activity is FragmentActivity) {
-//                    activity.supportFragmentManager.registerFragmentLifecycleCallbacks(object :
-//                        FragmentManager.FragmentLifecycleCallbacks() {
-//                        override fun onFragmentViewDestroyed(fm: FragmentManager, f: Fragment) {
-//                            super.onFragmentViewDestroyed(fm, f)
-//                            if (f is BaseDialogFragment) {
-//                                if (showingDialogMap.getOrElse(
-//                                        activity.hashCode(),
-//                                        defaultValue = { 0 }) == f.hashCode()
-//                                ) {
-//                                    showingDialogMap.remove(activity.hashCode())
-//                                }
-//                                tryShowNextDialog(activity)
-//                            }
-//                        }
-//
-//                    }, true)
-//                }
-
-            }
-
-            override fun onActivityResumed(activity: Activity) {
-                super.onActivityResumed(activity)
-                Log.d(TAG, "onActivityResumed: ${activity.javaClass.simpleName}")
-
-                if (activity is FragmentActivity) {
-                    tryShowNextDialog(activity)
-                }
-            }
-
-            override fun onActivityDestroyed(activity: Activity) {
-                super.onActivityDestroyed(activity)
-                Log.d(TAG, "onActivityDestroyed: ${activity.javaClass.simpleName}")
-//                todo:后续再优化
-//                if (activity is FragmentActivity) {
-//                    waitToShowDialogQueue.removeAll { it.lifecycleOwner == activity }
-//                }
-
-            }
-        })
-
-    }
-
-    override fun submit(task: BaseDialogTask<BaseDialogData>, dialogData: BaseDialogData) {
-        runOnUiThread {
-            waitToShowDialogQueue.add(task)
-            waitToShowDialogQueue.sortByDescending { it.priority }
-
-            val activity = AppUtil.currentActivity as? FragmentActivity ?: return@runOnUiThread
-            if (!activity.isUiValid()) {
-                return@runOnUiThread
-            }
-            tryShowNextDialog(activity)
-        }
-    }
-
-
-    override fun tryShowNextDialog(activity: FragmentActivity) {
-        if (paused){
-            Log.i(TAG, "tryShowNextDialog: paused, not showing dialog")
-            return
-        }
-        //在当前页面中寻找第一个可展示的任务
-        Log.i(
-            TAG,
-            "tryShowNextDialog: size:${waitToShowDialogQueue.size}, queue:$waitToShowDialogQueue,activity:${activity}"
-        )
-        if (waitToShowDialogQueue.isEmpty()) {
-            return
-        }
-        if (!activity.isUiValid()) {
-            return
-        }
-        if (AppUtil.background){
-            //如果当前应用在后台,则不展示弹窗
-            return
-        }
-
-        val activityKey = activity.hashCode()
-        val iterator = waitToShowDialogQueue.iterator()
-        while (iterator.hasNext()) {
-            val task = iterator.next()
-
-            val currentActivityName = activity::class.java.name
-            
-            // 优先检查是否在排除列表中(高优先级)
-            if (task.excludeActivities.isNotEmpty()) {
-                if (currentActivityName in task.excludeActivities) {
-                    continue
-                }
-            }
-
-            if (task.excludeFragments.isNotEmpty()) {
-                val fragments =
-                    (activity as? FragmentActivity)?.supportFragmentManager?.fragments.orEmpty()
-                val needExclude = task.excludeFragments.any { excludeFragment ->
-                    fragments.any { it::class.java.name == excludeFragment && it.isResumed && it.userVisibleHint && it.isVisible }
-                }
-                if (needExclude) continue
-            }
-
-            // 校验当前是否是允许展示的 Activity 页面
-            if (task.onlyShowInActivities.isNotEmpty()) {
-                if (currentActivityName !in task.onlyShowInActivities) {
-                    continue
-                }
-            }
-
-            // 当前页面是否已经展示弹窗
-            if (showingDialogMap[activityKey] != null) {
-                Log.i(TAG, "showingDialogMap[activityKey] != null")
-                continue
-            }
-
-            if (task.dialogData == null) {
-                Log.i(TAG, "task.dialogData == null")
-                continue
-            }
-
-            //找到了!展示并从队列移除
-            iterator.remove()
-            Log.i(TAG, "tryShowNextDialog show: $task")
-            val code = task.showDialog(task.dialogData!!, activity)
-            showingDialogMap[activityKey] = code
-            return
-        }
-    }
-
-    override fun removeSelfAndTryShowNextDialog(dialogFragment: BaseDialogFragment) {
-        val activity = dialogFragment.requireActivity()
-        if (showingDialogMap.getOrElse(
-                activity.hashCode(),
-                defaultValue = { 0 }) == dialogFragment.hashCode()
-        ) {
-            showingDialogMap.remove(activity.hashCode())
-        }
-        tryShowNextDialog(activity)
-    }
-
-    override fun logout() {
-        waitToShowDialogQueue.clear()
-    }
-
-    private var paused = false
-    override fun resume() {
-        paused = false
-        Log.i(TAG, "resume: ")
-        tryShowNextDialog(AppUtil.currentActivity as? FragmentActivity ?: return)
-    }
-
-    override fun removeWaitToShowDialog(predicate: (BaseDialogTask<BaseDialogData>) -> Boolean) {
-        waitToShowDialogQueue.removeAll(waitToShowDialogQueue.filter(predicate))
-    }
-
-    override fun pause() {
-        paused = true
-        Log.i(TAG, "pause: ")
-    }
-
-}

+ 0 - 72
app/src/main/java/com/adealink/weparty/commonui/dialogchain/DialogTaskManager.kt

@@ -1,72 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain
-
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.log.Log
-import com.adealink.weparty.commonui.ext.isSuccess
-import kotlinx.coroutines.GlobalScope
-import kotlinx.coroutines.launch
-import java.util.concurrent.PriorityBlockingQueue
-
-/**
- * todo:
- * Created by XiaoDongLin.
- * Date: 2025/4/17
- */
-interface IDialogTaskManager {
-
-    /**
-     * 提交任务
-     */
-    fun <DATA : BaseDialogData> submit(task: BaseDialogTask<DATA>)
-
-    /**
-     * 清空任务(可用于退出/清理)
-     */
-    fun clear()
-}
-
-
-object DialogTaskManager : IDialogTaskManager {
-
-    private const val TAG = "DialogTaskManager"
-
-    private val taskQueue = PriorityBlockingQueue<BaseDialogTask<*>>(20, Comparator { o1, o2 ->
-        return@Comparator o2.priority - o1.priority
-    })
-
-    @Suppress("UNCHECKED_CAST")
-    private fun runNext() {
-        if (taskQueue.isEmpty()) return
-        val task = taskQueue.poll()
-        task ?: return
-
-        GlobalScope.launch {
-            try {
-                task as BaseDialogTask<BaseDialogData>
-                val rlt = task.canShow()
-                Log.i(TAG, "runNext, task:${task.javaClass.simpleName},  rlt.isSuccess:${rlt.isSuccess}")
-                if (rlt is Rlt.Success) {
-                    task.dialogData = rlt.data
-                    DialogShowManager.submit(task, rlt.data)
-                }
-            } catch (e: Exception) {
-                e.printStackTrace()
-            } finally {
-                runNext() // try next task
-            }
-        }
-    }
-
-
-    override fun <DATA : BaseDialogData> submit(task: BaseDialogTask<DATA>) {
-        taskQueue.add(task)
-        runNext()
-    }
-
-    @Synchronized
-    override fun clear() {
-        taskQueue.clear()
-    }
-
-
-}

+ 0 - 21
app/src/main/java/com/adealink/weparty/commonui/dialogchain/Priority.kt

@@ -1,21 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain
-
-
-enum class Priority(val priority: Int) {
-    HIGHEST(999),
-    HIGHER(6),
-    HIGH(5),
-    NORMAL(4),
-    LOW(3),
-    LOWER(2),
-    LOWEST(1),
-
-
-
-    //todo:临时排序一下
-
-    NEW_USER_REWRARD(100),
-    NEW_USER_GREET(99),
-    NEW_USER_LOTTERY(98),
-    WELCOME_DIALOG_TASK(97);
-}

+ 0 - 54
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/CharmLevelUpgradeDialogTask.kt

@@ -1,54 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import android.os.Bundle
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.router.Router
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.module.level.Level
-import com.adealink.weparty.module.level.data.CommonLevelChangeNotify
-
-/**
- * Created by XiaoDongLin.
- * Date: 2025/5/8
- */
-class CharmLevelUpgradeDialogTask(
-    val notify: CommonLevelChangeNotify
-) :
-    BaseDialogTask<BaseDialogData.CharmLevelUpgradeDialogData>() {
-    override val priority: Int
-        get() = Priority.NORMAL.priority
-    override val tag: String
-        get() = "CharmLevelUpgradeDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.CharmLevelUpgradeDialogData> {
-        return Rlt.Success(
-            BaseDialogData.CharmLevelUpgradeDialogData(
-                notify
-            )
-        )
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.CharmLevelUpgradeDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        val fragment =
-            Router.getRouterInstance<BaseDialogFragment>(Level.CharmUpgrade.PATH)
-                ?.apply {
-                    arguments = Bundle().apply {
-                        putParcelable(
-                            Level.VipRechargeLevelUpgrade.EXTRA_UPGRADE_DATA,
-                            dialogData.notify
-                        )
-                    }
-                }
-        fragment?.show(fragmentActivity.supportFragmentManager)
-        return fragment.hashCode()
-    }
-
-
-}

+ 0 - 48
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/CommonDialogTask.kt

@@ -1,48 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.Rlt
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.widget.CommonDialog
-import com.adealink.weparty.module.anchor.AnchorModule
-import com.adealink.weparty.module.anchor.data.AnchorMessage
-import com.adealink.weparty.module.anchor.data.AnchorMessageReplyCode
-
-/**
- * 通用安全通知对话框任务
- * Dialog构建位于AnchorManager
- */
-class CommonDialogTask(
-    private val message: AnchorMessage,
-    private val dialog: CommonDialog,
-) : BaseDialogTask<BaseDialogData.SafetyNotificationData>() {
-
-    override val priority: Int = Priority.HIGHEST.priority
-    override val tag: String = "CommonDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.SafetyNotificationData> {
-        return Rlt.Success(
-            BaseDialogData.SafetyNotificationData(
-                messageId = message.messageId,
-                messageType = message.messageType
-            )
-        )
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.SafetyNotificationData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        // 展示即消费
-        val anchorViewModel = AnchorModule.getAnchorViewModel(fragmentActivity)
-        anchorViewModel?.replyAnchorMessage(
-            dialogData.messageId,
-            dialogData.messageType,
-            AnchorMessageReplyCode.REPLY_READ
-        )
-        dialog.show(fragmentActivity.supportFragmentManager,"CommonDialogTask")
-        return dialog.hashCode()
-    }
-}

+ 0 - 54
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/CommonTaskRewardDialogTask.kt

@@ -1,54 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import android.os.Bundle
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.router.Router
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.module.task.CommonTaskCompleteRewardNotify
-import com.adealink.weparty.module.task.UserTask
-
-/**
- * Created by XiaoDongLin.
- * Date: 2025/5/10
- */
-class CommonTaskRewardDialogTask(
-    val notify: CommonTaskCompleteRewardNotify
-) :
-    BaseDialogTask<BaseDialogData.CommonTaskRewardDialogData>() {
-    override val priority: Int
-        get() = Priority.HIGH.priority
-    override val tag: String
-        get() = "CommonTaskRewardDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.CommonTaskRewardDialogData> {
-        return Rlt.Success(
-            BaseDialogData.CommonTaskRewardDialogData(
-                notify
-            )
-        )
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.CommonTaskRewardDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        val fragment =
-            Router.getRouterInstance<BaseDialogFragment>(UserTask.TaskRewardDialog.PATH)
-                ?.apply {
-                    arguments = Bundle().apply {
-                        putParcelable(
-                            UserTask.TaskRewardDialog.EXTRA_NOTIFY_DATA,
-                            dialogData.notify
-                        )
-                    }
-                }
-        fragment?.show(fragmentActivity.supportFragmentManager)
-        return fragment.hashCode()
-    }
-
-
-}

+ 0 - 48
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/CompleteProfileDialogTask.kt

@@ -1,48 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.IError
-import com.adealink.frame.base.Rlt
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.module.task.CompleteProfileDialog
-import com.adealink.weparty.module.task.DialogLocalService
-import com.adealink.weparty.module.task.TaskItemReward
-
-/**
- * Created by XiaoDongLin.
- * Date: 2025/5/6
- */
-class CompleteProfileDialogTask(
-    private val taskInfo: TaskItemReward
-) : BaseDialogTask<BaseDialogData.CompleteProfileDialogData>() {
-    override val priority: Int
-        get() = Priority.NORMAL.priority
-    override val tag: String
-        get() = "CompleteProfileDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.CompleteProfileDialogData> {
-        if (DialogLocalService.lastShowCompleteProfileDialog != 0L) {
-            return Rlt.Failed(IError("has showed"))
-        }
-        if (taskInfo.taskDimensionProgress >= taskInfo.taskDimensionTarget) {
-            return Rlt.Failed(IError("task complete"))
-        }
-        return Rlt.Success(
-            BaseDialogData.CompleteProfileDialogData
-        )
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.CompleteProfileDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        val fragment = CompleteProfileDialog()
-        fragment.show(fragmentActivity.supportFragmentManager)
-
-        DialogLocalService.lastShowCompleteProfileDialog = System.currentTimeMillis()
-
-        return fragment.hashCode()
-    }
-}

+ 0 - 65
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/DailySignInTask.kt

@@ -1,65 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import android.os.Bundle
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.IError
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.router.Router
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.module.operation.Operation
-import com.adealink.weparty.module.operation.signinreward.data.DailySignInRewardsRes
-import com.adealink.weparty.module.task.DialogLocalService
-import com.adealink.weparty.ui.home.util.HomeLocalService
-
-/**
- * 每日签到
- * Created by XiaoDongLin.
- * Date: 2025/4/23
- */
-class DailySignInTask(
-    private val signInListRes: DailySignInRewardsRes
-) : BaseDialogTask<BaseDialogData.SignInDialogData>() {
-    override val priority: Int
-        get() = Priority.NORMAL.priority
-    override val tag: String
-        get() = "DailySignInTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.SignInDialogData> {
-        if (HomeLocalService.homeTabVisitCount <= 1) {
-            return Rlt.Failed(IError("产品要求,第一次打开app,不主动弹窗"))
-        }
-        return Rlt.Success(
-            BaseDialogData.SignInDialogData(
-                dialogData = signInListRes
-            )
-        )
-
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.SignInDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        DialogLocalService.nextSignInTime =
-            dialogData.dialogData.nextSignInTime
-        val fragment =
-            Router.getRouterInstance<BaseDialogFragment>(Operation.SignInRewardDialog.PATH)
-                ?.apply {
-                    arguments = Bundle().apply {
-                        putParcelable(
-                            Operation.SignInRewardDialog.EXTRA_DIALOG_DATA,
-                            dialogData
-                        )
-                    }
-                }
-        fragment?.show(fragmentActivity.supportFragmentManager)
-
-        return fragment.hashCode()
-
-    }
-
-
-}

+ 0 - 84
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/GenderChangeDialogTask.kt

@@ -1,84 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.Rlt
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.widget.CommonDialog
-import com.adealink.weparty.module.account.AccountModule
-import com.adealink.weparty.module.anchor.AnchorModule
-import com.adealink.weparty.module.anchor.data.AnchorMessageReplyCode
-
-/**
- * 性别变更弹窗
- */
-class GenderChangeDialogTask(
-    private val messageId: Long = 0,
-    private val messageType: Int = 0,
-    private val title: CharSequence? = null,
-    private val content: CharSequence? = null,
-    private val positiveText: CharSequence? = null,
-    private val negativeText: CharSequence? = null
-) : BaseDialogTask<BaseDialogData.GenderChangeDialogData>() {
-
-    private val DEFAULT_COUNTDOWN_MS = 10_000L // 10秒
-
-    override val priority: Int = Priority.HIGHEST.priority
-    override val tag: String = "GenderChangeDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.GenderChangeDialogData> {
-        return Rlt.Success(
-            BaseDialogData.GenderChangeDialogData(
-                messageId = messageId,
-                messageType = messageType,
-                title = title,
-                content = content,
-                positiveText = positiveText,
-                negativeText = negativeText,
-            )
-        )
-    }
-
-    // Router调出弹窗
-    override fun showDialog(
-        dialogData: BaseDialogData.GenderChangeDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-
-        val anchorViewModel = AnchorModule.getAnchorViewModel(fragmentActivity)
-        anchorViewModel?.replyAnchorMessage(
-            messageId,
-            messageType,
-            AnchorMessageReplyCode.REPLY_READ
-        )
-
-        val fragment = CommonDialog.Builder()
-            .title(dialogData.title ?: "")
-            .message(dialogData.content ?: "")
-            .positiveText(dialogData.positiveText ?: "")
-            .negativeText(dialogData.negativeText ?: "")
-            .positiveCountDownMS(DEFAULT_COUNTDOWN_MS)
-            .cancelable(false)
-            .canceledOnTouchOutside(false)
-            .onPositive {
-                // 点击确认按钮时执行登出逻辑
-                AccountModule.onChangeGender()
-            }
-            .onDismiss {
-                // 倒计时结束未点击也执行登出逻辑
-                AccountModule.onChangeGender()
-            }
-            .isClickableWhenCountDown(true)
-            .countDownTimerFormat { millisUntilFinished ->
-                "$positiveText (${millisUntilFinished / 1000}s)"
-            }
-            .countDownFinishCallback {
-                AccountModule.onChangeGender()
-            }
-            .build()
-
-        fragment.show(fragmentActivity.supportFragmentManager)
-        return fragment.hashCode()
-    }
-}

+ 0 - 52
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/InviteRewardDialogTask.kt

@@ -1,52 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import android.os.Bundle
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.router.Router
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.module.task.UserTask
-import com.adealink.weparty.module.task.invite.InviteNewRewardNotify
-
-/**
- * Created by XiaoDongLin.
- * Date: 2025/5/10
- */
-class InviteRewardDialogTask(
-    private val notify: InviteNewRewardNotify
-) :
-    BaseDialogTask<BaseDialogData.InviteNewRewardDialogData>() {
-    override val priority: Int
-        get() = Priority.NORMAL.priority
-    override val tag: String
-        get() = "InviteRewardDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.InviteNewRewardDialogData> {
-        return Rlt.Success(
-            BaseDialogData.InviteNewRewardDialogData(
-                notify
-            )
-        )
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.InviteNewRewardDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        val fragment =
-            Router.getRouterInstance<BaseDialogFragment>(UserTask.InviteNewRewardDialog.PATH)
-                ?.apply {
-                    arguments = Bundle().apply {
-                        putParcelable(
-                            UserTask.InviteNewRewardDialog.EXTRA_NOTIFY_DATA,
-                            dialogData.notify
-                        )
-                    }
-                }
-        fragment?.show(fragmentActivity.supportFragmentManager)
-        return fragment.hashCode()
-    }
-}

+ 0 - 86
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/MedalAchieveDialogTask.kt

@@ -1,86 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import android.os.Bundle
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.router.Router
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.module.medal.Medal
-
-/**
- * 勋章达成弹窗
- * Created by XiaoDongLin.
- * Date: 2025/5/13
- */
-class MedalAchieveDialogTask(
-    val medalId: Long,
-    val url: String,
-    val dynamicUrl: String?,
-    val level: Int,
-    val subLevel: Int,
-    val name: String,
-    val desc: String?
-
-) : BaseDialogTask<BaseDialogData.MedalAchieveDialogData>() {
-    override val priority: Int
-        get() = Priority.NORMAL.priority
-    override val tag: String
-        get() = "MedalAchieveDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.MedalAchieveDialogData> {
-        return Rlt.Success(
-            BaseDialogData.MedalAchieveDialogData(
-                medalId,
-                url,
-                dynamicUrl,
-                level,
-                subLevel,
-                name,
-                desc
-            )
-        )
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.MedalAchieveDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        val fragment =
-            Router.getRouterInstance<BaseDialogFragment>(Medal.MedalAchieve.PATH)?.apply {
-                arguments = Bundle().apply {
-                    putLong(
-                        Medal.Common.EXTRA_MEDAL_ID, dialogData.medalId
-                    )
-                    putString(
-                        Medal.Common.EXTRA_MEDAL_URL, dialogData.medalUrl
-                    )
-                    putString(
-                        Medal.Common.EXTRA_MEDAL_DYNAMIC_URL, dialogData.medalDynamicUrl
-                    )
-                    putInt(
-                        Medal.Common.EXTRA_MEDAL_LEVEL, dialogData.medalLevel
-                    )
-                    putInt(
-                        Medal.Common.EXTRA_MEDAL_SUB_LEVEL, dialogData.medalSubLevel
-                    )
-                    putString(
-                        Medal.Common.EXTRA_MEDAL_NAME, dialogData.medalName
-                    )
-                    putString(
-                        Medal.Common.EXTRA_MEDAL_DESC, dialogData.medalDesc
-                    )
-                }
-            }
-        fragment?.show(
-            fragmentActivity.supportFragmentManager,
-            "${Medal.MedalAchieve.TAG}_${medalId}"
-        )
-
-        return fragment.hashCode()
-    }
-
-
-}

+ 0 - 69
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/NewUserLotteryDialogTask.kt

@@ -1,69 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.IError
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.log.Log
-import com.adealink.frame.router.Router
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.module.operation.Operation
-import com.adealink.weparty.module.operation.OperationModule
-import com.adealink.weparty.module.profile.ProfileModule
-import com.adealink.weparty.module.profile.data.Gender
-
-/**
- * Created by XiaoDongLin.
- * Date: 2025/4/22
- */
-class NewUserLotteryDialogTask() :
-    BaseDialogTask<BaseDialogData.NewUserLotteryDialogData>() {
-    override val priority: Int
-        get() = Priority.NEW_USER_LOTTERY.priority
-    override val tag: String
-        get() = "NewUserLotteryDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.NewUserLotteryDialogData> {
-        Log.i(tag, "canShow")
-        if (Gender.getGender(ProfileModule.getMyUserInfo()?.gender) != Gender.MALE) {
-            Log.i(tag, "not male")
-            return Rlt.Failed(IError("not male"))
-        }
-        //前三天
-        val userInfoRlt = ProfileModule.getUserInfoByUid(uid = ProfileModule.getMyUid())
-        if (userInfoRlt is Rlt.Failed) {
-            Log.i(tag, "userInfoRlt:$userInfoRlt")
-            return Rlt.Failed(userInfoRlt.error)
-        }
-        val myUserInfo = (userInfoRlt as Rlt.Success).data
-        if (!myUserInfo.isMaleNewUser) {
-            Log.i(tag, "isMaleNewUser is false")
-            return Rlt.Failed(IError("isMaleNewUser is false"))
-        }
-        //判断是否在前三天
-        if (OperationModule.getNewUserLotteryIsEnd()) {
-            Log.i(tag, "getNewUserLotteryIsEnd")
-            return Rlt.Failed(IError("end"))
-        }
-
-        return Rlt.Success(BaseDialogData.NewUserLotteryDialogData)
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.NewUserLotteryDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        val fragment =
-            Router.getRouterInstance<BaseDialogFragment>(Operation.NewUserLotteryDialog.PATH)
-                ?.apply {
-
-                }
-        fragment?.show(fragmentActivity.supportFragmentManager)
-
-        return fragment.hashCode()
-    }
-
-
-}

+ 0 - 81
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/NewUserRewardDialogTask.kt

@@ -1,81 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import android.os.Bundle
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.coroutine.dispatcher.Dispatcher
-import com.adealink.frame.log.Log
-import com.adealink.frame.router.Router
-import com.adealink.weparty.App
-import com.adealink.weparty.AppModule
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.commonui.ext.onFailure
-import com.adealink.weparty.commonui.ext.onSuccess
-import com.adealink.weparty.module.operation.Operation
-import com.adealink.weparty.module.task.UserTaskHttpService
-import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.launch
-
-/**
- * Created by XiaoDongLin.
- * Date: 2025/4/22
- */
-class NewUserRewardDialogTask(
-    private val coins: Int,
-    private val chatTimes: Int,
-) : BaseDialogTask<BaseDialogData.NewUserRewardDialogData>() {
-
-    companion object {
-        const val TAG = "NewUserRewardDialogTask"
-    }
-
-    private val taskHttpService by lazy {
-        App.instance.networkService.getHttpService(UserTaskHttpService::class.java)
-    }
-
-    override val priority: Int
-        get() = Priority.NEW_USER_REWRARD.priority
-    override val tag: String
-        get() = "NewUserRewardDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.NewUserRewardDialogData> {
-        return Rlt.Success(
-            BaseDialogData.NewUserRewardDialogData(
-                coins = coins,
-                chatTimes = chatTimes
-            )
-        )
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.NewUserRewardDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        val fragment =
-            Router.getRouterInstance<BaseDialogFragment>(Operation.NewUserRewardDialog.PATH)
-                ?.apply {
-                    arguments = Bundle().apply {
-                        putParcelable(
-                            Operation.NewUserRewardDialog.EXTRA_DIALOG_DATA,
-                            dialogData
-                        )
-                    }
-                }
-        fragment?.show(fragmentActivity.supportFragmentManager)
-        CoroutineScope(Dispatcher.WENEXT_THREAD_POOL).launch {
-            taskHttpService.getPVReward().apply {
-                onSuccess { Log.i(TAG, "showNewUserRewardDialog") }
-                onFailure { Log.e(TAG, "getPVReward failed:$it") }
-            }
-        }
-        return fragment.hashCode()
-    }
-
-    override val onlyShowInActivities: List<String>
-        get() = listOf(
-            Router.getClazz(AppModule.Main.PATH)?.name ?: ""
-        )
-}

+ 0 - 110
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/UserGreetingDialogTask.kt

@@ -1,110 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import android.os.Bundle
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.IError
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.log.Log
-import com.adealink.frame.router.Router
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.commonui.ext.onSuccess
-import com.adealink.weparty.module.operation.Operation
-import com.adealink.weparty.module.profile.ProfileModule
-import com.adealink.weparty.module.profile.data.Gender
-import com.adealink.weparty.module.profile.data.UserConfigType
-import com.adealink.weparty.module.profile.view.SayHiState
-import com.adealink.weparty.module.userlist.data.UserInfoItemData
-import com.adealink.weparty.ui.home.util.HomeLocalService
-
-/**
- * 新客打招呼弹窗
- * Created by XiaoDongLin.
- * Date: 2025/4/22
- */
-class UserGreetingDialogTask(
-    private val uidList: List<Long>
-) :
-    BaseDialogTask<BaseDialogData.NewUserGreetingDialogData>() {
-    override val priority: Int
-        get() = Priority.NEW_USER_GREET.priority
-    override val tag: String
-        get() = "UserGreetingDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.NewUserGreetingDialogData> {
-        Log.i(tag, "canShow")
-        val hasShow = HomeLocalService.hasShowNewUserGreeting
-        if (hasShow) {
-            Log.i(tag, "hasShowNewUserGreeting is true")
-            return Rlt.Failed(error = IError("hasShowNewUserGreeting is true"))
-        }
-        val myUserInfoRlt = ProfileModule.getUserInfoByUid(uid = ProfileModule.getMyUid(), false)
-        if (myUserInfoRlt is Rlt.Failed) {
-            Log.i(tag, "myUserInfoRlt:$myUserInfoRlt")
-            return Rlt.Failed(myUserInfoRlt.error)
-        }
-        val myUserInfo = (myUserInfoRlt as Rlt.Success).data
-        if (Gender.getGender(myUserInfo.gender) != Gender.MALE) {
-            Log.i(tag, "gender is female")
-            return Rlt.Failed(error = IError("gender is female"))
-        }
-        if (!myUserInfo.isMaleNewUser) {
-            Log.i(tag, "isMaleNewUser is false")
-            return Rlt.Failed(error = IError("isMaleNewUser is false"))
-        }
-        if (uidList.isEmpty()) {
-            Log.i(tag, "uidList is empty")
-            return Rlt.Failed(error = IError("uidList is empty"))
-        }
-        //随机算法,查询5个
-        val randomList = uidList.shuffled().take(5).toSet()
-        //查询用户信息
-        val userInfoRlt = ProfileModule.getUsersInfoByUid(
-            uidSet = randomList,
-            cache = true,
-            attrSet = setOf(
-                UserConfigType.USER_ATTR_EXT_INFO,
-                UserConfigType.USER_ATTR_PROFILE,
-                UserConfigType.USER_REAL_AUTH
-            )
-        )
-        val resultList = mutableListOf<UserInfoItemData>()
-        userInfoRlt.onSuccess { userInfoMap ->
-            userInfoMap.values.forEach { userInfo ->
-                val userInfoItemData = UserInfoItemData(
-                    userInfo = userInfo,
-                    sayHiState = SayHiState.SayHi,
-                )
-                resultList.add(userInfoItemData)
-            }
-        }
-        return Rlt.Success(
-            BaseDialogData.NewUserGreetingDialogData(
-                resultList,
-            )
-        )
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.NewUserGreetingDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        HomeLocalService.hasShowNewUserGreeting = true
-        val fragment =
-            Router.getRouterInstance<BaseDialogFragment>(Operation.NewUserGreetingDialog.PATH)
-                ?.apply {
-                    arguments = Bundle().apply {
-                        putParcelable(
-                            Operation.NewUserGreetingDialog.EXTRA_DIALOG_DATA,
-                            dialogData
-                        )
-                    }
-                }
-        fragment?.show(fragmentActivity.supportFragmentManager)
-        return fragment.hashCode()
-    }
-
-
-}

+ 0 - 83
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/VipNewFeatureDialogTask.kt

@@ -1,83 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import android.os.Bundle
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.IError
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.log.Log
-import com.adealink.frame.router.Router
-import com.adealink.weparty.App
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.module.level.Level
-import com.adealink.weparty.module.level.datasource.remote.VipHttpService
-
-/**
- * VIP上新弹窗任务
- * By RYM
- */
-class VipNewFeatureDialogTask : BaseDialogTask<BaseDialogData.VipNewFeatureDialogData>() {
-
-    companion object {
-        const val TAG = "VipNewFeatureDialogTask"
-    }
-
-    private val vipHttpService by lazy {
-        App.instance.networkService.getHttpService(VipHttpService::class.java)
-    }
-
-    override val priority: Int
-        get() = Priority.NORMAL.priority
-
-    override val tag: String
-        get() = TAG
-
-    override suspend fun canShow(): Rlt<BaseDialogData.VipNewFeatureDialogData> {
-        return try {
-            when (val rlt = vipHttpService.getVipNewArrivalNotification()) {
-                is Rlt.Success -> {
-                    val vipFeatureData = rlt.data.data
-                    if (vipFeatureData != null) {
-                        Rlt.Success(
-                            BaseDialogData.VipNewFeatureDialogData(
-                                vipNewFeatureData = vipFeatureData
-                            )
-                        )
-                    } else {
-                        Rlt.Failed(error = IError("VIP feature data code is not 200 or data is null"))
-                    }
-                }
-
-                is Rlt.Failed -> {
-                    Log.d(
-                        TAG,
-                        "Failed to get vip new feature notification: ${rlt.error.msg}"
-                    )
-                    Rlt.Failed(rlt.error)
-                }
-            }
-        } catch (e: Exception) {
-            Log.e(TAG, "Error checking vip new feature notification", e)
-            Rlt.Failed(error = IError(e.message.toString()))
-        }
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.VipNewFeatureDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        val fragment = Router.getRouterInstance<BaseDialogFragment>(Level.VipNewFeature.PATH)
-            ?.apply {
-                arguments = Bundle().apply {
-                    putParcelable(
-                        Level.VipNewFeature.EXTRA_FEATURE_DATA,
-                        dialogData.vipNewFeatureData
-                    )
-                }
-            }
-        fragment?.show(fragmentActivity.supportFragmentManager)
-        return fragment.hashCode()
-    }
-}

+ 0 - 52
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/VipRechargeLevelUpgradeDialogTask.kt

@@ -1,52 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import android.os.Bundle
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.router.Router
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.module.level.Level
-import com.adealink.weparty.module.level.data.CommonLevelChangeNotify
-
-/**
- * Created by XiaoDongLin.
- * Date: 2025/5/8
- */
-class VipRechargeLevelUpgradeDialogTask(
-    private val notify: CommonLevelChangeNotify
-) :
-    BaseDialogTask<BaseDialogData.VipRechargeLevelUpgradeDialogData>() {
-    override val priority: Int
-        get() = Priority.NORMAL.priority
-    override val tag: String
-        get() = "VipRechargeLevelUpgradeDialog"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.VipRechargeLevelUpgradeDialogData> {
-        return Rlt.Success(
-            BaseDialogData.VipRechargeLevelUpgradeDialogData(
-                notify
-            )
-        )
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.VipRechargeLevelUpgradeDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        val fragment =
-            Router.getRouterInstance<BaseDialogFragment>(Level.VipRechargeLevelUpgrade.PATH)
-                ?.apply {
-                    arguments = Bundle().apply {
-                        putParcelable(
-                            Level.VipRechargeLevelUpgrade.EXTRA_UPGRADE_DATA,
-                            dialogData.notify
-                        )
-                    }
-                }
-        fragment?.show(fragmentActivity.supportFragmentManager)
-        return fragment.hashCode()
-    }
-}

+ 0 - 50
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/WealthLevelUpgradeDialogTask.kt

@@ -1,50 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import android.os.Bundle
-import androidx.fragment.app.Fragment
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.router.Router
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.module.level.Level
-import com.adealink.weparty.module.level.data.LevelUpgradeNotify
-
-/**
- * Created by XiaoDongLin.
- * Date: 2025/5/8
- */
-class WealthLevelUpgradeDialogTask(
-    val notify: LevelUpgradeNotify
-) :
-    BaseDialogTask<BaseDialogData.WealthLevelUpgradeDialogData>() {
-    override val priority: Int
-        get() = Priority.NORMAL.priority
-    override val tag: String
-        get() = "WealthLevelUpgradeDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.WealthLevelUpgradeDialogData> {
-        return Rlt.Success(
-            BaseDialogData.WealthLevelUpgradeDialogData(
-                notify
-            )
-        )
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.WealthLevelUpgradeDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        val fragment = Router.getRouterInstance<BaseDialogFragment>(Level.LevelUpgradeDialog.PATH)
-        fragment?.arguments = Bundle().apply {
-            putParcelable(
-                Level.Common.EXTRA_UPGRADE_NOTIFY,
-                dialogData.notify
-            )
-        }
-        fragment?.show(fragmentActivity.supportFragmentManager)
-        return fragment.hashCode()
-    }
-}

+ 0 - 94
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/WelcomeDialogTask.kt

@@ -1,94 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import android.os.Bundle
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.IError
-import com.adealink.frame.base.Rlt
-import com.adealink.frame.router.Router
-import com.adealink.frame.util.differentDays
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
-import com.adealink.weparty.module.task.DailyTaskInfo
-import com.adealink.weparty.module.task.DialogLocalService
-import com.adealink.weparty.module.task.UserTask
-import java.util.Date
-
-/**
- * 男性、女性新用户,注册≤3天内,每天首次进入 有主动弹窗/展示气泡,每天弹1次
- * 出现对象:当前新手任务未全部完成的所有用户
- * 出现时机:注册前3天,每天用户首次进入APP,进入10s时、当前前台在线,弹窗/展示气泡(无论在任意全局页面)
- *
- * 展示:
- * 男性展示金币奖励,女性展示钻石奖励
- * ——具体待领取的数值:目前剩余未完成的任务总可获得奖励数(包括注册3天内的额外奖励)
- * 新手任务前3天额外限时奖励的倒计时
- * 交互:
- * 点击前往:任务中心-普通任务页面
- * 点击关闭:弹窗/气泡收起至固定常驻入口
- * Created by XiaoDongLin.
- * Date: 2025/4/25
- */
-class WelcomeDialogTask(
-    private val newUserTime: Long,
-    private val dailyTaskInfo: DailyTaskInfo
-) : BaseDialogTask<BaseDialogData.WelcomeRewardDialogData>() {
-    override val priority: Int
-        get() = Priority.WELCOME_DIALOG_TASK.priority
-    override val tag: String
-        get() = "WelcomeDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.WelcomeRewardDialogData> {
-        if (newUserTime <= 0) {
-            return Rlt.Failed(IError(""))
-        }
-        //新手任务倒计时,未完成任务数量
-        val notFinishCount = dailyTaskInfo.dailyTaskItems?.count { !it.isCompleted() } ?: 0
-//        男性、女性新用户,注册≤3天内,每天首次进入 有主动弹窗/展示气泡,每天弹1次
-//                                出现对象:当前新手任务未全部完成的所有用户
-//                                出现时机:注册前3天,每天用户首次进入APP,进入10s时、当前前台在线,弹窗/展示气泡(无论在任意全局页面)
-        val lastShowWelcomeDialogTime =
-            DialogLocalService.lastShowWelcomeDialogTime
-        val diffDays = differentDays(
-            Date(lastShowWelcomeDialogTime),
-            Date(System.currentTimeMillis())
-        )
-        if (diffDays > 0) {
-            val rewardCount =
-                dailyTaskInfo.dailyTaskItems?.filter { !it.isCompleted() }
-                    ?.sumOf { it.coinRewardCount() } ?: 0
-            if (rewardCount > 0) {
-                return Rlt.Success(
-                    BaseDialogData.WelcomeRewardDialogData(
-                        rewardCount = rewardCount,
-                        endTime = newUserTime,
-                        dotCount = notFinishCount
-                    )
-                )
-            }
-        }
-        return Rlt.Failed(IError("not to show"))
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.WelcomeRewardDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        DialogLocalService.lastShowWelcomeDialogTime = System.currentTimeMillis()
-        val fragment =
-            Router.getRouterInstance<BaseDialogFragment>(UserTask.WelcomeRewardDialog.PATH)
-                ?.apply {
-                    arguments = Bundle().apply {
-                        putParcelable(
-                            UserTask.WelcomeRewardDialog.EXTRA_DIALOG_DATA,
-                            dialogData
-                        )
-                    }
-                }
-        fragment?.show(fragmentActivity.supportFragmentManager)
-        return fragment.hashCode()
-    }
-
-
-}

+ 0 - 49
app/src/main/java/com/adealink/weparty/commonui/dialogchain/dialogtask/WomemChatDiamondDialogTask.kt

@@ -1,49 +0,0 @@
-package com.adealink.weparty.commonui.dialogchain.dialogtask
-
-import androidx.fragment.app.FragmentActivity
-import com.adealink.frame.base.IError
-import com.adealink.frame.base.Rlt
-import com.adealink.weparty.commonui.dialogchain.BaseDialogData
-import com.adealink.weparty.commonui.dialogchain.BaseDialogTask
-import com.adealink.weparty.commonui.dialogchain.Priority
-import com.adealink.weparty.module.profile.ProfileModule
-import com.adealink.weparty.module.profile.data.Gender
-import com.adealink.weparty.module.task.DialogLocalService
-import com.adealink.weparty.module.task.UserTaskManager
-import com.adealink.weparty.module.task.WomemChatDiamondDialog
-
-/**
- * Created by XiaoDongLin.
- * Date: 2025/5/6
- */
-class WomemChatDiamondDialogTask() :
-    BaseDialogTask<BaseDialogData.WomenChatDiamondDialogData>() {
-    override val priority: Int
-        get() = Priority.NORMAL.priority
-    override val tag: String
-        get() = "WomemChatDiamondDialogTask"
-
-    override suspend fun canShow(): Rlt<BaseDialogData.WomenChatDiamondDialogData> {
-        if (Gender.getGender(ProfileModule.getMyUserInfo()?.gender) == Gender.FEMALE
-            && !UserTaskManager.womenHasMakeMoneyByChat
-            && DialogLocalService.needToShowDiamondDialog
-        ) {
-            return Rlt.Success(
-                BaseDialogData.WomenChatDiamondDialogData
-            )
-        }
-        return Rlt.Failed(IError("not show"))
-    }
-
-    override fun showDialog(
-        dialogData: BaseDialogData.WomenChatDiamondDialogData,
-        fragmentActivity: FragmentActivity
-    ): Int {
-        DialogLocalService.needToShowDiamondDialog = false
-
-        val fragment = WomemChatDiamondDialog()
-        fragment.show(fragmentActivity.supportFragmentManager)
-        return fragment.hashCode()
-    }
-
-}

+ 0 - 451
app/src/main/java/com/adealink/weparty/commonui/dialogfragment/WheelDatePickerDialogFragment.kt

@@ -1,451 +0,0 @@
-package com.adealink.weparty.commonui.dialogfragment
-
-import android.os.Bundle
-import com.adealink.frame.aab.util.getCompatString
-import com.adealink.weparty.commonui.MIN_YEAR
-import com.adealink.weparty.R
-import com.adealink.weparty.databinding.FragmentWheelDatePickerBinding
-import com.adealink.frame.util.onClick
-import com.adealink.weparty.commonui.dialogfragment.data.DatePickerType
-import com.adealink.weparty.commonui.ext.show
-import com.adealink.weparty.commonui.widget.BottomDialogFragment
-import com.adealink.frame.mvvm.view.viewBinding
-import com.adealink.frame.util.getBirthStr
-import com.adealink.frame.util.timeToYMDHM
-import com.adealink.weparty.commonui.dialogfragment.data.Month
-import java.util.*
-
-/**
- * 日期选择控件;
- * Created by xuefu_du on 2021/6/23.
- */
-class WheelDatePickerDialogFragment : BottomDialogFragment(R.layout.fragment_wheel_date_picker) {
-
-    companion object {
-        val SIMPLE_NAME: String = WheelDatePickerDialogFragment::class.java.simpleName
-
-        private const val EXTRA_INIT_DATE = "extra_init_date"
-        private const val EXTRA_TIPS = "extra_tips"
-        private const val EXTRA_TARGET_MONTH_SCOPE = "extra_target_month_scope"
-        private const val EXTRA_TARGET_DAY_SCOPE = "extra_target_day_scope"
-        private const val EXTRA_CURR_MINUTE_SCOPE = "extra_curr_minute_scope"
-        private const val EXTRA_TYPE = "extra_type"
-        fun newInstance(
-            timestamp: Long = System.currentTimeMillis(),
-            tips: String? = null,
-            targetMonthScope: Int? = -2,
-            targetDayScope: Int? = 0,
-            currMinuteScope: Int? = 0,
-            type: Int? = DatePickerType.YMD.ordinal
-        ): WheelDatePickerDialogFragment {
-            val fragment = WheelDatePickerDialogFragment()
-            val bundle = Bundle()
-            if (targetMonthScope != null) {
-                bundle.putInt(EXTRA_TARGET_MONTH_SCOPE, targetMonthScope)
-            }
-            if (targetDayScope != null) {
-                bundle.putInt(EXTRA_TARGET_DAY_SCOPE, targetDayScope)
-            }
-            if (currMinuteScope != null) {
-                bundle.putInt(EXTRA_CURR_MINUTE_SCOPE, currMinuteScope)
-            }
-            bundle.putLong(EXTRA_INIT_DATE, timestamp)
-            bundle.putString(EXTRA_TIPS, tips)
-            if (type != null) {
-                bundle.putInt(EXTRA_TYPE, type)
-            }
-            fragment.arguments = bundle
-            return fragment
-        }
-    }
-
-    private val binding by viewBinding(FragmentWheelDatePickerBinding::bind)
-
-    private val yearList = mutableListOf<String>()
-    private val monthList =
-        mutableListOf<Pair<Int, String>>()  //first用于索引及获取相应时间戳,second用于日期控件滚轮文案显示
-    private val dayList = mutableListOf<String>()
-    private var hourList = arrayListOf<String>()
-    private var minuteList = arrayListOf<String>()
-
-    private var initTimestamp = System.currentTimeMillis()
-    private var tips: String? = null
-    private var targetMonthScope: Int = -2   //-N选取前N个月  N选取后N个月
-    private var targetDayScope: Int = 0   //-N选取前N天  N选取后N天
-    private var currMinuteScope: Int = 0   //选取开始的小时数,1表示选取当前时间一小时
-    override val dimAmount: Float = 0.2f
-
-    private var selectYear = 0
-    private var selectMonth = 0
-    private var selectDay = 0
-    private var selectHour = 0
-    private var selectMinute = 0
-
-    private var currYear = 0
-    private var targetYear = MIN_YEAR
-    private var currMonth = 1
-    private var targetMonth = 1
-    private var currDay = 1
-    private var targetDay = 1
-    private var targetHour = 1
-    private var targetMinute = 1
-    private var currHour = 1
-    private var currMinute = 1
-    private var type: Int = DatePickerType.YMD.ordinal
-    var selectBirthdayCallback: ISelectDateCallback? = null
-
-
-    private fun parseIntent() {
-        arguments?.getLong(EXTRA_INIT_DATE)?.let {
-            initTimestamp = it
-        }
-        arguments?.getInt(EXTRA_TARGET_MONTH_SCOPE)?.let {
-            targetMonthScope = it
-        }
-        arguments?.getInt(EXTRA_TARGET_DAY_SCOPE)?.let {
-            targetDayScope = it
-        }
-        arguments?.getInt(EXTRA_CURR_MINUTE_SCOPE)?.let {
-            currMinuteScope = it
-        }
-        arguments?.getInt(EXTRA_TYPE)?.let {
-            type = it
-        }
-        if (initTimestamp <= 0) {
-            initTimestamp = System.currentTimeMillis()
-        }
-        arguments?.getString(EXTRA_TIPS)?.let {
-            tips = it
-        }
-    }
-
-    /**
-     * - get(Calendar.MONTH) 比真实的月份少1;
-     */
-    private fun initDataPicker() {
-        val cal = Calendar.getInstance()
-        // 当前的时间
-        if (currMinuteScope != 0) {
-            cal.add(Calendar.MINUTE, currMinuteScope)
-        }
-        currYear = cal.get(Calendar.YEAR)
-        currMonth = cal.get(Calendar.MONTH) + 1
-        currDay = cal.get(Calendar.DAY_OF_MONTH)
-        currHour = cal.get(Calendar.HOUR_OF_DAY)
-        currMinute = cal.get(Calendar.MINUTE)
-        val currTimestamp = cal.timeInMillis
-        // 选择月份或日
-        if (targetDayScope != 0) {
-            cal.add(Calendar.DATE, targetDayScope)
-        } else {
-            cal.add(Calendar.MONTH, targetMonthScope)
-        }
-        targetYear = cal.get(Calendar.YEAR)
-        targetMonth = cal.get(Calendar.MONTH) + 1
-        targetDay = cal.get(Calendar.DAY_OF_MONTH)
-        targetHour = cal.get(Calendar.HOUR_OF_DAY)
-        targetMinute = cal.get(Calendar.MINUTE)
-        val targetTimestamp = cal.timeInMillis
-        //防越界
-        if (targetTimestamp > currTimestamp) {
-            if (currTimestamp > initTimestamp || initTimestamp > targetTimestamp) {
-                initTimestamp = currTimestamp
-            }
-        } else {
-            if (currTimestamp < initTimestamp || initTimestamp < targetTimestamp) {
-                initTimestamp = currTimestamp
-            }
-        }
-        // 初始化选中的时间
-        val date = Date(initTimestamp)
-        cal.time = date
-        selectYear = cal.get(Calendar.YEAR)
-        selectMonth = cal.get(Calendar.MONTH) + 1
-        selectDay = cal.get(Calendar.DAY_OF_MONTH)
-        selectHour = cal.get(Calendar.HOUR_OF_DAY)
-        selectMinute = cal.get(Calendar.MINUTE)
-        // 填充列表
-        if (targetYear < currYear) {
-            for (year in targetYear..currYear) {
-                yearList.add("$year")
-            }
-        } else {
-            for (year in currYear..targetYear) {
-                yearList.add("$year")
-            }
-        }
-    }
-
-    private fun inflateMonthList(month: Int) {
-        when (month) {
-            Month.JANUARY.value -> monthList.add(Pair(1, getCompatString(R.string.commonui_january)))
-            Month.FEBRUARY.value -> monthList.add(Pair(2, getCompatString(R.string.commonui_february)))
-            Month.MARCH.value -> monthList.add(Pair(3, getCompatString(R.string.commonui_march)))
-            Month.APRIL.value -> monthList.add(Pair(4, getCompatString(R.string.commonui_april)))
-            Month.MAY.value -> monthList.add(Pair(5, getCompatString(R.string.commonui_may)))
-            Month.JUNE.value -> monthList.add(Pair(6, getCompatString(R.string.commonui_june)))
-            Month.JULY.value -> monthList.add(Pair(7, getCompatString(R.string.commonui_july)))
-            Month.AUGUST.value -> monthList.add(Pair(8, getCompatString(R.string.commonui_august)))
-            Month.SEPTEMBER.value -> monthList.add(Pair(9, getCompatString(R.string.commonui_september)))
-            Month.OCTOBER.value -> monthList.add(Pair(10, getCompatString(R.string.commonui_october)))
-            Month.NOVEMBER.value -> monthList.add(Pair(11, getCompatString(R.string.commonui_november)))
-            else -> monthList.add(Pair(12, getCompatString(R.string.commonui_december)))
-        }
-    }
-
-    override fun initViews() {
-        parseIntent()
-        initDataPicker()
-        binding.tvTips.text = tips
-        binding.wheelYear.setEntries(yearList)
-        updateMonthList()
-
-        // 设置选中x
-        binding.wheelYear.currentIndex = selectYear - targetYear
-        binding.wheelMonth.currentIndex = monthList.indexOfFirst { it.first == selectMonth }
-        binding.wheelDay.currentIndex = dayList.indexOf(selectDay.toString())
-        binding.wheelHour.currentIndex = hourList.indexOf(selectHour.toString())
-        binding.wheelMinute.currentIndex = minuteList.indexOf(
-            if (selectMinute < 10) {
-                "0$selectMinute"
-            } else {
-                selectMinute.toString()
-            }
-        )
-        when (type) {
-            DatePickerType.YMDHM.ordinal -> {  //精确到分钟
-                binding.wheelDay.setItemWidth(100)
-                binding.wheelMonth.setItemWidth(200)
-                binding.wheelYear.setItemWidth(200)
-                binding.wheelHour.show()
-                binding.wheelMinute.show()
-                binding.wheelHour.setOnWheelChangedListener { _, _, newIndex ->
-                    selectHour = hourList.getOrNull(newIndex)?.toInt() ?: 0
-                    updateMinuteList()
-                    selectMinute = minuteList.getOrNull(0)?.toInt() ?: 0
-                }
-                binding.wheelMinute.setOnWheelChangedListener { _, _, newIndex ->
-                    selectMinute = minuteList.getOrNull(newIndex)?.toInt() ?: 0
-                }
-            }
-
-            else -> {}
-        }
-        binding.wheelYear.setOnWheelChangedListener { _, _, newIndex ->
-            selectYear = yearList.getOrNull(newIndex)?.toInt() ?: 0
-            updateMonthList()
-            selectMonth = monthList.getOrNull(0)?.first ?: 0
-            updateDayList()
-            selectDay = dayList.getOrNull(0)?.toInt() ?: 0
-            selectHour = hourList.getOrNull(0)?.toInt() ?: 0
-            selectMinute = minuteList.getOrNull(0)?.toInt() ?: 0
-        }
-        binding.wheelMonth.setOnWheelChangedListener { _, _, newIndex ->
-            selectMonth = monthList.getOrNull(newIndex)?.first ?: 0
-            updateDayList()
-            selectDay = dayList.getOrNull(0)?.toInt() ?: 0
-            selectHour = hourList.getOrNull(0)?.toInt() ?: 0
-            selectMinute = minuteList.getOrNull(0)?.toInt() ?: 0
-        }
-        binding.wheelDay.setOnWheelChangedListener { _, _, newIndex ->
-            selectDay = dayList.getOrNull(newIndex)?.toInt() ?: 0
-            updateHourList()
-            selectHour = hourList.getOrNull(0)?.toInt() ?: 0
-            selectMinute = minuteList.getOrNull(0)?.toInt() ?: 0
-        }
-        binding.btnConfirm.onClick {
-            val calendar = Calendar.getInstance()
-            calendar.clear()
-            if (type == DatePickerType.YMDHM.ordinal) {
-                calendar.set(selectYear, selectMonth - 1, selectDay, selectHour, selectMinute)
-            } else {
-                calendar.set(selectYear, selectMonth - 1, selectDay)
-            }
-            val timestamp = calendar.timeInMillis
-            selectBirthdayCallback?.onSelectComplete(
-                timestamp,
-                if (type == DatePickerType.YMDHM.ordinal) {
-                    timeToYMDHM(timestamp)
-                } else {
-                    getBirthStr(timestamp)
-                }
-            )
-            dismiss()
-        }
-    }
-
-
-    /**
-     * 更新可选择的月份;
-     * 1. 只有1年:直接从小到大填充月份;注意目标月份是否大于当前月份
-     * 2. 跨年:[targetMonth, 12] 、[1, currMonth]
-     */
-    private fun updateMonthList() {
-        monthList.clear()
-        val startMonth = if (yearList.size < 2) {
-            if (targetMonth > currMonth) currMonth else targetMonth
-        } else {
-            if (currYear < targetYear) {
-                if (selectYear.toString() == yearList.getOrNull(0)) currMonth else 1
-            } else {
-                if (selectYear.toString() == yearList.getOrNull(0)) targetMonth else 1
-            }
-
-        }
-
-        val endMonth = if (yearList.size < 2) {
-            if (targetMonth > currMonth) targetMonth else currMonth
-        } else {
-            if (currYear < targetYear) {
-                if (selectYear.toString() == yearList.getOrNull(0)) 12 else targetMonth
-            } else {
-                if (selectYear.toString() == yearList.getOrNull(0)) 12 else currMonth
-            }
-
-        }
-
-        for (month in startMonth until endMonth + 1) {
-            inflateMonthList(month)
-        }
-        binding.wheelMonth.setEntries(monthList.map { it.second })
-        updateDayList()
-    }
-
-    /**
-     * 更新可选择的日子;
-     */
-    private fun updateDayList() {
-        val calendar = Calendar.getInstance()
-        calendar[Calendar.YEAR] = selectYear
-        calendar[Calendar.MONTH] = selectMonth - 1
-        val days = calendar.getActualMaximum(Calendar.DAY_OF_MONTH)
-        dayList.clear()
-        try {
-            when (selectMonth) {
-                targetMonth -> {
-                    if (targetMonth <= currMonth) {
-                        if (yearList.size < 2) {
-                            if (targetDayScope != 0) {
-                                for (i in currDay..targetDay) {
-                                    dayList.add("$i")
-                                }
-                            } else {
-                                for (i in targetDay..days) {
-                                    dayList.add("$i")
-                                }
-                            }
-                        } else {
-                            if (targetDayScope != 0) {
-                                for (i in 1..targetDay) {
-                                    dayList.add("$i")
-                                }
-                            } else {
-                                for (i in currDay..days) {
-                                    dayList.add("$i")
-                                }
-                            }
-                        }
-                    } else {
-                        if (targetYear > currYear) {
-                            for (i in 1..targetDay) {
-                                dayList.add("$i")
-                            }
-                        } else {
-                            for (i in currDay..days) {
-                                dayList.add("$i")
-                            }
-                        }
-
-                    }
-                }
-
-                currMonth -> {
-                    if (targetMonth <= currMonth) {
-                        if (yearList.size < 2) {
-                            for (i in 1..currDay) {
-                                dayList.add("$i")
-                            }
-                        } else {
-                            for (i in currDay..days) {
-                                dayList.add("$i")
-                            }
-                        }
-                    } else {
-                        if (targetYear > currYear) {
-                            for (i in currDay..days) {
-                                dayList.add("$i")
-                            }
-                        } else {
-                            for (i in 1..currDay) {
-                                dayList.add("$i")
-                            }
-                        }
-                    }
-
-                }
-
-                else -> {
-                    for (i in 1..days) {
-                        dayList.add("$i")
-                    }
-                }
-            }
-        } catch (e: Exception) {
-            dayList.clear()
-            for (i in 1..days) {
-                dayList.add("$i")
-            }
-        }
-
-        binding.wheelDay.setEntries(dayList)
-        updateHourList()
-    }
-
-    private fun updateHourList() {
-        hourList.clear()
-
-        val startHour =
-            if (selectDay == currDay && selectMonth == currMonth) currHour
-            else if (selectDay == targetDay && selectMonth == targetMonth) targetHour
-            else 0
-        if (selectDay == targetDay && selectMonth == targetMonth) {
-            for (i in 0..startHour) {
-                hourList.add("$i")
-            }
-        } else {
-            for (i in startHour..23) {
-                hourList.add("$i")
-            }
-        }
-
-        binding.wheelHour.setEntries(hourList)
-        updateMinuteList()
-    }
-
-    private fun updateMinuteList() {
-        minuteList.clear()
-        val startMinute =
-            if (selectHour == currHour && selectDay == currDay && selectMonth == currMonth) currMinute
-            else if (selectHour == targetHour && selectDay == targetDay && selectMonth == targetMonth) targetMinute
-            else 0
-        if (selectHour == targetHour && selectDay == targetDay && selectMonth == targetMonth) {
-            for (i in 0..startMinute) {
-                minuteList.add(if (i < 10) "0$i" else "$i")
-            }
-        } else {
-            for (i in startMinute..59) {
-                minuteList.add(if (i < 10) "0$i" else "$i")
-            }
-        }
-
-        binding.wheelMinute.setEntries(minuteList)
-    }
-
-
-    interface ISelectDateCallback {
-        /**
-         * @param timeStr "yyyy-MM-dd" 格式 或者“yyyy-MM-DD-HH-MM-SS”
-         */
-        fun onSelectComplete(timestamp: Long, timeStr: String)
-    }
-}

+ 0 - 80
app/src/main/java/com/adealink/weparty/commonui/dialogfragment/WheelSimpleListStringDialogFragment.kt

@@ -1,80 +0,0 @@
-package com.adealink.weparty.commonui.dialogfragment
-
-import android.os.Bundle
-import com.adealink.frame.base.fastLazy
-import com.adealink.frame.mvvm.view.viewBinding
-import com.adealink.frame.util.onClick
-import com.adealink.weparty.R
-import com.adealink.weparty.commonui.widget.BottomDialogFragment
-import com.adealink.weparty.databinding.FragmentWheelDateSimpleStringListBinding
-
-/**
- * 简单的String列表选择
- * Created by XiaoDongLin.
- * Date: 2025/3/11
- */
-class WheelSimpleListStringDialogFragment :
-    BottomDialogFragment(R.layout.fragment_wheel_date_simple_string_list) {
-
-    companion object {
-        private val EXTRA_STRING_LIST = "extra_string_list"
-        private val EXTAR_CURRENT_INDEX = "extra_current_index"
-
-        fun newInstance(
-            list: List<String>,
-            defaultIndex: Int
-        ): WheelSimpleListStringDialogFragment {
-            return WheelSimpleListStringDialogFragment().apply {
-                arguments = Bundle().apply {
-                    putStringArrayList(
-                        EXTRA_STRING_LIST,
-                        ArrayList(list)
-                    )
-                    putInt(EXTAR_CURRENT_INDEX, defaultIndex)
-                }
-            }
-        }
-    }
-
-    private val binding by viewBinding(FragmentWheelDateSimpleStringListBinding::bind)
-    private var selectItem = ""
-    private var listener: ISelectResultListener? = null
-
-    private val stringList by fastLazy {
-        arguments?.getStringArrayList(EXTRA_STRING_LIST) ?: arrayListOf()
-    }
-    private var currentIndex = -1
-
-
-    override fun initViews() {
-        super.initViews()
-        currentIndex = arguments?.getInt(EXTAR_CURRENT_INDEX) ?: -1
-
-        binding.btnCancel.onClick {
-            dismiss()
-        }
-        binding.btnConfirm.onClick {
-            listener?.onSelectComplete(currentIndex, selectItem)
-            dismiss()
-        }
-        binding.wheelView.setEntries(stringList)
-        if (currentIndex > 0) {
-            binding.wheelView.setCurrentIndex(currentIndex, false)
-            selectItem = stringList.getOrNull(currentIndex) ?: ""
-        }
-
-        binding.wheelView.setOnWheelChangedListener { view, oldIndex, newIndex ->
-            currentIndex = newIndex
-            selectItem = stringList.getOrNull(newIndex) ?: ""
-        }
-    }
-
-    fun setOnSelectResultListener(listener: ISelectResultListener) {
-        this.listener = listener
-    }
-
-    interface ISelectResultListener {
-        fun onSelectComplete(index: Int, data: String)
-    }
-
-}

+ 0 - 0
app/src/main/java/com/adealink/weparty/commonui/fragment/FragmentExt.kt → app/src/main/java/com/adealink/weparty/commonui/ext/FragmentExt.kt


+ 0 - 1
app/src/main/java/com/adealink/weparty/commonui/fresco/NetworkImageUtil.kt

@@ -1 +0,0 @@
-package com.adealink.weparty.commonui.fresco

+ 0 - 277
app/src/main/java/com/adealink/weparty/commonui/game/GameButton.kt

@@ -1,277 +0,0 @@
-package com.adealink.weparty.commonui.game
-
-import android.content.Context
-import android.graphics.Typeface
-import android.util.AttributeSet
-import android.util.TypedValue
-import android.view.Gravity
-import android.view.LayoutInflater
-import androidx.constraintlayout.widget.ConstraintLayout
-import androidx.core.view.updateLayoutParams
-import com.adealink.frame.aab.util.getCompatColor
-import com.adealink.frame.aab.util.getCompatColorStateList
-import com.adealink.frame.aab.util.getCompatDrawable
-import com.adealink.weparty.R
-import com.adealink.weparty.commonui.drawabletoolbox.StateListDrawableBuilder
-import com.adealink.weparty.commonui.ext.dp
-import com.adealink.weparty.commonui.ext.dpf
-import com.adealink.weparty.commonui.ext.gone
-import com.adealink.weparty.commonui.ext.show
-import com.adealink.weparty.commonui.ext.sp
-import com.adealink.weparty.databinding.LayoutGameButtonBinding
-
-class GameButton @JvmOverloads constructor(
-    context: Context, attrs: AttributeSet? = null
-) : ConstraintLayout(context, attrs) {
-
-    private val binding = LayoutGameButtonBinding.inflate(LayoutInflater.from(context), this)
-
-    var buttonType: GameButtonType = GameButtonType.Normal
-        set(value) {
-            field = value
-            updateUI()
-        }
-
-    var leftDrawableRes: Int? = 0
-        set(value) {
-            field = value
-            setLeftDrawable(value)
-        }
-
-    var text: CharSequence? = null
-        set(value) {
-            field = value
-            setButtonText(value)
-        }
-
-    var textSize: Float = 0f
-        set(value) {
-            field = value
-            setButtonTextSize(value)
-        }
-
-    var bgSize: Int = GameButtonSize.SizeSmall.ordinal
-        set(value) {
-            field = value
-            updateUI()
-        }
-
-    private var leftDrawableMargin: Int = 0
-
-    var rightDrawableRes: Int? = 0
-        set(value) {
-            field = value
-            setRightDrawable(value)
-        }
-
-    private var rightDrawableMargin: Int = 0
-
-    private var strokeWidth: Float = 0f
-
-    var textStyle: GameButtonTextStyle = GameButtonTextStyle.Normal
-        set(value) {
-            field = value
-            setButtonTextStyle(value)
-        }
-
-    init {
-        initAttrs(context, attrs)
-    }
-
-    private fun initAttrs(context: Context, attrs: AttributeSet?) {
-        if (isInEditMode) {
-            return
-        }
-        context.theme.obtainStyledAttributes(
-            attrs,
-            R.styleable.GameButton,
-            0, 0
-        ).apply {
-            val type = getInt(R.styleable.GameButton_button_type, GameButtonType.Normal.type)
-            buttonType = GameButtonType.map(type) ?: GameButtonType.Normal
-
-            strokeWidth = getDimension(R.styleable.GameButton_stroke_width, 0.dpf())
-
-            leftDrawableRes = getResourceId(R.styleable.GameButton_left_drawable, 0)
-            leftDrawableMargin = getDimensionPixelSize(R.styleable.GameButton_left_drawable_margin, 2.dp())
-
-            rightDrawableRes = getResourceId(R.styleable.GameButton_right_drawable, 0)
-            rightDrawableMargin = getDimensionPixelSize(R.styleable.GameButton_right_drawable_margin, 2.dp())
-
-            text = getString(R.styleable.GameButton_text)
-            textSize = getDimensionPixelSize(R.styleable.GameButton_text_size, 20.sp()).toFloat()
-
-            bgSize = getInt(R.styleable.GameButton_bg_size, GameButtonSize.SizeSmall.ordinal)
-
-            val style = getInt(R.styleable.GameButton_text_style, GameButtonTextStyle.Normal.style)
-            textStyle = GameButtonTextStyle.map(style) ?: GameButtonTextStyle.Normal
-        }
-        updateUI()
-        setPadding(8.dp(), 0, 8.dp(), 0)
-    }
-
-    private fun updateUI() {
-        background =
-            StateListDrawableBuilder()
-                .normal(getCompatDrawable(getButtonBg(ButtonStatus.Normal)))
-                .pressed(getCompatDrawable(getButtonBg(ButtonStatus.Pressed)))
-                .disabled(getCompatDrawable(getButtonBg(ButtonStatus.Disable)))
-                .build()
-        when (buttonType) {
-            GameButtonType.Confirm -> {
-                binding.tvName.setTextColor(getCompatColorStateList(R.color.game_weak_button_text_sel))
-            }
-
-            GameButtonType.Normal -> {
-                binding.tvName.setTextColor(getCompatColorStateList(R.color.game_strong_button_text_sel))
-            }
-        }
-        if (strokeWidth > 0) {
-            binding.tvName.setStroke(getButtonStrokeColor(), strokeWidth)
-        }
-        binding.tvName.gravity = Gravity.CENTER
-        binding.tvName.updateLayoutParams<LayoutParams> {
-            marginStart = leftDrawableMargin
-            marginEnd = rightDrawableMargin
-        }
-    }
-
-    private fun setButtonText(text: CharSequence?) {
-        binding.tvName.text = text
-    }
-
-    private fun setButtonTextSize(pxSize: Float) {
-        binding.tvName.setTextSize(TypedValue.COMPLEX_UNIT_PX, pxSize)
-    }
-
-    private fun setButtonTextStyle(textStyle: GameButtonTextStyle) {
-        binding.tvName.setTypeface(null, when(textStyle) {
-            GameButtonTextStyle.Normal -> Typeface.NORMAL
-            GameButtonTextStyle.Bold -> Typeface.BOLD
-            GameButtonTextStyle.Italic -> Typeface.ITALIC
-        })
-    }
-
-    private fun setLeftDrawable(drawableRes: Int?) {
-        if (drawableRes == null || drawableRes == 0) {
-            binding.ivLeft.gone()
-        } else {
-            binding.ivLeft.show()
-            binding.ivLeft.setImageResource(drawableRes)
-        }
-    }
-
-    private fun setRightDrawable(drawableRes: Int?) {
-        if (drawableRes == null || drawableRes == 0) {
-            binding.ivRight.gone()
-        } else {
-            binding.ivRight.show()
-            binding.ivRight.setImageResource(drawableRes)
-        }
-    }
-
-    private fun getButtonBg(status: ButtonStatus): Int {
-        return when (buttonType) {
-            GameButtonType.Confirm -> getConfirmButtonBgBySize(status)
-            GameButtonType.Normal -> getNormalButtonBgBySize(status)
-        }
-    }
-
-    private fun getConfirmButtonBgBySize(status: ButtonStatus): Int {
-        return when (bgSize) {
-            GameButtonSize.SizeLarge.ordinal -> {
-                when (status) {
-                    ButtonStatus.Normal -> R.drawable.game_confirm_btn_large
-                    ButtonStatus.Pressed -> R.drawable.game_confirm_btn_large_pressed
-                    ButtonStatus.Disable -> R.drawable.game_confirm_btn_large_disable
-                }
-            }
-
-            GameButtonSize.SizeSmall.ordinal -> {
-                when (status) {
-                    ButtonStatus.Normal -> R.drawable.game_confirm_btn_small
-                    ButtonStatus.Pressed -> R.drawable.game_confirm_btn_small_pressed
-                    ButtonStatus.Disable -> R.drawable.game_confirm_btn_small_disable
-                }
-            }
-
-            else -> {
-                when (status) {
-                    ButtonStatus.Normal -> R.drawable.game_confirm_btn_medium
-                    ButtonStatus.Pressed -> R.drawable.game_confirm_btn_medium_pressed
-                    ButtonStatus.Disable -> R.drawable.game_confirm_btn_medium_disable
-                }
-            }
-        }
-    }
-
-    private fun getNormalButtonBgBySize(status: ButtonStatus): Int {
-        return when (bgSize) {
-            GameButtonSize.SizeLarge.ordinal -> {
-                when (status) {
-                    ButtonStatus.Normal -> R.drawable.game_normal_btn_large
-                    ButtonStatus.Pressed -> R.drawable.game_normal_btn_large_pressed
-                    ButtonStatus.Disable -> R.drawable.game_confirm_btn_large_disable
-                }
-            }
-
-            GameButtonSize.SizeSmall.ordinal -> {
-                when (status) {
-                    ButtonStatus.Normal -> R.drawable.game_normal_btn_small
-                    ButtonStatus.Pressed -> R.drawable.game_normal_btn_small_pressed
-                    ButtonStatus.Disable -> R.drawable.game_confirm_btn_small_disable
-                }
-            }
-
-            else -> {
-                when (status) {
-                    ButtonStatus.Normal -> R.drawable.game_normal_btn_medium
-                    ButtonStatus.Pressed -> R.drawable.game_normal_btn_medium_pressed
-                    ButtonStatus.Disable -> R.drawable.game_confirm_btn_medium_disable
-                }
-            }
-        }
-    }
-
-    private fun getButtonStrokeColor(): Int {
-        return when (buttonType) {
-            GameButtonType.Confirm -> getCompatColor(R.color.game_confirm_button_stroke_color_sel)
-            GameButtonType.Normal -> getCompatColor(R.color.game_normal_button_stroke_color_sel)
-        }
-    }
-
-    enum class ButtonStatus {
-        Normal,
-        Pressed,
-        Disable
-    }
-
-    enum class GameButtonType(val type: Int) {
-        Confirm(0), //确认按钮
-        Normal(1); //一般按钮
-
-        companion object {
-            fun map(type: Int): GameButtonType? {
-                return values().firstOrNull { it.type == type }
-            }
-        }
-    }
-
-    enum class GameButtonSize() {
-        SizeSmall,
-        SizeMedium,
-        SizeLarge;
-    }
-
-    enum class GameButtonTextStyle(val style: Int) {
-        Normal(0),
-        Bold(1),
-        Italic(2);
-
-        companion object {
-            fun map(style: Int): GameButtonTextStyle? {
-                return entries.firstOrNull { it.style == style }
-            }
-        }
-    }
-}

+ 0 - 441
app/src/main/java/com/adealink/weparty/commonui/game/GameTextView.kt

@@ -1,441 +0,0 @@
-package com.adealink.weparty.commonui.game
-
-import android.content.Context
-import android.graphics.Canvas
-import android.graphics.Color
-import android.graphics.LinearGradient
-import android.graphics.Paint
-import android.graphics.PorterDuff
-import android.graphics.PorterDuffXfermode
-import android.graphics.Shader
-import android.util.AttributeSet
-import androidx.appcompat.widget.AppCompatTextView
-import androidx.core.content.withStyledAttributes
-import com.adealink.frame.aab.util.getCompatColor
-import com.adealink.weparty.R
-
-/**
- * 可设置文字描边的TextView
- * 默认文字描边颜色 #FF0A8399
- */
-open class GameTextView @JvmOverloads constructor(
-    context: Context, attrs: AttributeSet? = null
-) : AppCompatTextView(context, attrs) {
-
-    //描边
-    private val strokePaint = Paint()
-    private var strokeColor: Int = 0
-    private var strokeWidth: Float = 0f
-
-    //描边渐变色
-    private var strokeColors: Array<Int>? = null
-    private var strokeColorPositions: Array<Float>? = null
-    private var strokeOrientation = VERTICAL_GRADIENT
-
-    //阴影
-    private val shadowPaint = Paint()
-    private var shadowDx: Float = 0f
-    private var shadowDy: Float = 0f
-    private var shadowRadius: Float = 0f
-    private var shadowColor: Int = 0
-
-    //文字渐变色
-    private val gradientPaint = Paint()
-    private var gradientOrientation = VERTICAL_GRADIENT
-    private var gradientColors: Array<Int>? = null
-    private var gradientColorPositions: Array<Float>? = null
-
-    // 斜线
-    private val diagonalPaint = Paint()
-    private var diagonalColor: Int = Color.TRANSPARENT
-    private var diagonalWidth: Float = 0f
-
-    private val SRC_ATOP_X_FERMODE = PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP)
-
-
-    //动态修改 阴影值
-    fun setShadowDx(shadowDx: Float) {
-        this.shadowDx = shadowDx
-    }
-
-    fun setShadowDy(shadowDy: Float) {
-        this.shadowDy = shadowDy
-    }
-
-    fun setShadowColor(shadowColor: Int) {
-        this.shadowColor = shadowColor
-    }
-
-    init {
-        initAttrs(context, attrs)
-    }
-
-    private fun initAttrs(context: Context, attrs: AttributeSet?) {
-        if (isInEditMode) {
-            return
-        }
-        context.withStyledAttributes(attrs, R.styleable.GameTextView) {
-            strokeColor =
-                getColor(R.styleable.GameTextView_strokeColor, getCompatColor(R.color.black))
-            strokeWidth = getDimension(R.styleable.GameTextView_strokeWidth, 0f)
-            val strokeColors = getString(R.styleable.GameTextView_strokeColors)
-            val strokePositions = getString(R.styleable.GameTextView_strokePosition)
-            strokeOrientation =
-                getInt(R.styleable.GameTextView_gradientOrientation, VERTICAL_GRADIENT)
-            if (strokeColors != null && strokePositions != null) {
-                val cc =
-                    strokeColors.split(",".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
-                val pp = strokePositions.split(",".toRegex()).dropLastWhile { it.isEmpty() }
-                    .toTypedArray()
-                if (cc.isNotEmpty() && cc.size == pp.size) {
-                    this@GameTextView.strokeColors = cc.map { Color.parseColor(it) }.toTypedArray()
-                    strokeColorPositions = pp.map { it.toFloat() }.toTypedArray()
-                    setTextColor(Color.WHITE)
-                }
-            }
-            shadowDx = getFloat(R.styleable.GameTextView_shadowDx, 0f)
-            shadowDy = getFloat(R.styleable.GameTextView_shadowDy, 0f)
-            shadowRadius = getFloat(R.styleable.GameTextView_shadowRadius, 0f)
-            shadowColor =
-                getColor(R.styleable.GameTextView_shadowColor, getCompatColor(R.color.black))
-
-            val gradientColors = getString(R.styleable.GameTextView_gradientColors)
-            val gradientPositions = getString(R.styleable.GameTextView_gradientPosition)
-            gradientOrientation =
-                getInt(R.styleable.GameTextView_gradientOrientation, VERTICAL_GRADIENT)
-            if (gradientColors != null && gradientPositions != null) {
-                val cc = gradientColors.split(",".toRegex()).dropLastWhile { it.isEmpty() }
-                    .toTypedArray()
-                val pp = gradientPositions.split(",".toRegex()).dropLastWhile { it.isEmpty() }
-                    .toTypedArray()
-                if (cc.isNotEmpty() && cc.size == pp.size) {
-                    this@GameTextView.gradientColors =
-                        cc.map { Color.parseColor(it) }.toTypedArray()
-                    gradientColorPositions = pp.map { it.toFloat() }.toTypedArray()
-                    setTextColor(Color.WHITE)
-                }
-            }
-            diagonalColor = getColor(R.styleable.GameTextView_diagonalColor, Color.TRANSPARENT)
-            diagonalWidth = getDimension(R.styleable.GameTextView_diagonalWidth, 0f)
-        }
-        updatePaintAndInvalidate()
-    }
-
-    override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
-        super.onSizeChanged(w, h, oldw, oldh)
-        setStroke(
-            strokeColor,
-            strokeWidth
-        )
-        setGradient(
-            gradientColors?.toList() ?: emptyList(),
-            gradientColorPositions?.toList() ?: emptyList(),
-            gradientOrientation
-        )
-    }
-
-    fun setStroke(color: Int, width: Float) {
-        strokeColor = color
-        strokeWidth = width
-        updatePaintAndInvalidate()
-    }
-
-    fun setShadow(radius: Float, dx: Float, dy: Float, color: Int) {
-        shadowRadius = radius
-        shadowDx = dx
-        shadowDy = dy
-        shadowColor = color
-        updatePaintAndInvalidate()
-    }
-
-    fun setGradient(
-        colors: List<Int>,
-        positions: List<Float>,
-        orientation: Int = VERTICAL_GRADIENT
-    ) {
-        gradientOrientation = orientation
-        gradientColors = colors.toTypedArray()
-        gradientColorPositions = positions.toTypedArray()
-        updatePaintAndInvalidate()
-    }
-
-    private fun updatePaintAndInvalidate() {
-        //阴影画笔
-        shadowPaint.isAntiAlias = true
-        shadowPaint.isDither = true
-        shadowPaint.isFilterBitmap = true
-        shadowPaint.strokeWidth = strokeWidth
-        shadowPaint.strokeJoin = Paint.Join.ROUND
-        shadowPaint.strokeCap = Paint.Cap.ROUND
-        shadowPaint.style = Paint.Style.FILL_AND_STROKE
-        if (shadowDx > 0 && shadowDy > 0) {
-            shadowPaint.setShadowLayer(shadowRadius, shadowDx, shadowDy, shadowColor)
-        } else {
-            shadowPaint.clearShadowLayer()
-        }
-
-        //描边画笔
-        strokePaint.isAntiAlias = true
-        strokePaint.isDither = true
-        strokePaint.isFilterBitmap = true
-        strokePaint.strokeWidth = strokeWidth
-        val strokeColors = strokeColors
-        val strokePositions = strokeColorPositions
-
-        if (strokeColors != null && strokePositions != null
-            && strokeColors.isNotEmpty()
-            && strokeColors.size == strokePositions.size
-        ) {
-            strokePaint.shader = if (strokeOrientation == VERTICAL_GRADIENT) {
-                LinearGradient(
-                    0f,
-                    0f,
-                    0f,
-                    lineHeight.toFloat(),
-                    strokeColors.toIntArray(),
-                    strokePositions.toFloatArray(),
-                    Shader.TileMode.CLAMP
-                )
-            } else {
-                LinearGradient(
-                    0f,
-                    0f,
-                    width.toFloat(),
-                    0f,
-                    strokeColors.toIntArray(),
-                    strokePositions.toFloatArray(),
-                    Shader.TileMode.CLAMP
-                )
-            }
-        } else {
-            strokePaint.shader = LinearGradient(
-                0f, 0f,
-                0f, lineHeight.toFloat(),
-                strokeColor,
-                strokeColor,
-                Shader.TileMode.CLAMP
-            )
-        }
-
-        strokePaint.strokeJoin = Paint.Join.ROUND
-        strokePaint.strokeCap = Paint.Cap.ROUND
-        strokePaint.style = Paint.Style.STROKE
-        strokePaint.xfermode = SRC_ATOP_X_FERMODE
-        if (strokeWidth != 0f && !text.endsWith(" ")) {
-            //描边时给文字末尾加个空格,防止被切割
-            text = text.padEnd(text.length + 1)
-        }
-        //渐变画笔
-        gradientPaint.isAntiAlias = true
-        gradientPaint.isDither = true
-        gradientPaint.isFilterBitmap = true
-        val gradientColors = gradientColors
-        val gradientPositions = gradientColorPositions
-        if (gradientColors != null && gradientPositions != null
-            && gradientColors.isNotEmpty()
-            && gradientColors.size == gradientPositions.size
-        ) {
-            gradientPaint.shader = if (gradientOrientation == VERTICAL_GRADIENT) {
-                LinearGradient(
-                    0f,
-                    0f,
-                    0f,
-                    lineHeight.toFloat(),
-                    gradientColors.toIntArray(),
-                    gradientPositions.toFloatArray(),
-                    Shader.TileMode.CLAMP
-                )
-            } else {
-                LinearGradient(
-                    0f,
-                    0f,
-                    width.toFloat(),
-                    0f,
-                    gradientColors.toIntArray(),
-                    gradientPositions.toFloatArray(),
-                    Shader.TileMode.CLAMP
-                )
-            }
-        } else {
-            gradientPaint.shader = null
-        }
-        gradientPaint.strokeJoin = Paint.Join.ROUND
-        gradientPaint.strokeCap = Paint.Cap.ROUND
-        gradientPaint.style = Paint.Style.FILL
-        strokePaint.xfermode = SRC_ATOP_X_FERMODE
-        // 斜线
-        diagonalPaint.apply {
-            isAntiAlias = true
-            strokeWidth = diagonalWidth
-            strokeCap = Paint.Cap.ROUND
-            color = diagonalColor
-            style = Paint.Style.STROKE
-        }
-        postInvalidate()
-    }
-
-    private fun isDrawShadow(): Boolean {
-        return shadowDx > 0 || shadowDy > 0
-    }
-
-    private fun isDiagonal(): Boolean {
-        return diagonalWidth > 0
-    }
-
-    private fun isDrawGradient(): Boolean {
-        val gradientColors = gradientColors
-        val gradientPositions = gradientColorPositions
-        return gradientColors != null && gradientPositions != null
-                && gradientColors.isNotEmpty()
-                && gradientColors.size == gradientPositions.size
-    }
-
-    private fun isDrawStroke(): Boolean {
-        return strokeWidth > 0
-    }
-
-    fun setShadowLayer(radius: Float, dx: Float, dy: Float, color: String?) {
-        shadowPaint.setShadowLayer(radius, dx, dy, Color.parseColor(color))
-    }
-
-    override fun onDraw(canvas: Canvas) {
-        //阴影
-        if (isDrawShadow()) {
-            drawShadow {
-                super.onDraw(canvas)
-            }
-        }
-
-        //描边
-        if (isDrawStroke()) {
-            drawStroke {
-                super.onDraw(canvas)
-            }
-        }
-        // 斜线
-        if (isDiagonal()) {
-            drawDiagonal(canvas)
-        }
-        if (isDrawGradient()) {
-            //渐变
-            drawGradient {
-                super.onDraw(canvas)
-            }
-        } else {
-            super.onDraw(canvas)
-        }
-    }
-
-    private fun drawShadow(callDraw: () -> Unit) {
-        val originIsAntiAlias = paint.isAntiAlias
-        val originIsDither = paint.isDither
-        val originIsFilterBitmap = paint.isFilterBitmap
-        val originStrokeWidth = paint.strokeWidth
-        val originTextColor = textColors
-        val originStrokeJoin = paint.strokeJoin
-        val originStrokeCap = paint.strokeCap
-        val originStyle = paint.style
-
-        paint.isAntiAlias = shadowPaint.isAntiAlias
-        paint.isDither = shadowPaint.isDither
-        paint.isFilterBitmap = shadowPaint.isFilterBitmap
-        paint.strokeWidth = shadowPaint.strokeWidth
-        //paint.color = shadowPaint.color
-        paint.strokeJoin = shadowPaint.strokeJoin
-        paint.strokeCap = shadowPaint.strokeCap
-        paint.style = shadowPaint.style
-        paint.setShadowLayer(shadowRadius, shadowDx, shadowDy, shadowColor)
-
-        callDraw.invoke()
-
-        paint.isAntiAlias = originIsAntiAlias
-        paint.isDither = originIsDither
-        paint.isFilterBitmap = originIsFilterBitmap
-        paint.strokeWidth = originStrokeWidth
-        paint.strokeJoin = originStrokeJoin
-        paint.strokeCap = originStrokeCap
-        paint.style = originStyle
-        paint.clearShadowLayer()
-    }
-
-    private fun drawStroke(callDraw: () -> Unit) {
-        val originIsAntiAlias = paint.isAntiAlias
-        val originIsDither = paint.isDither
-        val originIsFilterBitmap = paint.isFilterBitmap
-        val originStrokeWidth = paint.strokeWidth
-        val originShader = paint.shader
-        val originStrokeJoin = paint.strokeJoin
-        val originStrokeCap = paint.strokeCap
-        val originStyle = paint.style
-
-        paint.isAntiAlias = strokePaint.isAntiAlias
-        paint.isDither = strokePaint.isDither
-        paint.isFilterBitmap = strokePaint.isFilterBitmap
-        paint.strokeWidth = strokePaint.strokeWidth
-        paint.shader = strokePaint.shader
-        paint.strokeJoin = strokePaint.strokeJoin
-        paint.strokeCap = strokePaint.strokeCap
-        paint.style = strokePaint.style
-
-        callDraw.invoke()
-
-        paint.isAntiAlias = originIsAntiAlias
-        paint.isDither = originIsDither
-        paint.isFilterBitmap = originIsFilterBitmap
-        paint.strokeWidth = originStrokeWidth
-        paint.shader = originShader
-        paint.strokeJoin = originStrokeJoin
-        paint.strokeCap = originStrokeCap
-        paint.style = originStyle
-        paint.clearShadowLayer()
-    }
-
-    private fun drawGradient(callDraw: () -> Unit) {
-        val originIsAntiAlias = paint.isAntiAlias
-        val originIsDither = paint.isDither
-        val originIsFilterBitmap = paint.isFilterBitmap
-        val originShader = paint.shader
-        val originStrokeJoin = paint.strokeJoin
-        val originStrokeCap = paint.strokeCap
-        val originStyle = paint.style
-
-        paint.isAntiAlias = gradientPaint.isAntiAlias
-        paint.isDither = gradientPaint.isDither
-        paint.isFilterBitmap = gradientPaint.isFilterBitmap
-        paint.shader = gradientPaint.shader
-        paint.strokeJoin = gradientPaint.strokeJoin
-        paint.strokeCap = gradientPaint.strokeCap
-        paint.style = gradientPaint.style
-
-        callDraw.invoke()
-
-        paint.isAntiAlias = originIsAntiAlias
-        paint.isDither = originIsDither
-        paint.isFilterBitmap = originIsFilterBitmap
-        paint.shader = originShader
-        paint.strokeJoin = originStrokeJoin
-        paint.strokeCap = originStrokeCap
-        paint.style = originStyle
-    }
-
-    private fun drawDiagonal(canvas: Canvas) {
-        if (diagonalWidth > 0) {
-            diagonalPaint.color = diagonalColor
-            diagonalPaint.strokeWidth = diagonalWidth
-            diagonalPaint.style = Paint.Style.STROKE
-            diagonalPaint.strokeCap = Paint.Cap.ROUND
-            diagonalPaint.isAntiAlias = true
-            canvas.drawLine(
-                0f,
-                (height.toFloat() * 0.4).toFloat(), width.toFloat(),
-                (height.toFloat() * 0.6).toFloat(), diagonalPaint
-            )
-        }
-    }
-
-    companion object {
-        const val VERTICAL_GRADIENT = 0
-        const val HORIZONTAL_GRADIENT = 1
-    }
-
-}

+ 0 - 32
app/src/main/java/com/adealink/weparty/commonui/widget/choicelist/ChoiceItemViewBinder.kt

@@ -1,32 +0,0 @@
-package com.adealink.weparty.commonui.widget.choicelist
-
-import android.view.LayoutInflater
-import android.view.ViewGroup
-import com.adealink.weparty.R
-import com.adealink.weparty.commonui.recycleview.adapter.BindingViewHolder
-import com.adealink.weparty.commonui.recycleview.adapter.multitype.ItemViewBinder
-import com.adealink.weparty.databinding.ItemChoiceBinding
-
-class ChoiceItemViewBinder(private val onItemClick: (choiceId: Int)->Unit): ItemViewBinder<ChoiceModel, BindingViewHolder<ItemChoiceBinding>>() {
-    override fun onBindViewHolder(holder: BindingViewHolder<ItemChoiceBinding>, item: ChoiceModel) {
-        when(item.isCheck) {
-            true -> {
-                holder.binding.ivChoice.setImageResource(R.drawable.common_checked_ic)
-            }
-            else -> {
-                holder.binding.ivChoice.setImageResource(R.drawable.common_check_normal_ic)
-            }
-        }
-        holder.binding.tvChoice.text = item.title
-        holder.binding.root.setOnClickListener {
-            onItemClick.invoke(item.id)
-        }
-    }
-
-    override fun onCreateViewHolder(
-        inflater: LayoutInflater,
-        parent: ViewGroup
-    ): BindingViewHolder<ItemChoiceBinding> {
-        return BindingViewHolder(ItemChoiceBinding.inflate(inflater, parent, false))
-    }
-}

+ 0 - 14
app/src/main/java/com/adealink/weparty/commonui/widget/choicelist/ChoiceModel.kt

@@ -1,14 +0,0 @@
-package com.adealink.weparty.commonui.widget.choicelist
-
-data class ChoiceModel(
-    val id: Int,
-    val title: String,
-    var isCheck: Boolean = false,
-    var data: Any? = null
-)
-
-data class ImageChoiceModel(
-    val id: Int,
-    val url: String,
-    var isCheck: Boolean = false,
-)

+ 0 - 106
app/src/main/java/com/adealink/weparty/commonui/widget/choicelist/CommonChoiceListView.kt

@@ -1,106 +0,0 @@
-package com.adealink.weparty.commonui.widget.choicelist
-
-import android.content.Context
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import androidx.constraintlayout.widget.ConstraintLayout
-import androidx.recyclerview.widget.LinearLayoutManager
-import com.adealink.weparty.R
-import com.adealink.weparty.commonui.MULTIPLE_CHOICE
-import com.adealink.weparty.commonui.SINGLE_CHOICE
-import com.adealink.weparty.commonui.recycleview.adapter.multitype.MultiTypeAdapter
-import com.adealink.weparty.databinding.LayoutCommonChoiceListBinding
-
-class CommonChoiceListView @JvmOverloads constructor(
-    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
-) : ConstraintLayout(context, attrs, defStyleAttr) {
-
-    private val binding = LayoutCommonChoiceListBinding.inflate(LayoutInflater.from(context), this)
-    private lateinit var choiceAdapter: MultiTypeAdapter
-    private var choiceType = SINGLE_CHOICE
-    private var choiceModelList = arrayListOf<ChoiceModel>()
-    var onCheckChangeListener: OnCheckChangeListener? = null
-
-    private val itemClickFunction = { choiceId: Int ->
-        val currentModel = choiceModelList.find { it.id == choiceId }
-        if (currentModel != null) {
-            val hasItemChecked = currentModel.isCheck
-            if (choiceType == MULTIPLE_CHOICE) {
-                currentModel.isCheck = !hasItemChecked
-                choiceAdapter.notifyDataSetChanged()
-                notifyCheckedChanged()
-            } else {
-                if (!currentModel.isCheck) {
-                    choiceModelList.forEach {
-                        it.isCheck = it.id == choiceId
-                    }
-                    choiceAdapter.notifyDataSetChanged()
-                    notifyCheckedChanged()
-                }
-            }
-        }
-    }
-
-    init {
-        initAttrs(context, attrs)
-        initView()
-    }
-
-    private fun initAttrs(context: Context, attrs: AttributeSet?) {
-        attrs?.let {
-            val ta = context.obtainStyledAttributes(it, R.styleable.CommonChoiceListView)
-            choiceType = convertChoiceType(
-                ta.getInt(
-                    R.styleable.CommonChoiceListView_choice_type,
-                    SINGLE_CHOICE
-                )
-            )
-            ta.recycle()
-        }
-    }
-
-    private fun convertChoiceType(attrType: Int): Int {
-        return when (attrType) {
-            0 -> SINGLE_CHOICE
-            else -> MULTIPLE_CHOICE
-        }
-    }
-
-    private fun initView() {
-        choiceAdapter = MultiTypeAdapter()
-        choiceAdapter.register(ChoiceItemViewBinder(itemClickFunction))
-        binding.rvChoice.apply {
-            adapter = choiceAdapter
-            layoutManager = LinearLayoutManager(context)
-        }
-        binding.rvChoice.isNestedScrollingEnabled = false
-    }
-
-    fun setChoiceModelList(list: ArrayList<ChoiceModel>) {
-        choiceModelList = list
-        choiceAdapter.items = list
-        choiceAdapter.notifyDataSetChanged()
-    }
-
-    private fun notifyCheckedChanged() {
-        val choiceList = mutableListOf<ChoiceModel>()
-        choiceModelList.forEach {
-            if (it.isCheck) {
-                choiceList.add(it)
-                return@forEach
-            }
-        }
-        onCheckChangeListener?.onCheckChanged(choiceList)
-    }
-
-    fun getCheckedItemIdList(): ArrayList<Int> {
-        val list = arrayListOf<Int>()
-        choiceModelList.forEach {
-            if (it.isCheck) {
-                list.add(it.id)
-                return@forEach
-            }
-        }
-        return list
-    }
-}

+ 0 - 114
app/src/main/java/com/adealink/weparty/commonui/widget/choicelist/CommonImageChoiceListView.kt

@@ -1,114 +0,0 @@
-package com.adealink.weparty.commonui.widget.choicelist
-
-import android.content.Context
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import androidx.constraintlayout.widget.ConstraintLayout
-import androidx.recyclerview.widget.GridLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import com.adealink.frame.util.DisplayUtil
-import com.adealink.weparty.R
-import com.adealink.weparty.commonui.MULTIPLE_CHOICE
-import com.adealink.weparty.commonui.SINGLE_CHOICE
-import com.adealink.weparty.commonui.recycleview.adapter.multitype.MultiTypeAdapter
-import com.adealink.weparty.commonui.recycleview.itemdecoration.GridSpacingItemDecoration
-import com.adealink.weparty.databinding.LayoutCommonChoiceListBinding
-
-class CommonImageChoiceListView @JvmOverloads constructor(
-    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0,
-) : ConstraintLayout(context, attrs, defStyleAttr) {
-
-    private val binding = LayoutCommonChoiceListBinding.inflate(LayoutInflater.from(context), this)
-    private lateinit var choiceAdapter: MultiTypeAdapter
-    private var choiceType = SINGLE_CHOICE
-    private var choiceModelList = arrayListOf<ImageChoiceModel>()
-    var onCheckChangeListener: OnImageCheckChangeListener? = null
-
-    private val itemClickFunction = { choiceId: Int ->
-        val currentModel = choiceModelList.find { it.id == choiceId }
-        if (currentModel != null) {
-            val hasItemChecked = currentModel.isCheck
-            if (choiceType == MULTIPLE_CHOICE) {
-                currentModel.isCheck = !hasItemChecked
-                choiceAdapter.notifyDataSetChanged()
-                notifyCheckedChanged()
-            } else {
-                if (!currentModel.isCheck) {
-                    choiceModelList.forEach {
-                        it.isCheck = it.id == choiceId
-                    }
-                    choiceAdapter.notifyDataSetChanged()
-                    notifyCheckedChanged()
-                }
-            }
-        }
-    }
-
-    init {
-        initAttrs(context, attrs)
-        initView()
-    }
-
-    private fun initAttrs(context: Context, attrs: AttributeSet?) {
-        attrs?.let {
-            val ta = context.obtainStyledAttributes(it, R.styleable.CommonImageChoiceListView)
-            choiceType = convertChoiceType(
-                ta.getInt(
-                    R.styleable.CommonImageChoiceListView_choice_type,
-                    SINGLE_CHOICE
-                )
-            )
-            ta.recycle()
-        }
-    }
-
-    private fun convertChoiceType(attrType: Int): Int {
-        return when (attrType) {
-            0 -> SINGLE_CHOICE
-            else -> MULTIPLE_CHOICE
-        }
-    }
-
-    private fun initView() {
-        choiceAdapter = MultiTypeAdapter()
-        choiceAdapter.register(ImageChoiceItemViewBinder(itemClickFunction))
-        binding.rvChoice.apply {
-            adapter = choiceAdapter
-            layoutManager = GridLayoutManager(
-                context,
-                ImageChoiceItemViewBinder.SPAN_COUNT,
-                RecyclerView.VERTICAL,
-                false
-            )
-            addItemDecoration(GridSpacingItemDecoration(ImageChoiceItemViewBinder.SPAN_COUNT, DisplayUtil.dp2px(5f), DisplayUtil.dp2px(5f), false))
-        }
-    }
-
-    fun setChoiceModelList(list: ArrayList<ImageChoiceModel>) {
-        choiceModelList = list
-        choiceAdapter.items = list
-        choiceAdapter.notifyDataSetChanged()
-    }
-
-    private fun notifyCheckedChanged() {
-        val choiceList = mutableListOf<ImageChoiceModel>()
-        choiceModelList.forEach {
-            if (it.isCheck) {
-                choiceList.add(it)
-                return@forEach
-            }
-        }
-        onCheckChangeListener?.onCheckChanged(choiceList)
-    }
-
-    fun getCheckedItemIdList(): ArrayList<Int> {
-        val list = arrayListOf<Int>()
-        choiceModelList.forEach {
-            if (it.isCheck) {
-                list.add(it.id)
-                return@forEach
-            }
-        }
-        return list
-    }
-}

+ 0 - 42
app/src/main/java/com/adealink/weparty/commonui/widget/choicelist/ImageChoiceItemViewBinder.kt

@@ -1,42 +0,0 @@
-package com.adealink.weparty.commonui.widget.choicelist
-
-import android.view.LayoutInflater
-import android.view.ViewGroup
-import com.adealink.frame.util.DisplayUtil
-import com.adealink.weparty.R
-import com.adealink.weparty.commonui.recycleview.adapter.BindingViewHolder
-import com.adealink.weparty.commonui.recycleview.adapter.multitype.ItemViewBinder
-import com.adealink.weparty.databinding.ItemImageChoiceBinding
-
-class ImageChoiceItemViewBinder(private val onItemClick: (choiceId: Int)->Unit): ItemViewBinder<ImageChoiceModel, BindingViewHolder<ItemImageChoiceBinding>>() {
-    override fun onBindViewHolder(holder: BindingViewHolder<ItemImageChoiceBinding>, item: ImageChoiceModel) {
-        val lp = holder.binding.root.layoutParams
-        lp.width = itemWidth
-        lp.height = itemWidth
-        holder.binding.root.layoutParams = lp
-        when(item.isCheck) {
-            true -> {
-                holder.binding.ivChoice.setImageResource(R.drawable.common_checked_ic)
-            }
-            else -> {
-                holder.binding.ivChoice.setImageResource(R.drawable.common_check_normal_ic)
-            }
-        }
-        holder.binding.ivImage.setImageUrl(item.url)
-        holder.binding.root.setOnClickListener {
-            onItemClick.invoke(item.id)
-        }
-    }
-
-    override fun onCreateViewHolder(
-        inflater: LayoutInflater,
-        parent: ViewGroup
-    ): BindingViewHolder<ItemImageChoiceBinding> {
-        return BindingViewHolder(ItemImageChoiceBinding.inflate(inflater, parent, false))
-    }
-
-    companion object {
-        const val SPAN_COUNT = 3
-        val itemWidth = (DisplayUtil.getScreenWidth() - DisplayUtil.dp2px(42f)) / SPAN_COUNT
-    }
-}

+ 0 - 9
app/src/main/java/com/adealink/weparty/commonui/widget/choicelist/OnCheckChangeListener.kt

@@ -1,9 +0,0 @@
-package com.adealink.weparty.commonui.widget.choicelist
-
-interface OnCheckChangeListener {
-    fun onCheckChanged(chosenModel: List<ChoiceModel>)
-}
-
-interface OnImageCheckChangeListener {
-    fun onCheckChanged(chosenModelList: List<ImageChoiceModel>)
-}

+ 0 - 10
app/src/main/java/com/adealink/weparty/commonui/widget/tags/OnSelectTagsListener.kt

@@ -1,10 +0,0 @@
-package com.adealink.weparty.commonui.widget.tags
-
-/**
- * Created by sunxiaodong on 2021/10/19.
- */
-interface OnSelectTagsListener {
-
-    fun onSelectTags(selectTags: List<TagsLayout.Tag>)
-
-}

+ 0 - 242
app/src/main/java/com/adealink/weparty/commonui/widget/tags/TagsLayout.kt

@@ -1,242 +0,0 @@
-package com.adealink.weparty.commonui.widget.tags
-
-import android.content.Context
-import android.content.res.ColorStateList
-import android.net.Uri
-import android.util.AttributeSet
-import android.view.LayoutInflater
-import android.view.View
-import android.view.ViewGroup
-import android.widget.TextView
-import com.adealink.frame.aab.util.getCompatColorStateList
-import com.adealink.weparty.commonui.MULTIPLE_CHOICE
-import com.adealink.weparty.commonui.SINGLE_CHOICE
-import com.adealink.weparty.commonui.SINGLE_MUST_CHOICE
-import com.adealink.frame.image.view.NetworkImageView
-import com.adealink.frame.util.DisplayUtil
-import com.adealink.weparty.R
-import com.facebook.common.util.UriUtil
-
-/**
- * Created by sunxiaodong on 2021/10/17.
- */
-class TagsLayout @JvmOverloads constructor(
-    context: Context,
-    attrs: AttributeSet? = null,
-    defStyleAttr: Int = 0,
-) : ViewGroup(context, attrs, defStyleAttr) {
-
-    data class Tag(val id: Long, var icon: String, var text: String, var select: Boolean = false)
-
-    private var tags: MutableList<Tag> = arrayListOf()
-    private var itemHeight = DisplayUtil.dp2px(28F)
-    private var itemMinWidth = 0
-    private var itemHInterval = DisplayUtil.dp2px(10F)
-    private var itemVInterval = DisplayUtil.dp2px(16F)
-    private var itemBackground = R.drawable.common_tags_layout_item_bg
-    private var itemTextColor : ColorStateList = getCompatColorStateList(R.color.color_222222)
-    var singleLine = false
-    var canSelect = true
-    var selectTagsListener: OnSelectTagsListener? = null
-    private var choiceType = MULTIPLE_CHOICE
-    private var tagViewMap = hashMapOf<Long, View>()
-
-    init {
-        attrs?.apply {
-            val a = context.obtainStyledAttributes(this, R.styleable.TagsLayout)
-            itemHeight = a.getDimensionPixelSize(R.styleable.TagsLayout_item_height, itemHeight)
-            itemMinWidth = a.getDimensionPixelSize(R.styleable.TagsLayout_item_min_width, itemMinWidth)
-            itemHInterval =
-                a.getDimensionPixelSize(R.styleable.TagsLayout_item_h_interval, itemHInterval)
-            itemVInterval =
-                a.getDimensionPixelSize(R.styleable.TagsLayout_item_v_interval, itemVInterval)
-            itemBackground = a.getResourceId(R.styleable.TagsLayout_item_background, itemBackground)
-            itemTextColor =
-                a.getColorStateList(R.styleable.TagsLayout_item_text_color) ?: itemTextColor
-            choiceType =
-                when (a.getInt(R.styleable.TagsLayout_choice_type, choiceType)) {
-                    0 -> SINGLE_CHOICE
-                    2 -> SINGLE_MUST_CHOICE
-                    else -> MULTIPLE_CHOICE
-                }
-            a.recycle()
-        }
-    }
-
-    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
-        val count = childCount
-        val maxWidth = MeasureSpec.getSize(widthMeasureSpec) - paddingStart - paddingEnd
-        var lineWidth = 0
-        var contentHeight = 0
-        var maxLineWidth = 0
-        var maxItemHeight = 0
-        var begin = true
-        for (i in 0 until count) {
-            val view = getChildAt(i)
-            measureChild(view, widthMeasureSpec, heightMeasureSpec)
-            if (!begin) {
-                lineWidth += itemHInterval
-            } else {
-                begin = false
-            }
-            if (lineWidth + view.measuredWidth > maxWidth) {
-                if (singleLine) {
-                    break
-                }
-                contentHeight += itemVInterval
-                contentHeight += maxItemHeight
-                maxItemHeight = 0
-                maxLineWidth = maxLineWidth.coerceAtLeast(lineWidth)
-                lineWidth = 0
-                begin = true
-            }
-            maxItemHeight = maxItemHeight.coerceAtLeast(view.measuredHeight)
-            lineWidth += view.measuredWidth
-        }
-        contentHeight += maxItemHeight
-        maxLineWidth = maxLineWidth.coerceAtLeast(lineWidth)
-        setMeasuredDimension(maxLineWidth, contentHeight)
-    }
-
-    override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
-        val isRlt: Boolean = layoutDirection == LAYOUT_DIRECTION_RTL
-        var x = 0
-        var y = 0
-        val contentWidth = r - l
-        var maxItemHeight = 0
-        val count = childCount
-        val xPaddingPx: Int = itemHInterval
-        val yPaddingPx: Int = itemVInterval
-        if (isRlt) {
-            x = contentWidth - paddingStart
-        }
-        for (i in 0 until count) {
-            val view = getChildAt(i)
-            if (isRlt) {
-                if (x - view.measuredWidth - paddingEnd < 0) {
-                    if (singleLine) {
-                        break
-                    }
-                    x = contentWidth - paddingStart
-                    y += yPaddingPx
-                    y += maxItemHeight
-                    maxItemHeight = 0
-                }
-                x -= view.measuredWidth
-                view.layout(x, y, x + view.measuredWidth, y + view.measuredHeight)
-                x -= xPaddingPx
-            } else {
-                if (contentWidth < x + view.measuredWidth + paddingEnd) {
-                    if (singleLine) {
-                        break
-                    }
-                    x = 0
-                    y += yPaddingPx
-                    y += maxItemHeight
-                    maxItemHeight = 0
-                }
-                view.layout(x, y, x + view.measuredWidth, y + view.measuredHeight)
-                x += view.measuredWidth
-                x += xPaddingPx
-            }
-            maxItemHeight = maxItemHeight.coerceAtLeast(view.measuredHeight)
-        }
-    }
-
-    fun setTags(tags: List<Tag>) {
-        this.tags.clear()
-        this.tags.addAll(tags)
-        tagViewMap.clear()
-        removeAllViews()
-        this.tags.forEachIndexed { index, tag ->
-            val itemView =
-                LayoutInflater.from(context).inflate(R.layout.layout_tag_item, this, false)
-            itemView.minimumWidth = itemMinWidth
-            tagViewMap[tag.id] = itemView
-            val iconView = itemView.findViewById<NetworkImageView>(R.id.icon)
-            if (tag.icon.isEmpty()) {
-                iconView.visibility = View.GONE
-            } else {
-                iconView.visibility = View.VISIBLE
-                iconView.setImageUrl(tag.icon)
-            }
-
-            val textView = itemView.findViewById<TextView>(R.id.text)
-            if (tag.text.isEmpty()) {
-                textView.visibility = View.GONE
-            } else {
-                textView.visibility = View.VISIBLE
-                textView.text = tag.text
-            }
-            textView.setTextColor(itemTextColor)
-
-            itemView.setBackgroundResource(itemBackground)
-            itemView.isSelected = tag.select
-            itemView.setOnClickListener {
-                when (choiceType) {
-                    SINGLE_CHOICE -> {
-                        if (tag.select) {
-                            tag.select = false
-                            itemView.isSelected = tag.select
-                        } else {
-                            tags.forEachIndexed { index1, tag ->
-                                tag.select = index1 == index
-                                getChildAt(index1).isSelected = tag.select
-                            }
-                        }
-                        selectTagsListener?.onSelectTags(getAllSelectTags())
-                    }
-                    SINGLE_MUST_CHOICE -> {
-                        if(tag.select) {
-                            selectTagsListener?.onSelectTags(getAllSelectTags())
-                            return@setOnClickListener
-                        }
-
-                        tags.forEachIndexed { index1, tag ->
-                            tag.select = index1 == index
-                            getChildAt(index1).isSelected = tag.select
-                        }
-                        selectTagsListener?.onSelectTags(getAllSelectTags())
-                    }
-                    else -> {
-                        if (!tag.select && !canSelect) {
-                            return@setOnClickListener
-                        }
-                        tag.select = !tag.select
-                        itemView.isSelected = tag.select
-                        selectTagsListener?.onSelectTags(getAllSelectTags())
-                    }
-                }
-            }
-            this.addView(itemView)
-        }
-    }
-
-    fun getAllSelectTags(): List<Tag> {
-        return tags.filter { it.select }
-    }
-
-    fun update(tag: Tag) {
-        val itemView = tagViewMap[tag.id] ?: return
-        val iconView = itemView.findViewById<NetworkImageView>(R.id.icon)
-        if (tag.icon.isEmpty()) {
-            iconView.visibility = View.GONE
-        } else {
-            iconView.visibility = View.VISIBLE
-            if (UriUtil.isNetworkUri(Uri.parse(tag.icon))){
-                iconView.setImageUrl(tag.icon)
-            }else{
-                iconView.setImageURI(Uri.parse(tag.icon))
-            }
-        }
-
-        val textView = itemView.findViewById<TextView>(R.id.text)
-        if (tag.text.isEmpty()) {
-            textView.visibility = View.GONE
-        } else {
-            textView.visibility = View.VISIBLE
-            textView.text = tag.text
-        }
-    }
-
-}

+ 0 - 12
app/src/main/java/com/adealink/weparty/commonui/widget/upload/InnerUploadFileOpCallback.kt

@@ -1,12 +0,0 @@
-package com.adealink.weparty.commonui.widget.upload
-
-/**
- * Created by sunxiaodong on 2022/2/22.
- */
-internal interface InnerUploadFileOpCallback {
-
-    fun onAddClick()
-    fun onDeleteClick(item: UploadFileItem)
-    fun onPreviewClick(position: Int)
-
-}

+ 0 - 84
app/src/main/java/com/adealink/weparty/commonui/widget/upload/UploadFileAddView.kt

@@ -1,84 +0,0 @@
-package com.adealink.weparty.commonui.widget.upload
-
-import android.content.Context
-import android.content.res.TypedArray
-import android.util.AttributeSet
-import androidx.recyclerview.widget.LinearLayoutManager
-import androidx.recyclerview.widget.RecyclerView
-import com.adealink.frame.base.fastLazy
-import com.adealink.weparty.R
-import com.adealink.weparty.commonui.recycleview.adapter.MultiTypeListAdapter
-import com.adealink.weparty.commonui.recycleview.itemdecoration.HorizontalItemDecoration
-
-/**
- * Created by sunxiaodong on 2022/2/22.
- */
-class UploadFileAddView @kotlin.jvm.JvmOverloads constructor(
-    context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
-) : RecyclerView(context, attrs, defStyleAttr), InnerUploadFileOpCallback {
-
-    private var maxCount: Int = 3
-
-    private val fileAdapter by fastLazy { MultiTypeListAdapter<UploadFileItem>() }
-
-    var callback: UploadFileOpCallback? = null
-
-    init {
-        val typedArray: TypedArray = context.obtainStyledAttributes(
-            attrs,
-            R.styleable.UploadFileAddView
-        )
-        maxCount = typedArray.getInt(R.styleable.UploadFileAddView_maxCount, maxCount)
-        typedArray.recycle()
-
-        adapter = fileAdapter
-        layoutManager = LinearLayoutManager(context, HORIZONTAL, false)
-        addItemDecoration(HorizontalItemDecoration(5F, 16f, 16f))
-        fileAdapter.register(UploadFileItemViewHolder(this))
-        addItems(listOf(UploadFileItem(addBtn = true)))
-    }
-
-    fun addItems(items: List<UploadFileItem>) {
-        val leftCount = maxCount - (fileAdapter.itemCount - 1)
-        if (items.size >= leftCount) {
-            fileAdapter.removeFirst()
-            fileAdapter.addList(items.take(leftCount))
-        } else {
-            fileAdapter.addList(items)
-        }
-    }
-
-    fun getItems(): List<UploadFileItem> {
-        return fileAdapter.items.mapNotNull { (it as? UploadFileItem) }.filter { !it.addBtn }
-    }
-
-    override fun onAddClick() {
-        callback?.onAddFile()
-    }
-
-    override fun onDeleteClick(item: UploadFileItem) {
-        val shouldAddAddBtn = !hasAddBtn()
-        fileAdapter.remove(item)
-        if (shouldAddAddBtn) {
-            fileAdapter.addFirst(UploadFileItem(addBtn = true))
-        }
-    }
-
-    private fun hasAddBtn(): Boolean {
-        return fileAdapter.getItem(0)?.addBtn == true
-    }
-
-    override fun onPreviewClick(position: Int) {
-        val uriList = arrayListOf<String>()
-        val pathList = arrayListOf<String>()
-        uriList.addAll(getItems().mapNotNull { it.uri })
-        pathList.addAll(getItems().mapNotNull { it.path })
-        val realPhotoIndex = if (hasAddBtn()) {
-            position - 1
-        } else {
-            position
-        }
-        callback?.onPreview(uriList, pathList, realPhotoIndex)
-    }
-
-}

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно