|
|
@@ -14,6 +14,9 @@ import androidx.viewpager2.widget.ViewPager2
|
|
|
import com.adealink.frame.base.fastLazy
|
|
|
import com.adealink.frame.log.Log
|
|
|
import com.adealink.frame.router.Router
|
|
|
+import com.adealink.frame.util.AppUtil
|
|
|
+import com.adealink.frame.util.removeUiCallbacks
|
|
|
+import com.adealink.frame.util.runOnUiThread
|
|
|
import com.adealink.weparty.AppModule
|
|
|
import com.adealink.weparty.R
|
|
|
import com.adealink.weparty.commonui.BaseFragment
|
|
|
@@ -21,10 +24,27 @@ import com.adealink.weparty.commonui.dialogchain.DialogTaskManager
|
|
|
import com.adealink.weparty.commonui.dialogchain.dialogtask.MedalAchieveDialogTask
|
|
|
import com.adealink.weparty.commonui.dialogfragment.BaseDialogFragment
|
|
|
import com.adealink.weparty.commonui.recycleview.adapter.BaseTabFragmentStateAdapter
|
|
|
+import com.adealink.weparty.commonui.toast.util.showToast
|
|
|
import com.adealink.weparty.commonui.widget.EmptyFragment
|
|
|
+import com.adealink.weparty.config.globalConfigManager
|
|
|
import com.adealink.weparty.databinding.LayoutMainTabNormalBinding
|
|
|
import com.adealink.weparty.location.constant.TAG_LOCATION_REPORT
|
|
|
import com.adealink.weparty.location.viewmodel.LocationViewModel
|
|
|
+import com.adealink.weparty.log.manager.logManager
|
|
|
+import com.adealink.weparty.module.account.AccountModule
|
|
|
+import com.adealink.weparty.module.anchor.AnchorModule
|
|
|
+import com.adealink.weparty.module.anchor.data.AnchorMessage
|
|
|
+import com.adealink.weparty.module.anchor.data.AnchorMessageReplyCode
|
|
|
+import com.adealink.weparty.module.anchor.data.AnchorMessageType
|
|
|
+import com.adealink.weparty.module.anchor.data.FromScene
|
|
|
+import com.adealink.weparty.module.backpack.BackpackModule
|
|
|
+import com.adealink.weparty.module.couple.CoupleModule
|
|
|
+import com.adealink.weparty.module.emotion.EmotionModule
|
|
|
+import com.adealink.weparty.module.family.FamilyModule
|
|
|
+import com.adealink.weparty.module.game.GameModule
|
|
|
+import com.adealink.weparty.module.gift.GiftModule
|
|
|
+import com.adealink.weparty.module.level.LevelModule
|
|
|
+import com.adealink.weparty.module.level.data.TAG_LEVEL
|
|
|
import com.adealink.weparty.module.medal.Medal
|
|
|
import com.adealink.weparty.module.medal.MedalModule
|
|
|
import com.adealink.weparty.module.medal.data.MedalData
|
|
|
@@ -34,10 +54,16 @@ import com.adealink.weparty.module.operation.Operation
|
|
|
import com.adealink.weparty.module.operation.OperationModule
|
|
|
import com.adealink.weparty.module.operation.newuser.HomeBannerEntranceFloatViewComp
|
|
|
import com.adealink.weparty.module.profile.Profile
|
|
|
+import com.adealink.weparty.module.profile.ProfileModule
|
|
|
import com.adealink.weparty.module.room.Room
|
|
|
+import com.adealink.weparty.module.room.RoomModule
|
|
|
+import com.adealink.weparty.module.skin.SkinModule
|
|
|
import com.adealink.weparty.module.task.DailySignInComp
|
|
|
import com.adealink.weparty.module.task.HomeIncomeViewComp
|
|
|
import com.adealink.weparty.module.task.HomeTaskCountDownViewComp
|
|
|
+import com.adealink.weparty.module.task.RoomTaskMonitor
|
|
|
+import com.adealink.weparty.module.task.UserTaskManager
|
|
|
+import com.adealink.weparty.module.task.invite.InviteRewardManager
|
|
|
import com.adealink.weparty.module.userlist.UserList
|
|
|
import com.adealink.weparty.module.wallet.WalletModule
|
|
|
import com.adealink.weparty.ui.IScrollManager
|
|
|
@@ -47,6 +73,8 @@ import com.adealink.weparty.ui.tab.HOME_TABS
|
|
|
import com.adealink.weparty.ui.tab.HomeTab
|
|
|
import com.adealink.weparty.ui.tab.ITabManager
|
|
|
import com.adealink.weparty.ui.tab.Tab
|
|
|
+import com.adealink.weparty.webview.manager.PreloadWebViewManager
|
|
|
+import com.adealink.weparty.webview.manager.PreloadWebViewWorker
|
|
|
import com.google.android.material.tabs.TabLayout
|
|
|
import com.google.android.material.tabs.TabLayoutMediator
|
|
|
|
|
|
@@ -62,9 +90,14 @@ abstract class BaseHomeFragment : BaseFragment, ITabManager {
|
|
|
abstract val vpContent: ViewPager2
|
|
|
abstract val tlTab: TabLayout
|
|
|
|
|
|
+ protected val roomAttrViewModel by fastLazy { RoomModule.getRoomAttrViewModel(this.requireActivity()) }
|
|
|
private val locationViewModel by viewModels<LocationViewModel>()
|
|
|
+ private val anchorViewModel by fastLazy { AnchorModule.getAnchorViewModel(this) }
|
|
|
+ private val familyInfoViewModel by fastLazy { FamilyModule.getFamilyInfoViewModel(this.requireActivity()) }
|
|
|
private val medalViewModel by fastLazy { MedalModule.getMedalViewModel(this) }
|
|
|
- private val operationViewModel by fastLazy { OperationModule.getOperationViewModel(this.requireActivity()) }
|
|
|
+ protected val operationViewModel by fastLazy { OperationModule.getOperationViewModel(this.requireActivity()) }
|
|
|
+ private val countryViewModel by fastLazy { ProfileModule.getCountryViewModel(this) }
|
|
|
+
|
|
|
private lateinit var homePagerAdapter: HomeProfilePageAdapter
|
|
|
private val gestureDetector: GestureDetector by lazy {
|
|
|
GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
|
|
|
@@ -147,14 +180,6 @@ abstract class BaseHomeFragment : BaseFragment, ITabManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- override fun initComponents() {
|
|
|
- super.initComponents()
|
|
|
- homeBannerEntranceFloatViewComp = HomeBannerEntranceFloatViewComp(this).also { it.attach() }
|
|
|
- HomeTaskCountDownViewComp(this).attach()
|
|
|
- HomeIncomeViewComp(this).attach()
|
|
|
- DailySignInComp(this).attach()
|
|
|
- }
|
|
|
-
|
|
|
fun updateTabView(
|
|
|
tabView: TabLayout.Tab?,
|
|
|
isSelected: Boolean,
|
|
|
@@ -174,10 +199,103 @@ abstract class BaseHomeFragment : BaseFragment, ITabManager {
|
|
|
|
|
|
open fun onConfigureTab(tab: Tab, binding: LayoutMainTabNormalBinding) {}
|
|
|
|
|
|
- private var homeBannerEntranceFloatViewComp: HomeBannerEntranceFloatViewComp? = null
|
|
|
+ private val importantLoad by fastLazy {
|
|
|
+ Runnable {
|
|
|
+ importantLoad()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @CallSuper
|
|
|
+ open fun importantLoad() {
|
|
|
+ AccountModule.refreshToken()
|
|
|
+ roomAttrViewModel?.getMyRoomInfo(true)
|
|
|
+// anchorViewModel?.getAnchorMessages()
|
|
|
+ OperationModule.checkSuperSupporterWhatsAppFillStatus()
|
|
|
+ BackpackModule.checkGiftBackpack()
|
|
|
+ RoomModule.init()
|
|
|
+ GameModule.checkPlayingGame()
|
|
|
+ countryViewModel?.getCountryList(true)
|
|
|
+ }
|
|
|
+
|
|
|
+ private val minorLoad by fastLazy {
|
|
|
+ Runnable {
|
|
|
+ minorLoad()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @CallSuper
|
|
|
+ open fun minorLoad() {
|
|
|
+ WalletModule.fetchCurrency()
|
|
|
+ WalletModule.queryAndHandleUnDealPurchases()
|
|
|
+ LevelModule.pullLevelConfigs()
|
|
|
+ CoupleModule.pullCoupleConfig()
|
|
|
+ ProfileModule.reportPhoneModel(FromScene.STARTUP.scene)
|
|
|
+ WalletModule.init()
|
|
|
+ FamilyModule.pullFamilyLevelConfig()
|
|
|
+ ProfileModule.pullUserNoteNameData()
|
|
|
+ }
|
|
|
+
|
|
|
+ private val otherLoad by fastLazy {
|
|
|
+ Runnable {
|
|
|
+ otherLoad()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private var homeBannerEntranceFloatViewComp:HomeBannerEntranceFloatViewComp?=null
|
|
|
+
|
|
|
+ @CallSuper
|
|
|
+ open fun otherLoad() {
|
|
|
+ GiftModule.getGifts(true)
|
|
|
+ EmotionModule.getEmotionPackages(true)
|
|
|
+ MedalModule.init()
|
|
|
+ OperationModule.init()
|
|
|
+ SkinModule.getCurrentSkin(true)
|
|
|
+ familyInfoViewModel?.getApplyJoinFamilyUnHandleNum()
|
|
|
+
|
|
|
+ //todo:先放延迟加载
|
|
|
+ UserTaskManager.refreshTaskConfig()
|
|
|
+ HomeTaskCountDownViewComp(this).attach()
|
|
|
+ HomeIncomeViewComp(this).attach()
|
|
|
+ DailySignInComp(this).attach()
|
|
|
+ homeBannerEntranceFloatViewComp = HomeBannerEntranceFloatViewComp(this)
|
|
|
+ homeBannerEntranceFloatViewComp?.attach()
|
|
|
+
|
|
|
+ preloadWebViewResource()
|
|
|
+ ProfileModule.checkChatAchievement()
|
|
|
+ }
|
|
|
+
|
|
|
+ @CallSuper
|
|
|
+ override fun loadData() {
|
|
|
+ globalConfigManager.getAllGlobalConfig(true)
|
|
|
+ logManager.subscribeReportLogNotify()
|
|
|
+ runOnUiThread(importantLoad)
|
|
|
+ runOnUiThread(minorLoad, 2000L)
|
|
|
+ runOnUiThread(otherLoad, 3000L)
|
|
|
+ UserTaskManager.init()//初始化
|
|
|
+ InviteRewardManager.init()//初始化
|
|
|
+ RoomTaskMonitor //初始化
|
|
|
+ }
|
|
|
|
|
|
override fun observeViewModel() {
|
|
|
super.observeViewModel()
|
|
|
+ anchorViewModel?.anchorMessageLD?.observe(viewLifecycleOwner,
|
|
|
+ object : Observer<AnchorMessage> {
|
|
|
+ override fun onChanged(value: AnchorMessage) {
|
|
|
+ handleAnchorMessage(value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ observeMedal()
|
|
|
+ operationViewModel?.rateAppNotifyLD?.observe(viewLifecycleOwner,
|
|
|
+ object : Observer<Unit> {
|
|
|
+ override fun onChanged(value: Unit) {
|
|
|
+ showRateAppDialog()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun observeMedal() {
|
|
|
medalViewModel?.medalAchieveLiveData?.observe(viewLifecycleOwner,
|
|
|
object : Observer<MedalData> {
|
|
|
override fun onChanged(it: MedalData) {
|
|
|
@@ -195,13 +313,23 @@ abstract class BaseHomeFragment : BaseFragment, ITabManager {
|
|
|
}
|
|
|
}
|
|
|
)
|
|
|
- operationViewModel?.rateAppNotifyLD?.observe(viewLifecycleOwner,
|
|
|
- object : Observer<Unit> {
|
|
|
- override fun onChanged(value: Unit) {
|
|
|
- showRateAppDialog()
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun handleAnchorMessage(message: AnchorMessage) {
|
|
|
+ when (AnchorMessageType.map(message.messageType)) {
|
|
|
+ AnchorMessageType.SUPER_GIFT_ENERGY_BOX, AnchorMessageType.MESSAGE_BECOME_SUPER_SUPPORTER -> {
|
|
|
+ OperationModule.handleOperationMessage(
|
|
|
+ childFragmentManager,
|
|
|
+ message
|
|
|
+ ) { msg, replayCode ->
|
|
|
+ replyAnchorMessage(msg, replayCode)
|
|
|
}
|
|
|
}
|
|
|
- )
|
|
|
+
|
|
|
+ else -> {
|
|
|
+ Log.d(TAG_LEVEL, "handleAnchorMessage: $message")
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private fun showRateAppDialog() {
|
|
|
@@ -211,6 +339,13 @@ abstract class BaseHomeFragment : BaseFragment, ITabManager {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ private fun replyAnchorMessage(message: AnchorMessage, replyCode: AnchorMessageReplyCode) {
|
|
|
+ anchorViewModel?.replyAnchorMessage(message.messageId, message.messageType, replyCode)
|
|
|
+ ?.observe(viewLifecycleOwner) {
|
|
|
+ showToast(it)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
|
|
super.onActivityCreated(savedInstanceState)
|
|
|
locationViewModel.reportLocation().observe(viewLifecycleOwner) {
|
|
|
@@ -218,6 +353,18 @@ abstract class BaseHomeFragment : BaseFragment, ITabManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun preloadWebViewResource() {
|
|
|
+ PreloadWebViewWorker.startPreloadWorker(AppUtil.appContext)
|
|
|
+ }
|
|
|
+
|
|
|
+ override fun onDestroy() {
|
|
|
+ super.onDestroy()
|
|
|
+ removeUiCallbacks(importantLoad)
|
|
|
+ removeUiCallbacks(minorLoad)
|
|
|
+ removeUiCallbacks(otherLoad)
|
|
|
+ PreloadWebViewManager.destroy()
|
|
|
+ }
|
|
|
+
|
|
|
internal inner class HomeProfilePageAdapter : BaseTabFragmentStateAdapter(this) {
|
|
|
override fun getTabName(pos: Int): String {
|
|
|
return ""
|
|
|
@@ -251,7 +398,7 @@ abstract class BaseHomeFragment : BaseFragment, ITabManager {
|
|
|
}
|
|
|
}.apply {
|
|
|
//把数据传递给子Fragment
|
|
|
- arguments = Bundle().apply {
|
|
|
+ arguments=Bundle().apply {
|
|
|
putString(AppModule.Main.EXTRA_MAIN_SUB_TAB, subTabKey)
|
|
|
}
|
|
|
}
|