Skip to content

Commit

Permalink
[mod] 코드리뷰 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
Sangwook123 committed Dec 21, 2023
1 parent dd0c643 commit bc88e5f
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.go.sopt.winey.presentation.main.feed.detail.DetailActivity
import org.go.sopt.winey.presentation.main.mypage.MyPageFragment
import org.go.sopt.winey.presentation.main.mypage.MypageHelpActivity
import org.go.sopt.winey.presentation.main.recommend.RecommendFragment
import org.go.sopt.winey.presentation.model.NotificationType
import org.go.sopt.winey.presentation.onboarding.login.LoginActivity
import org.go.sopt.winey.util.binding.BindingActivity
import org.go.sopt.winey.util.context.snackBar
Expand Down Expand Up @@ -51,18 +52,22 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
}

private fun initNotiTypeHandler() {
when (notiType) {
KEY_RANKUP_TO_2, KEY_RANKUP_TO_3, KEY_RANKUP_TO_4 -> navigateToMyPageWithBundle(KEY_FROM_NOTI, true)
KEY_RANKDOWN_TO_1, KEY_RANKDOWN_TO_2, KEY_RANKDOWN_TO_3 -> navigateToMyPageWithBundle(
val notificationType = NotificationType.values().find { it.key == notiType }
when (notificationType) {
NotificationType.RANK_UP_TO_2, NotificationType.RANK_UP_TO_3, NotificationType.RANK_UP_TO_4 -> navigateToMyPageWithBundle(
KEY_FROM_NOTI,
true
)

KEY_GOAL_FAILED -> navigateToMyPageWithBundle(KEY_FROM_NOTI, true)
KEY_LIKE_NOTI -> navigateToDetail(feedId?.toInt())
KEY_COMMENT_NOTI -> navigateToDetail(feedId?.toInt())
KEY_HOW_TO_LEVELUP -> navigateToLevelupHelp()
else -> null
NotificationType.RANK_DOWN_TO_1, NotificationType.RANK_DOWN_TO_2, NotificationType.RANK_DOWN_TO_3 -> navigateToMyPageWithBundle(
KEY_FROM_NOTI,
true
)

NotificationType.GOAL_FAILED -> navigateToMyPageWithBundle(KEY_FROM_NOTI, true)
NotificationType.LIKE_NOTIFICATION -> navigateToDetail(feedId?.toInt())
NotificationType.COMMENT_NOTIFICATION -> navigateToDetail(feedId?.toInt())
else -> navigateToLevelupHelp()
}
}

Expand Down Expand Up @@ -182,23 +187,6 @@ class MainActivity : BindingActivity<ActivityMainBinding>(R.layout.activity_main
private const val KEY_TO_MYFEED = "toMyFeed"
private const val KEY_TO_MYPAGE = "navigateMypage"

private const val KEY_RANKUP_TO_2 = "RANKUPTO2"
private const val KEY_RANKUP_TO_3 = "RANKUPTO3"
private const val KEY_RANKUP_TO_4 = "RANKUPTO4"

private const val KEY_RANKDOWN_TO_1 = "DELETERANKDOWNTO1"
private const val KEY_RANKDOWN_TO_2 = "DELETERANKDOWNTO2"
private const val KEY_RANKDOWN_TO_3 = "DELETERANKDOWNTO3"

private const val KEY_GOAL_FAILED = "GOALFAILED"
private const val KEY_LIKE_NOTI = "LIKENOTI"
private const val KEY_COMMENT_NOTI = "COMMENTNOTI"
private const val KEY_HOW_TO_LEVELUP = "HOWTOLEVELUP"

private const val MY_FEED_SCREEN = "MyFeedFragment"
private const val KEY_FEED_UPLOAD = "upload"
private const val KEY_FEED_DELETE = "delete"
private const val KEY_PREV_SCREEN_NAME = "PREV_SCREEN_NAME"
private const val VAL_MY_FEED_SCREEN = "MyFeedFragment"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class MainViewModel @Inject constructor(
.onFailure { t ->
if (t is HttpException) {
Timber.e("HTTP 실패 ${t.code()}")
if (t.code() == CODE_TOKEN_EXPIRED) {
if (t.code() == CODE_TOKEN_EXPIRED || t.code() == CODE_INVALID_USER) {
postLogout()
}
}
Expand Down Expand Up @@ -117,9 +117,7 @@ class MainViewModel @Inject constructor(
fun patchFcmToken() {
viewModelScope.launch {
val token = dataStoreRepository.getDeviceToken().first()
if (token.isNullOrBlank()) {
return@launch
}
if (token.isNullOrBlank()) return@launch
authRepository.patchFcmToken(token)
.onSuccess {
Timber.e("디바이스 토큰 보내기 성공")
Expand All @@ -135,5 +133,6 @@ class MainViewModel @Inject constructor(

companion object {
private const val CODE_TOKEN_EXPIRED = 401
private const val CODE_INVALID_USER = 404
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import org.go.sopt.winey.presentation.main.feed.upload.UploadActivity
import org.go.sopt.winey.presentation.main.mypage.MyPageFragment
import org.go.sopt.winey.presentation.main.notification.NotificationActivity
import org.go.sopt.winey.presentation.model.WineyDialogLabel
import org.go.sopt.winey.presentation.onboarding.login.LoginActivity
import org.go.sopt.winey.util.activity.showReportGoogleForm
import org.go.sopt.winey.util.amplitude.AmplitudeUtils
import org.go.sopt.winey.util.amplitude.type.EventType
Expand Down Expand Up @@ -333,9 +332,6 @@ class WineyFeedFragment :
}

is UiState.Failure -> {
val intent = Intent(requireActivity(), LoginActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
snackBar(binding.root) { state.msg }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import org.go.sopt.winey.presentation.main.notification.NotificationActivity
import org.go.sopt.winey.presentation.model.WineyDialogLabel
import org.go.sopt.winey.presentation.nickname.NicknameActivity
import org.go.sopt.winey.presentation.onboarding.guide.GuideActivity
import org.go.sopt.winey.presentation.onboarding.login.LoginActivity
import org.go.sopt.winey.util.amplitude.AmplitudeUtils
import org.go.sopt.winey.util.binding.BindingFragment
import org.go.sopt.winey.util.fragment.WineyDialogFragment
Expand Down Expand Up @@ -110,26 +109,26 @@ class MyPageFragment : BindingFragment<FragmentMyPageBinding>(R.layout.fragment_
when (isAllowed) {
true -> {
binding.ivMypageAgree.transitionToStart()
lifecycleScope.launch {
val data = dataStoreRepository.getUserInfo().first()
val newData = data?.copy(fcmIsAllowed = false)
dataStoreRepository.saveUserInfo(newData)
}
patchUserInfo()
}

false -> {
binding.ivMypageAgree.transitionToEnd()
lifecycleScope.launch {
val data = dataStoreRepository.getUserInfo().first()
val newData = data?.copy(fcmIsAllowed = true)
dataStoreRepository.saveUserInfo(newData)
}
patchUserInfo()
}
}
myPageViewModel.patchAllowedNotification(isAllowed)
}
}

private fun patchUserInfo() {
lifecycleScope.launch {
val data = dataStoreRepository.getUserInfo().first()
val newData = data?.copy(fcmIsAllowed = false)
dataStoreRepository.saveUserInfo(newData)
}
}

// 닉네임 액티비티 갔다가 다시 돌아왔을 때 유저 데이터 갱신하도록
override fun onStart() {
super.onStart()
Expand Down Expand Up @@ -298,9 +297,6 @@ class MyPageFragment : BindingFragment<FragmentMyPageBinding>(R.layout.fragment_
}

is UiState.Failure -> {
val intent = Intent(requireActivity(), LoginActivity::class.java)
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
snackBar(binding.root) { state.msg }
}

Expand All @@ -313,7 +309,7 @@ class MyPageFragment : BindingFragment<FragmentMyPageBinding>(R.layout.fragment_
binding.data = data
updateTargetInfo(data)
updateUserLevel(data)
updateSwitchState(data)
updateNotificationAllowSwitchState(data)
}

private fun updateTargetInfo(data: User) {
Expand Down Expand Up @@ -356,7 +352,7 @@ class MyPageFragment : BindingFragment<FragmentMyPageBinding>(R.layout.fragment_
}
}

private fun updateSwitchState(data: User) {
private fun updateNotificationAllowSwitchState(data: User) {
when (data.fcmIsAllowed) {
true -> {
binding.ivMypageAgree.transitionToEnd()
Expand Down
12 changes: 0 additions & 12 deletions app/src/main/res/drawable/ic_mypage_switchoff.xml

This file was deleted.

12 changes: 0 additions & 12 deletions app/src/main/res/drawable/ic_mypage_switchon.xml

This file was deleted.

4 changes: 2 additions & 2 deletions app/src/main/res/layout/fragment_my_page.xml
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
android:id="@+id/cl_mypage_agree"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layoutDescription="@xml/fragment_my_page_xml_cl_mypage_agree_scene"
app:layoutDescription="@xml/mypage_noti_agree_motion_scene"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/v_mypage_line6">

Expand All @@ -383,7 +383,7 @@
android:layout_marginTop="15dp"
android:layout_marginBottom="16dp"
android:background="@android:color/transparent"
app:layoutDescription="@xml/fragment_my_page_xml_cl_mypage_agree_scene"
app:layoutDescription="@xml/mypage_noti_agree_motion_scene"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent" >
Expand Down

0 comments on commit bc88e5f

Please sign in to comment.