mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-06-05 21:59:17 +02:00
Return empty list on empty value
This commit is contained in:
@ -29,10 +29,14 @@ class Converters {
|
|||||||
fun stringListToJson(list: List<String>) = gson.toJson(list)
|
fun stringListToJson(list: List<String>) = gson.toJson(list)
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
fun attendeeListToJson(list: List<Attendee>) = gson.toJson(list)
|
fun attendeeListToJson(list: List<Attendee>): String = gson.toJson(list)
|
||||||
|
|
||||||
@TypeConverter
|
@TypeConverter
|
||||||
fun jsonToAttendeeList(value: String): List<Attendee> {
|
fun jsonToAttendeeList(value: String): List<Attendee> {
|
||||||
|
if (value.isEmpty()) {
|
||||||
|
return emptyList()
|
||||||
|
}
|
||||||
|
|
||||||
return try {
|
return try {
|
||||||
gson.fromJson<ArrayList<Attendee>>(value, attendeeType) ?: ArrayList()
|
gson.fromJson<ArrayList<Attendee>>(value, attendeeType) ?: ArrayList()
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
Reference in New Issue
Block a user