fix some crashes related to missing Label fields at upgrading from older versions
This commit is contained in:
parent
5bd429709b
commit
00d5fbc6be
|
@ -283,14 +283,27 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
|
||||||
val phoneNumbers = if (phoneNumbersJson == "[]") ArrayList() else gson.fromJson<ArrayList<PhoneNumber>>(phoneNumbersJson, phoneNumbersToken)
|
val phoneNumbers = if (phoneNumbersJson == "[]") ArrayList() else gson.fromJson<ArrayList<PhoneNumber>>(phoneNumbersJson, phoneNumbersToken)
|
||||||
?: ArrayList(1)
|
?: ArrayList(1)
|
||||||
|
|
||||||
|
// labels can be null at upgrading from older app versions, when the label wasn't available at all yet
|
||||||
|
phoneNumbers.filter { it.label == null }.forEach {
|
||||||
|
it.label = ""
|
||||||
|
}
|
||||||
|
|
||||||
val emailsJson = cursor.getStringValue(COL_EMAILS)
|
val emailsJson = cursor.getStringValue(COL_EMAILS)
|
||||||
val emails = if (emailsJson == "[]") ArrayList() else gson.fromJson<ArrayList<Email>>(emailsJson, emailsToken)
|
val emails = if (emailsJson == "[]") ArrayList() else gson.fromJson<ArrayList<Email>>(emailsJson, emailsToken)
|
||||||
?: ArrayList(1)
|
?: ArrayList(1)
|
||||||
|
|
||||||
|
emails.filter { it.label == null }.forEach {
|
||||||
|
it.label = ""
|
||||||
|
}
|
||||||
|
|
||||||
val addressesJson = cursor.getStringValue(COL_ADDRESSES)
|
val addressesJson = cursor.getStringValue(COL_ADDRESSES)
|
||||||
val addresses = if (addressesJson == "[]") ArrayList() else gson.fromJson<ArrayList<Address>>(addressesJson, addressesToken)
|
val addresses = if (addressesJson == "[]") ArrayList() else gson.fromJson<ArrayList<Address>>(addressesJson, addressesToken)
|
||||||
?: ArrayList(1)
|
?: ArrayList(1)
|
||||||
|
|
||||||
|
addresses.filter { it.label == null }.forEach {
|
||||||
|
it.label = ""
|
||||||
|
}
|
||||||
|
|
||||||
val eventsJson = cursor.getStringValue(COL_EVENTS)
|
val eventsJson = cursor.getStringValue(COL_EVENTS)
|
||||||
val events = if (eventsJson == "[]") ArrayList() else gson.fromJson<ArrayList<Event>>(eventsJson, eventsToken)
|
val events = if (eventsJson == "[]") ArrayList() else gson.fromJson<ArrayList<Event>>(eventsJson, eventsToken)
|
||||||
?: ArrayList(1)
|
?: ArrayList(1)
|
||||||
|
|
Loading…
Reference in New Issue