|
@@ -13,9 +13,11 @@ import com.develop.base.ext.navigateTo
|
|
|
import com.develop.base.ext.resId2Dimension
|
|
|
import com.develop.base.manager.WifiHelp
|
|
|
import com.develop.base.widgets.CommonPopupWindow
|
|
|
+import com.develop.common.data_repo.FoodDataProvider
|
|
|
import com.develop.common.data_repo.db.DataFactory
|
|
|
import com.develop.common.data_repo.db.FunType
|
|
|
import com.develop.common.data_repo.db.RecipesType
|
|
|
+import com.develop.common.data_repo.db.entity.UserInfo
|
|
|
import com.develop.common.router.Screens
|
|
|
import com.develop.common.tag.*
|
|
|
import com.develop.common.ui.CommonBVMActivity
|
|
@@ -193,7 +195,6 @@ class HomeActivity : CommonBVMActivity<ActivityHomeBinding, HomeViewModel>() {
|
|
|
}
|
|
|
|
|
|
binding.policyLayout.setOnClickListener {
|
|
|
-
|
|
|
val bundle = Bundle()
|
|
|
bundle.putBoolean(POLICY_FROM_MAIN_SETTING, true)
|
|
|
navigateTo(Screens.Setting.POLICY) {
|
|
@@ -209,6 +210,38 @@ class HomeActivity : CommonBVMActivity<ActivityHomeBinding, HomeViewModel>() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun updateUserInfoUi(userInfo: UserInfo?) {
|
|
|
+ if (userInfo?.userName != null) {
|
|
|
+ binding.functionTopBar.setUserName(userInfo.userName ?: "")
|
|
|
+ binding.tvUserName.text = userInfo.userName ?: ""
|
|
|
+ val icon = when (userInfo.userAvatar?.toInt() ?: 0) {
|
|
|
+ 0 -> {
|
|
|
+ com.develop.common.R.drawable.ic_icon1
|
|
|
+ }
|
|
|
+ 1 -> {
|
|
|
+ com.develop.common.R.drawable.ic_icon2
|
|
|
+ }
|
|
|
+ 2 -> {
|
|
|
+ com.develop.common.R.drawable.ic_icon3
|
|
|
+ }
|
|
|
+ 3 -> {
|
|
|
+ com.develop.common.R.drawable.ic_icon4
|
|
|
+ }
|
|
|
+ 4 -> {
|
|
|
+ com.develop.common.R.drawable.ic_icon5
|
|
|
+ }
|
|
|
+ else -> {
|
|
|
+ com.develop.common.R.drawable.ic_icon6
|
|
|
+ }
|
|
|
+ }
|
|
|
+ binding.ivAvatar.setImageResource(icon)
|
|
|
+ } else {
|
|
|
+ binding.ivAvatar.setImageResource(com.develop.common.R.drawable.ic_icon1)
|
|
|
+ binding.functionTopBar.setUserName(getString(com.develop.common.R.string.login))
|
|
|
+ binding.tvUserName.text = getString(com.develop.common.R.string.login)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
companion object {
|
|
|
var dp1080 = (com.develop.base.R.dimen.convert_1080px).resId2Dimension().toInt()
|
|
|
var dp160 = (com.develop.base.R.dimen.convert_160px).resId2Dimension().toInt()
|
|
@@ -218,6 +251,11 @@ class HomeActivity : CommonBVMActivity<ActivityHomeBinding, HomeViewModel>() {
|
|
|
override fun onResume() {
|
|
|
super.onResume()
|
|
|
wifiHelp.scan()
|
|
|
+ val userInfo = FoodDataProvider
|
|
|
+ .getUserDatabase()
|
|
|
+ .userInfoDao()
|
|
|
+ .queryUserInfoByUserId(CURRENT_USER_ID)
|
|
|
+ updateUserInfoUi(userInfo)
|
|
|
}
|
|
|
|
|
|
override fun onDestroy() {
|