Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show error dialog on network error #131

Merged
merged 2 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions android/app/src/main/assets/zero_shot_classname_to_unicode.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"call": "U+1F919",
"dislike": "U+1F645",
"fist": "U+1F44A",
"like": "U+1F44D",
"mute": "U+1F92B",
"ok": "U+1F646",
"palm": "U+1F64B",
"peace": "U+270C",
"rock": "U+1F918",
"stop": "U+270B"
"clapping hands": "U+1F44F",
"I love it": "U+2764 U+FE0F",
"selfie": "U+1F933",
"punch": "U+1F44A",
"I see you": "U+1F440",
"no": "U+1F645",
"so hot": "U+1F525",
"cool": "U+1F60E",
"angry": "U+1F620",
"praying hands": "U+1F64F"
}
102 changes: 102 additions & 0 deletions android/app/src/main/assets/zero_shot_classname_to_unicode_100.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
{
"call": "U+1F919",
"dislike": "U+1F645",
"fist": "U+1F44A",
"like": "U+1F44D",
"mute": "U+1F92B",
"ok": "U+1F646",
"palm": "U+1F64B",
"peace": "U+270C",
"rock": "U+1F918",
"stop": "U+270B",
"clapping hands": "U+1F44F",
"thumbs up": "U+1F44D",
"thumbs down": "U+1F44E",
"waving hand": "U+1F44B",
"raised hand": "U+270B",
"victory hand": "U+270C",
"crossed fingers": "U+1F91E",
"love-you gesture": "U+1F91F",
"sign of the horns": "U+1F918",
"call me hand": "U+1F919",
"flexed biceps": "U+1F4AA",
"folded hands": "U+1F64F",
"handshake": "U+1F91D",
"writing hand": "U+270D",
"selfie": "U+1F933",
"mouth": "U+1F444",
"nose": "U+1F443",
"ear": "U+1F442",
"foot": "U+1F9B6",
"leg": "U+1F9B5",
"mechanical arm": "U+1F9BE",
"mechanical leg": "U+1F9BF",
"pointing up": "U+261D",
"pointing down": "U+1F447",
"pointing left": "U+1F448",
"pointing right": "U+1F449",
"raised fist": "U+270A",
"oncoming fist": "U+1F44A",
"left-facing fist": "U+1F91B",
"right-facing fist": "U+1F91C",
"raising hands": "U+1F64C",
"open hands": "U+1F450",
"palms up together": "U+1F932",
"hand with fingers splayed": "U+1F590",
"vulcan salute": "U+1F596",
"praying hands": "U+1F64F",
"eyes": "U+1F440",
"speaking head": "U+1F5E3",
"boy": "U+1F466",
"girl": "U+1F467",
"man": "U+1F468",
"woman": "U+1F469",
"person frowning": "U+1F64D",
"person pouting": "U+1F64E",
"person gesturing no": "U+1F645",
"person gesturing ok": "U+1F646",
"person tipping hand": "U+1F481",
"person raising hand": "U+1F64B",
"person bowing": "U+1F647",
"person facepalming": "U+1F926",
"person shrugging": "U+1F937",
"weight lifter": "U+1F3CB",
"wrestlers": "U+1F93C",
"handball": "U+1F93E",
"juggling": "U+1F939",
"smile": "U+1F642",
"heart": "U+2764",
"clap": "U+1F44F",
"star": "U+2B50",
"fire": "U+1F525",
"laugh": "U+1F602",
"wink": "U+1F609",
"sad": "U+1F641",
"angry": "U+1F620",
"wow": "U+1F62E",
"cool": "U+1F60E",
"kiss": "U+1F618",
"hug": "U+1F917",
"thinking": "U+1F914",
"scream": "U+1F631",
"rolling eyes": "U+1F644",
"sleep": "U+1F634",
"sweat": "U+1F613",
"nerd": "U+1F913",
"money-mouth": "U+1F911",
"sick": "U+1F912",
"dizzy": "U+1F635",
"party": "U+1F973",
"cat": "U+1F431",
"dog": "U+1F436",
"sun": "U+2600",
"moon": "U+1F319",
"cloud": "U+2601",
"rain": "U+1F327",
"snow": "U+1F328",
"lightning": "U+1F329",
"tornado": "U+1F32A",
"wind": "U+1F32C",
"fog": "U+1F32B",
"rainbow": "U+1F308"
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ enum class CustomError(
},
INTERNAL_SERVER_ERROR(500) {
override fun body(): String = "네트워크 접속 오류가 발생했습니다."
},;
},
NETWORK_IS_BUSY(503) {
override fun body(): String = "네트워크가 혼잡합니다.\n잠시 후 다시 시도해주세요."
};

companion object {
fun getBy(statusCode: Int) = values().firstOrNull { it.statusCode == statusCode }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.goliath.emojihub.repositories.remote

import android.net.Uri
import android.util.Log
import com.goliath.emojihub.data_sources.ApiErrorController
import com.goliath.emojihub.data_sources.CustomError
import com.goliath.emojihub.data_sources.api.ClipApi
import com.goliath.emojihub.data_sources.local.MediaDataSource
import com.goliath.emojihub.models.ClipRequestDto
Expand All @@ -18,7 +20,8 @@ interface ClipRepository {
@Singleton
class ClipRepositoryImpl @Inject constructor(
private val clipApi: ClipApi,
private val mediaDataSource: MediaDataSource
private val mediaDataSource: MediaDataSource,
private val errorController: ApiErrorController
): ClipRepository {
// FIXME: Default emojis should be topK different emojis -> use just 3 emojis for now
override val DEFAULT_EMOJI_LIST = listOf(
Expand Down Expand Up @@ -79,9 +82,11 @@ class ClipRepositoryImpl @Inject constructor(
}
}
Log.e("ClipRepository", "Clip inference response is not successful")
errorController.setErrorState(CustomError.NETWORK_IS_BUSY.statusCode)
return emptyList()
} catch (e: Exception) {
Log.e("ClipRepository", "Error running clip inference ${e.message}")
errorController.setErrorState(CustomError.NETWORK_IS_BUSY.statusCode)
}
return emptyList()
}
Expand Down
Loading