Skip to content

Commit 412cdc1

Browse files
committed
fix: 리뷰 반영 — Exception 분기 단순화, error 상태 UI 처리 추가
- handleException: 불필요한 when 분기 제거, Timber.e() 단일 호출로 통합 - MyPageFragment.bindState(): error 상태 시 Snackbar 표시 추가
1 parent 92b0427 commit 412cdc1

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

app/src/main/java/com/runnect/runnect/presentation/base/MviViewModel.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ import kotlinx.coroutines.flow.asStateFlow
1313
import kotlinx.coroutines.flow.catch
1414
import kotlinx.coroutines.flow.onStart
1515
import kotlinx.coroutines.launch
16-
import retrofit2.HttpException
1716
import timber.log.Timber
18-
import java.net.SocketException
19-
import java.net.UnknownHostException
2017

2118
abstract class MviViewModel<STATE, INTENT, EFFECT>(
2219
initialState: STATE
@@ -70,11 +67,6 @@ abstract class MviViewModel<STATE, INTENT, EFFECT>(
7067
}
7168

7269
protected open fun handleException(throwable: Throwable) {
73-
when (throwable) {
74-
is SocketException,
75-
is HttpException,
76-
is UnknownHostException -> Timber.e(throwable)
77-
else -> Timber.e(throwable)
78-
}
70+
Timber.e(throwable)
7971
}
8072
}

app/src/main/java/com/runnect/runnect/presentation/mypage/MyPageFragment.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_RUNNING_RECORD
2828
import com.runnect.runnect.util.analytics.EventName.EVENT_CLICK_UPLOADED_COURSE
2929
import com.runnect.runnect.util.extension.getStampResId
3030
import com.runnect.runnect.util.extension.repeatOnStarted
31+
import com.runnect.runnect.util.extension.showSnackbar
3132
import dagger.hilt.android.AndroidEntryPoint
3233
import kotlinx.coroutines.flow.collectLatest
3334

@@ -109,7 +110,7 @@ class MyPageFragment : BaseVisitorFragment<FragmentMyPageBinding>(R.layout.fragm
109110
private fun bindState(state: MyPageUiState) {
110111
setLoadingState(state.isLoading)
111112

112-
if (!state.isLoading) {
113+
if (!state.isLoading && state.error == null) {
113114
with(binding) {
114115
tvMyPageUserName.text = state.nickname
115116
tvMyPageUserLv.text = state.level
@@ -121,6 +122,10 @@ class MyPageFragment : BaseVisitorFragment<FragmentMyPageBinding>(R.layout.fragm
121122
val stampResId = getStampResourceId()
122123
viewModel.intent(MyPageIntent.UpdateProfileImg(stampResId))
123124
}
125+
126+
state.error?.let {
127+
context?.showSnackbar(anchorView = binding.root, message = it)
128+
}
124129
}
125130

126131
private fun inquiryKakao() {

0 commit comments

Comments
 (0)