From f1d2577e147c93c155966a76dad08e8d9208985a Mon Sep 17 00:00:00 2001 From: "HyunWoo Lee (Nunu Lee)" <54518925+l2hyunwoo@users.noreply.github.com> Date: Fri, 21 Jul 2023 16:57:28 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=90=EA=B8=B0=20=EC=82=AC=EC=A7=84=20?= =?UTF-8?q?=EA=B3=B5=EC=9C=A0=20=EC=8B=9C=EB=8F=84=20=EC=8B=9C=20=EC=B0=A8?= =?UTF-8?q?=EB=8B=A8=20(#222)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../receive/ReceiveSharedImageActivity.kt | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/teampophory/pophory/feature/share/receive/ReceiveSharedImageActivity.kt b/app/src/main/java/com/teampophory/pophory/feature/share/receive/ReceiveSharedImageActivity.kt index d9923f7c..da1084cb 100644 --- a/app/src/main/java/com/teampophory/pophory/feature/share/receive/ReceiveSharedImageActivity.kt +++ b/app/src/main/java/com/teampophory/pophory/feature/share/receive/ReceiveSharedImageActivity.kt @@ -121,13 +121,30 @@ class ReceiveSharedImageActivity : AppCompatActivity() { } else { val errorBody = parseErrorBody(httpException) val parsedBody = Json.parseToJsonElement(errorBody).jsonObject - if (parsedBody.containsKey("code") && parsedBody["code"]?.jsonPrimitive?.intOrNull == 442) { + if (!parsedBody.containsKey("code")) { snackBar(binding.root) { - "앨범에 사진을 바운 이후 다시 이용해주세요." + "사진 등록 시 네트워크에 문제가 발생했습니다." } } else { - snackBar(binding.root) { - "앨범에 사진 등록 시 네트워크에 문제가 발생했습니다." + val errorCode = parsedBody["code"]?.jsonPrimitive?.intOrNull + when (errorCode) { + ALBUM_LIMIT_EXCEPTION_CODE -> { + snackBar(binding.root) { + "앨범에 사진을 바운 이후 다시 이용해주세요." + } + } + + SELF_APPROVE_EXCEPTION_CODE -> { + snackBar(binding.root) { + "이미 내 앨범에 있는 사진이에요." + } + } + + else -> { + snackBar(binding.root) { + "앨범에 사진 등록 시 네트워크에 문제가 발생했습니다." + } + } } } } @@ -140,4 +157,9 @@ class ReceiveSharedImageActivity : AppCompatActivity() { private fun parseErrorBody(exception: HttpException): String { return exception.response()?.errorBody()?.string() ?: "" } + + private companion object { + const val ALBUM_LIMIT_EXCEPTION_CODE = 442 + const val SELF_APPROVE_EXCEPTION_CODE = 4423 + } }