From 3b58e60c09e04e0803c031badb575d7118fee9f1 Mon Sep 17 00:00:00 2001 From: Jokwanhee Date: Mon, 6 May 2024 13:41:29 +0900 Subject: [PATCH] =?UTF-8?q?[mod]=20#151=20=EC=9C=A0=EC=A0=80=20=ED=83=80?= =?UTF-8?q?=EC=9E=85=EC=97=90=20=EB=A7=9E=EA=B2=8C=20=EC=95=84=EC=9D=B4?= =?UTF-8?q?=EC=BD=98=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/response/home/ResponseHomeDto.kt | 3 +++ .../motivoo/domain/entity/home/HomeData.kt | 1 + .../motivoo/presentation/home/HomeFragment.kt | 6 +++--- app/src/main/res/layout/fragment_home.xml | 3 ++- .../motivoo_design/MotivooOtherPieChart.kt | 2 ++ .../android/motivoo_design/MotivooPieChart.kt | 2 ++ .../motivoo_design/MotivooStepCountText.kt | 19 +++++++++++++++---- .../com/android/utils/BitmapCacheManager.kt | 2 ++ motivoo_design/src/main/res/values/attrs.xml | 4 ++++ 9 files changed, 34 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/sopt/motivoo/data/model/response/home/ResponseHomeDto.kt b/app/src/main/java/sopt/motivoo/data/model/response/home/ResponseHomeDto.kt index 2f0bc3f3..7168ffe0 100644 --- a/app/src/main/java/sopt/motivoo/data/model/response/home/ResponseHomeDto.kt +++ b/app/src/main/java/sopt/motivoo/data/model/response/home/ResponseHomeDto.kt @@ -19,6 +19,8 @@ data class ResponseHomeDto( data class ResponseHomeDataDto( @SerialName("user_type") val userType: String, + @SerialName("opponent_user_type") + val opponentUserType: String, @SerialName("user_id") val userId: Long, @SerialName("user_goal_step_count") @@ -37,6 +39,7 @@ data class ResponseHomeDto( fun toHomeData(): HomeData = HomeData( userType = data.userType, + opponentUserType = data.opponentUserType, userId = data.userId, userGoalStepCount = data.userGoalStepCount, opponentUserGoalStepCount = data.opponentUserGoalStepCount, diff --git a/app/src/main/java/sopt/motivoo/domain/entity/home/HomeData.kt b/app/src/main/java/sopt/motivoo/domain/entity/home/HomeData.kt index 13be2aef..0d4385dc 100644 --- a/app/src/main/java/sopt/motivoo/domain/entity/home/HomeData.kt +++ b/app/src/main/java/sopt/motivoo/domain/entity/home/HomeData.kt @@ -2,6 +2,7 @@ package sopt.motivoo.domain.entity.home data class HomeData( val userType: String, + val opponentUserType: String, val userId: Long, val userGoalStepCount: Int, val opponentUserId: Long, diff --git a/app/src/main/java/sopt/motivoo/presentation/home/HomeFragment.kt b/app/src/main/java/sopt/motivoo/presentation/home/HomeFragment.kt index e9a7f5e8..e4f1329c 100644 --- a/app/src/main/java/sopt/motivoo/presentation/home/HomeFragment.kt +++ b/app/src/main/java/sopt/motivoo/presentation/home/HomeFragment.kt @@ -109,9 +109,9 @@ class HomeFragment : BindingFragment(R.layout.fragment_home requireContext().getString(R.string.home_parent) -> Parent else -> null } - viewModel.anotherUserType.value = when (homeState.homeData.userType) { - requireContext().getString(R.string.home_child) -> Parent - requireContext().getString(R.string.home_parent) -> Child + viewModel.anotherUserType.value = when (homeState.homeData.opponentUserType) { + requireContext().getString(R.string.home_child) -> Child + requireContext().getString(R.string.home_parent) -> Parent else -> null } diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index f66b8452..fbd96686 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -206,7 +206,8 @@ app:layout_constraintTop_toBottomOf="@id/iv_mission_completed" app:myStepCountText="@{String.valueOf(vm.stepCount)}" app:otherStepCountText="@{String.valueOf(vm.otherStepCount)}" - app:userType="@{vm.userType}" /> + app:userType="@{vm.userType}" + app:otherUserType="@{vm.anotherUserType}"/> { binding.tvStepCountTitle.text = context.getString(R.string.home_my_step_count) - binding.tvOtherStepCountTitle.text = - context.getString(R.string.home_parent_step_count) } Parent -> { binding.tvStepCountTitle.text = context.getString(R.string.home_my_step_count) - binding.tvOtherStepCountTitle.text = - context.getString(R.string.home_child_step_count) } else -> Unit @@ -38,6 +34,20 @@ class MotivooStepCountText @JvmOverloads constructor( field = value } + var otherUserType: MotivooUserType? = null + set(value) { + when (value) { + Child -> binding.tvOtherStepCountTitle.text = + context.getString(R.string.home_child_step_count) + + Parent -> binding.tvOtherStepCountTitle.text = + context.getString(R.string.home_parent_step_count) + + else -> Unit + } + field = value + } + init { initView() context.theme.obtainStyledAttributes( @@ -47,6 +57,7 @@ class MotivooStepCountText @JvmOverloads constructor( binding.tvOtherStepCount.text = getString(R.styleable.MotivooStepCountText_otherStepCountText) userType = getInt(R.styleable.MotivooStepCountText_userType, 0).toMotivooUserType + otherUserType = getInt(R.styleable.MotivooStepCountText_otherStepCountText, 0).toMotivooUserType recycle() } } diff --git a/motivoo_design/src/main/java/com/android/utils/BitmapCacheManager.kt b/motivoo_design/src/main/java/com/android/utils/BitmapCacheManager.kt index bb7e5d2d..ac22aacb 100644 --- a/motivoo_design/src/main/java/com/android/utils/BitmapCacheManager.kt +++ b/motivoo_design/src/main/java/com/android/utils/BitmapCacheManager.kt @@ -30,6 +30,8 @@ class BitmapCacheManager( bitmapCache.get(key) } + fun removeBitmapFromMemoryCache(key: String) = bitmapCache.remove(key) + companion object { const val MY_IMAGE = "MY_IMAGE" const val OTHER_IMAGE = "OTHER_IMAGE" diff --git a/motivoo_design/src/main/res/values/attrs.xml b/motivoo_design/src/main/res/values/attrs.xml index 240036c4..7f61c865 100644 --- a/motivoo_design/src/main/res/values/attrs.xml +++ b/motivoo_design/src/main/res/values/attrs.xml @@ -15,6 +15,10 @@ + + + +