|
|
@@ -11,15 +11,11 @@ import androidx.fragment.app.viewModels
|
|
|
import androidx.lifecycle.Observer
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import androidx.viewpager2.widget.ViewPager2
|
|
|
-import com.adealink.frame.aab.AAB
|
|
|
import com.adealink.frame.aab.util.getCompatString
|
|
|
import com.adealink.frame.base.fastLazy
|
|
|
import com.adealink.frame.data.json.froJsonErrorNull
|
|
|
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
|
|
|
@@ -30,29 +26,16 @@ 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.constant.TAG_ANCHOR
|
|
|
import com.adealink.weparty.module.anchor.data.AnchorMessage
|
|
|
import com.adealink.weparty.module.anchor.data.AnchorMessageReplyCode
|
|
|
import com.adealink.weparty.module.anchor.data.AnchorMessageTemplateBody
|
|
|
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.certification.CertificationModule
|
|
|
-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
|
|
|
import com.adealink.weparty.module.message.Message
|
|
|
@@ -61,18 +44,11 @@ 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
|
|
|
import com.adealink.weparty.ui.home.util.HomeLocalService
|
|
|
import com.adealink.weparty.ui.home.util.HomeUIUtil
|
|
|
@@ -80,8 +56,6 @@ 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
|
|
|
|
|
|
@@ -97,16 +71,10 @@ 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 anchorViewModel by fastLazy { AnchorModule.getAnchorViewModel(this.requireActivity()) }
|
|
|
private val medalViewModel by fastLazy { MedalModule.getMedalViewModel(this) }
|
|
|
- protected val operationViewModel by fastLazy { OperationModule.getOperationViewModel(this.requireActivity()) }
|
|
|
- private val countryViewModel by fastLazy { ProfileModule.getCountryViewModel(this) }
|
|
|
- private val walletViewModel by fastLazy { WalletModule.getWalletViewModel(requireActivity()) }
|
|
|
-
|
|
|
-
|
|
|
+ private val operationViewModel by fastLazy { OperationModule.getOperationViewModel(this.requireActivity()) }
|
|
|
private lateinit var homePagerAdapter: HomeProfilePageAdapter
|
|
|
private val gestureDetector: GestureDetector by lazy {
|
|
|
GestureDetector(context, object : GestureDetector.SimpleOnGestureListener() {
|
|
|
@@ -189,6 +157,14 @@ 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,
|
|
|
@@ -208,94 +184,7 @@ abstract class BaseHomeFragment : BaseFragment, ITabManager {
|
|
|
|
|
|
open fun onConfigureTab(tab: Tab, binding: LayoutMainTabNormalBinding) {}
|
|
|
|
|
|
- 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)
|
|
|
- walletViewModel?.checkThirdPayOpen()
|
|
|
-// installDynamicModule()
|
|
|
- }
|
|
|
-
|
|
|
- // 启动后,交给Google Play,延迟安装所有模块(后台自动下载)
|
|
|
- private fun installDynamicModule() {
|
|
|
- AAB.deferredInstall(
|
|
|
- listOf(
|
|
|
- CertificationModule.featureName
|
|
|
- )
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- 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 //初始化
|
|
|
- }
|
|
|
+ private var homeBannerEntranceFloatViewComp: HomeBannerEntranceFloatViewComp? = null
|
|
|
|
|
|
override fun observeViewModel() {
|
|
|
super.observeViewModel()
|
|
|
@@ -306,17 +195,6 @@ abstract class BaseHomeFragment : BaseFragment, ITabManager {
|
|
|
}
|
|
|
}
|
|
|
)
|
|
|
- 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) {
|
|
|
@@ -334,6 +212,13 @@ abstract class BaseHomeFragment : BaseFragment, ITabManager {
|
|
|
}
|
|
|
}
|
|
|
)
|
|
|
+ operationViewModel?.rateAppNotifyLD?.observe(viewLifecycleOwner,
|
|
|
+ object : Observer<Unit> {
|
|
|
+ override fun onChanged(value: Unit) {
|
|
|
+ showRateAppDialog()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
private fun handleAnchorMessage(message: AnchorMessage) {
|
|
|
@@ -347,7 +232,7 @@ abstract class BaseHomeFragment : BaseFragment, ITabManager {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- AnchorMessageType.USER_CHANGE_GENDER->{
|
|
|
+ AnchorMessageType.USER_CHANGE_GENDER -> {
|
|
|
val messageBody = froJsonErrorNull<AnchorMessageTemplateBody>(message.messageBody)
|
|
|
if (messageBody == null) {
|
|
|
Log.e(TAG_ANCHOR, "消息体解析失败")
|
|
|
@@ -392,18 +277,6 @@ 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 ""
|
|
|
@@ -437,7 +310,7 @@ abstract class BaseHomeFragment : BaseFragment, ITabManager {
|
|
|
}
|
|
|
}.apply {
|
|
|
//把数据传递给子Fragment
|
|
|
- arguments=Bundle().apply {
|
|
|
+ arguments = Bundle().apply {
|
|
|
putString(AppModule.Main.EXTRA_MAIN_SUB_TAB, subTabKey)
|
|
|
}
|
|
|
}
|