Skip to content

Commit

Permalink
fix:TOP-88 유효하지 않은 Emoji코드를 파싱 시도하면 앱이 Crash나는 문제 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
cwj-c committed Nov 26, 2023
1 parent 486c4f1 commit 36415a6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,12 @@ class IdealTypeFragment : SignupRootBaseFragment<IdealTypeViewModel, FragmentIde
}

private fun addChip(ideal: IdealTypeModel, idx: Int) {
val code = Integer.decode("0x${ideal.emojiCode}")
val emoji = String(Character.toChars(code))
val emoji = StringUtil.parseEmoji(ideal.emojiCode).let {
if (it.isNullOrBlank()) "" else "$it "
}
binding.groupChip.addView(
getIdealChip().apply {
"$emoji ${ideal.title}".let {
"$emoji${ideal.title}".let {
text = it
}
setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,12 @@ class InterestFragment : SignupRootBaseFragment<InterestViewModel, FragmentInter
}

private fun addChip(interest: InterestModel, idx: Int) {
val code = Integer.decode("0x${interest.emojiCode}")
val emoji = String(Character.toChars(code))
val emoji = StringUtil.parseEmoji(interest.emojiCode).let {
if (it.isNullOrBlank()) "" else "$it "
}
binding.groupChip.addView(
getInterestChip().apply {
"$emoji ${interest.title}".let {
"$emoji${interest.title}".let {
text = it
}
setOnClickListener {
Expand Down
10 changes: 10 additions & 0 deletions feature/signin/src/main/java/tht/feature/signin/util/StringUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import android.text.style.ForegroundColorSpan
import android.widget.TextView

object StringUtil {
fun parseEmoji(emojiCode: String): String? {
return try {
val code = Integer.decode("0x${emojiCode}")
String(Character.toChars(code))
} catch (e: Exception) {
e.printStackTrace()
null
}
}

fun setWhiteTextColor(textView: TextView, range: IntRange) {
textView.text = setTextColor(
textView.text.toString(),
Expand Down

0 comments on commit 36415a6

Please sign in to comment.