Merge pull request #1338 from Andries-Smit/fix/nullable-resource-helper-get-string-args
fix rh gs with empty args
This commit is contained in:
commit
fef8421e79
1 changed files with 5 additions and 4 deletions
|
@ -20,20 +20,21 @@ import javax.inject.Inject
|
|||
*/
|
||||
class ResourceHelperImplementation @Inject constructor(private val context: Context, private val fabricPrivacy: FabricPrivacy) : ResourceHelper {
|
||||
|
||||
override fun gs(@StringRes id: Int): String = gs(id, null)
|
||||
override fun gs(@StringRes id: Int): String = context.getString(id)
|
||||
|
||||
override fun gs(@StringRes id: Int, vararg args: Any?) : String {
|
||||
return try {
|
||||
context.getString(id, *args)
|
||||
} catch (exception: Exception) {
|
||||
val resourceName = context.resources.getResourceEntryName(id);
|
||||
val resourceName = context.resources.getResourceEntryName(id)
|
||||
val resourceValue = context.getString(id)
|
||||
val currentLocale: Locale = context.resources.configuration.locale
|
||||
fabricPrivacy.logMessage("Failed to get string for resource $resourceName ($id) for locale $currentLocale with args ${args.map{it.toString()}}")
|
||||
fabricPrivacy.logMessage("Failed to get string for resource $resourceName ($id) '$resourceValue' for locale $currentLocale with args ${args.map{it.toString()}}")
|
||||
fabricPrivacy.logException(exception)
|
||||
try {
|
||||
gsNotLocalised(id, *args)
|
||||
} catch (exceptionNonLocalized: Exception) {
|
||||
fabricPrivacy.logMessage("Fallback failed to get string for resource $resourceName ($id) with args ${args.map { it.toString() }}")
|
||||
fabricPrivacy.logMessage("Fallback failed to get string for resource $resourceName ($id) '$resourceValue' with args ${args.map { it.toString() }}")
|
||||
fabricPrivacy.logException(exceptionNonLocalized)
|
||||
"FAILED to get string $resourceName"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue