Skip to content

Commit 7deafca

Browse files
committed
테스트 공유 코드 방어 코드 추가
1 parent 7226a99 commit 7deafca

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

presentation/src/main/java/com/keyme/presentation/dailykeymetest/DailyKeymeTestRoute.kt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.keyme.presentation.dailykeymetest
22

3+
import android.widget.Toast
34
import androidx.compose.foundation.background
45
import androidx.compose.foundation.layout.Box
56
import androidx.compose.foundation.layout.fillMaxSize
@@ -58,8 +59,8 @@ fun DailyKeymeTestRoute(
5859
if (showTutorial) navigateToTutorial()
5960

6061
val myCharacter by dailyKeymeTestViewModel.myCharacterState.collectAsStateWithLifecycle()
61-
val dailyKeymeTest by dailyKeymeTestViewModel.dailyKeymeTestState.collectAsStateWithLifecycle()
62-
val dailyKeymeTestStatistic by dailyKeymeTestViewModel.dailyKeymeTestStatisticState.collectAsStateWithLifecycle()
62+
val dailyKeymeTest by dailyKeymeTestViewModel.keymeTestState.collectAsStateWithLifecycle()
63+
val dailyKeymeTestStatistic by dailyKeymeTestViewModel.keymeTestStatisticState.collectAsStateWithLifecycle()
6364

6465
val context = LocalContext.current
6566

@@ -77,7 +78,12 @@ fun DailyKeymeTestRoute(
7778
navigateToTakeKeymeTest(dailyKeymeTest.testId)
7879
},
7980
onShareClick = {
80-
context.startShareActivity(KeymeLinkUtil.getTestLink(dailyKeymeTest.testId))
81+
val shareTestLink = KeymeLinkUtil.getTestLink(dailyKeymeTest.testId)
82+
if (shareTestLink.isNotEmpty()) {
83+
context.startShareActivity(KeymeLinkUtil.getTestLink(dailyKeymeTest.testId))
84+
} else {
85+
Toast.makeText(context, "테스트 정보를 가져오는데 실패했습니다.", Toast.LENGTH_SHORT).show()
86+
}
8187
},
8288
onQuestionStatisticClick = navigateToQuestionResult,
8389
)

presentation/src/main/java/com/keyme/presentation/myprofile/ui/MyProfileScreen.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.keyme.presentation.myprofile.ui
22

3+
import android.widget.Toast
34
import androidx.compose.foundation.ExperimentalFoundationApi
45
import androidx.compose.foundation.Image
56
import androidx.compose.foundation.background
@@ -96,7 +97,11 @@ fun MyProfileScreen(
9697
val context = LocalContext.current
9798
EmptyStatistics(
9899
onShareClick = {
99-
context.startShareActivity(myProfileUiState.testLink)
100+
if (myProfileUiState.testLink.isNotEmpty()) {
101+
context.startShareActivity(myProfileUiState.testLink)
102+
} else {
103+
Toast.makeText(context, "테스트 정보를 가져오는데 실패했습니다.", Toast.LENGTH_SHORT).show()
104+
}
100105
},
101106
)
102107
}
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package com.keyme.presentation.utils
22

33
object KeymeLinkUtil {
4-
fun getTestLink(testId: Int) = "${Consts.testLinkUrl}$testId"
4+
fun getTestLink(testId: Int): String {
5+
return if (testId != 0) {
6+
"${Consts.testLinkUrl}$testId"
7+
} else {
8+
""
9+
}
10+
}
511
}

0 commit comments

Comments
 (0)