Skip to content
Snippets Groups Projects
Commit 02eefd3c authored by Kamal Bramwell's avatar Kamal Bramwell
Browse files

Updated decoding to recognize "null" Strings

parent f28f8330
Branches
No related tags found
No related merge requests found
...@@ -19,7 +19,7 @@ interface BindingsModel { ...@@ -19,7 +19,7 @@ interface BindingsModel {
inline fun <reified T> decode(data: ByteArray?): T? { inline fun <reified T> decode(data: ByteArray?): T? {
return data?.run { return data?.run {
if (isNotEmpty()) { if (isNotEmpty() && decodeToString() != "null") {
val typeToken = object : TypeToken<T>() {}.type val typeToken = object : TypeToken<T>() {}.type
Gson().fromJson<T>(decodeToString(), typeToken) Gson().fromJson<T>(decodeToString(), typeToken)
} else { } else {
...@@ -31,7 +31,7 @@ interface BindingsModel { ...@@ -31,7 +31,7 @@ interface BindingsModel {
inline fun <reified T> decodeArray(data: ByteArray?): List<T> { inline fun <reified T> decodeArray(data: ByteArray?): List<T> {
return data?.run { return data?.run {
if (isNotEmpty()) { if (isNotEmpty() && decodeToString() != "null") {
val typeToken = object : TypeToken<Array<T>>() {}.type val typeToken = object : TypeToken<Array<T>>() {}.type
Gson().fromJson<Array<T>>(decodeToString(), typeToken).toList() Gson().fromJson<Array<T>>(decodeToString(), typeToken).toList()
} else listOf() } else listOf()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment