Skip to content

Commit

Permalink
#210 MyPage UserImage 에러 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Aug 21, 2023
1 parent be36bbe commit 3be8ae4
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ object BindingAdapter {
GlideApp.with(imageView.context).load(img).centerInside().skipMemoryCache(caching).into(imageView)
}

@BindingAdapter("loadUserImage", requireAll = false)
@BindingAdapter("loadUserImage")
@JvmStatic
fun loadUserImage(imageView: ImageView, img: String) {
if (img.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.android.mediproject.core.common.mapper
package com.android.mediproject.core.common.util

import android.content.Context
import android.graphics.Typeface
Expand All @@ -9,14 +9,14 @@ import android.text.style.ForegroundColorSpan
import android.text.style.RelativeSizeSpan
import android.text.style.StyleSpan
import android.text.style.UnderlineSpan
import androidx.core.content.ContentProviderCompat.requireContext
import androidx.core.content.ContextCompat
import com.android.mediproject.core.common.R
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class SpanProvider @Inject constructor() {

companion object {
private const val TEXT_SIZE_PERCENT = 1.2F
}
Expand Down Expand Up @@ -132,5 +132,4 @@ class SpanProvider @Inject constructor() {
setSpan(UnderlineSpan(), 4, 8, Spannable.SPAN_INCLUSIVE_INCLUSIVE)
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package com.android.mediproject.core.test.repositories

import com.android.mediproject.core.data.user.UserInfoRepository
import com.android.mediproject.core.model.user.AccountState
import com.android.mediproject.core.model.user.remote.UserResponse
import com.android.mediproject.core.model.user.User
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
Expand All @@ -14,7 +14,7 @@ class FakeUserInfoRepository : UserInfoRepository {
override val myAccountInfo: StateFlow<AccountState>
get() = _myAccountInfo.asStateFlow()

override fun getMyAccountInfo(): Flow<Result<UserResponse>> = channelFlow{
override fun getMyAccountInfo(): Flow<Result<User>> = channelFlow{
}

override suspend fun updateMyAccountInfo(accountState: AccountState){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import android.view.View
import androidx.core.os.bundleOf
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.android.mediproject.core.common.mapper.MedicineInfoMapper
import com.android.mediproject.core.common.mapper.SpanProvider
import com.android.mediproject.core.common.util.SpanProvider
import com.android.mediproject.core.common.util.SystemBarStyler
import com.android.mediproject.core.common.viewmodel.repeatOnStarted
import com.android.mediproject.core.ui.base.BaseFragment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
package com.android.mediproject.feature.mypage

import android.os.Bundle
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan
import android.text.style.UnderlineSpan
import android.view.View
import androidx.core.content.ContextCompat
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.android.mediproject.core.common.mapper.SpanProvider
import com.android.mediproject.core.common.bindingadapter.GlideApp
import com.android.mediproject.core.common.util.SpanProvider
import com.android.mediproject.core.common.util.SystemBarStyler
import com.android.mediproject.core.common.viewmodel.UiState
import com.android.mediproject.core.model.token.CurrentTokens
import com.android.mediproject.core.model.token.TokenState
import com.android.mediproject.core.ui.R
import com.android.mediproject.core.ui.base.BaseFragment
import com.android.mediproject.feature.mypage.databinding.FragmentMyPageBinding
import com.android.mediproject.feature.mypage.mypagemore.MyPageMoreBottomSheetFragment
Expand All @@ -23,6 +19,7 @@ import dagger.hilt.android.AndroidEntryPoint
import com.android.mediproject.core.common.viewmodel.repeatOnStarted
import com.android.mediproject.core.model.comments.MyCommentsListResponse
import com.android.mediproject.core.model.user.User
import com.bumptech.glide.Glide
import javax.inject.Inject

@AndroidEntryPoint
Expand All @@ -31,6 +28,7 @@ class MyPageFragment :

@Inject
lateinit var systemBarStyler: SystemBarStyler

@Inject
lateinit var spanProvider: SpanProvider

Expand All @@ -45,18 +43,18 @@ class MyPageFragment :
}

private fun setBinding() = binding.apply {
viewModel = fragmentViewModel.apply {
viewLifecycleOwner.apply {
repeatOnStarted { token.collect { handleToken(it) } }
repeatOnStarted { eventFlow.collect { handleEvent(it) } }
repeatOnStarted { user.collect { handleUserState(it) } }
repeatOnStarted { myCommentsList.collect { handleMyCommentListState(it) } }
}
loadTokens()
viewModel = fragmentViewModel.apply {
viewLifecycleOwner.apply {
repeatOnStarted { token.collect { handleToken(it) } }
repeatOnStarted { eventFlow.collect { handleEvent(it) } }
repeatOnStarted { user.collect { handleUserState(it) } }
repeatOnStarted { myCommentsList.collect { handleMyCommentListState(it) } }
}
setBarStyle()
setRecyclerView()
loadTokens()
}
setBarStyle()
setRecyclerView()
}

private fun handleToken(tokenState: TokenState<CurrentTokens>) {
log(tokenState.toString())
Expand Down Expand Up @@ -118,8 +116,7 @@ class MyPageFragment :

is UiState.Success -> {
setSuccessUserVisible()
binding.user = userState.data

updateUserInformation(userState.data)
}

is UiState.Error -> {
Expand All @@ -128,6 +125,14 @@ class MyPageFragment :
}
}

private fun updateUserInformation(newUserData: User) =binding.apply{
user = newUserData
if (newUserData.profileUrl.isEmpty()) {
userImageIV.setImageResource(com.android.mediproject.core.common.R.drawable.default_user_image)
return@apply
}
GlideApp.with(requireContext()).load(newUserData.profileUrl).circleCrop().into(userImageIV)
}

private fun setLoadingUserVisible() = binding.apply {
userNameTV.visibility = View.GONE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@ package com.android.mediproject.feature.mypage.mypagemore
import android.app.Dialog
import android.os.Bundle
import android.text.Editable
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.TextWatcher
import android.text.style.ForegroundColorSpan
import android.text.style.UnderlineSpan
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.setFragmentResult
import androidx.fragment.app.viewModels
import com.android.mediproject.core.common.mapper.SpanProvider
import com.android.mediproject.core.common.util.SpanProvider
import com.android.mediproject.core.ui.base.view.Subtitle.Companion.PASSWORD
import com.android.mediproject.feature.mypage.R
import com.android.mediproject.feature.mypage.databinding.FragmentMyPageMoreDialogBinding
Expand Down
1 change: 0 additions & 1 deletion feature/mypage/src/main/res/layout/fragment_my_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
loadUserImage="@{user.profileUrl}"
android:onClick="@{()->viewModel.clickMyImage()}"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
2 changes: 0 additions & 2 deletions feature/mypage/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
<string name="confirm">확인</string>
<string name="cancel">취소</string>

<string name="logoutDescription">정말로 로그아웃을 원하신다면 완료 버튼을 눌러주세요.</string>
<string name="withdrawalDescription">정말로 회원탈퇴를 원하신다면 “회원탈퇴”를 입력한 뒤, 완료 버튼을 눌러주세요.</string>
<string name="withdrawalHint">\"회원탈퇴\"</string>

<string name="complete">완료</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import android.os.Bundle
import android.view.View
import androidx.fragment.app.viewModels
import androidx.navigation.fragment.findNavController
import com.android.mediproject.core.common.mapper.MedicineInfoMapper
import com.android.mediproject.core.common.mapper.SpanProvider
import com.android.mediproject.core.common.util.SpanProvider
import com.android.mediproject.core.common.util.deepNavigate
import com.android.mediproject.core.common.util.navigateByDeepLink
import com.android.mediproject.core.common.viewmodel.UiState
Expand Down

0 comments on commit 3be8ae4

Please sign in to comment.