Convert Recipient to kotlin.

This commit is contained in:
Greyson Parrelli
2024-04-03 12:23:55 -04:00
parent b50eab230d
commit 3ba2b46bb0
100 changed files with 1513 additions and 2020 deletions

View File

@@ -34,8 +34,9 @@ sealed class ServiceId(val libSignalServiceId: LibSignalServiceId) {
}
/** Parses a ServiceId serialized as a string. Returns null if the ServiceId is invalid. */
@JvmOverloads
@JvmStatic
fun parseOrNull(raw: String?): ServiceId? {
fun parseOrNull(raw: String?, logFailures: Boolean = true): ServiceId? {
if (raw == null) {
return null
}
@@ -43,10 +44,14 @@ sealed class ServiceId(val libSignalServiceId: LibSignalServiceId) {
return try {
fromLibSignal(LibSignalServiceId.parseFromString(raw))
} catch (e: IllegalArgumentException) {
Log.w(TAG, "[parseOrNull(String)] Illegal argument!", e)
if (logFailures) {
Log.w(TAG, "[parseOrNull(String)] Illegal argument!", e)
}
null
} catch (e: InvalidServiceIdException) {
Log.w(TAG, "[parseOrNull(String)] Invalid ServiceId!", e)
if (logFailures) {
Log.w(TAG, "[parseOrNull(String)] Invalid ServiceId!", e)
}
null
}
}