Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ea01dcd5 authored by Ricki Hirner's avatar Ricki Hirner
Browse files

Ignore empty strings when processing locally stored events

parent 5b6ab803
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -110,13 +110,15 @@ abstract class AndroidEvent(
                    field = event

                    val e = iterEvents.next()
                    populateEvent(e.entityValues)
                    populateEvent(MiscUtils.removeEmptyStrings(e.entityValues))

                    for (subValue in e.subValues)
                    for (subValue in e.subValues) {
                        val subValues = MiscUtils.removeEmptyStrings(subValue.values)
                        when (subValue.uri) {
                            Attendees.CONTENT_URI -> populateAttendee(subValue.values)
                            Reminders.CONTENT_URI -> populateReminder(subValue.values)
                            ExtendedProperties.CONTENT_URI -> populateExtended(subValue.values)
                            Attendees.CONTENT_URI -> populateAttendee(subValues)
                            Reminders.CONTENT_URI -> populateReminder(subValues)
                            ExtendedProperties.CONTENT_URI -> populateExtended(subValues)
                        }
                    }
                    populateExceptions()

+4 −2
Original line number Diff line number Diff line
@@ -85,15 +85,17 @@ object MiscUtils {
    /**
     * Removes empty [String] values from [values].
     *
     * @param values set of values to be processed
     * @param values set of values to be modified
     * @return the modified object (which is the same object as passed in; for chaining)
     */
    fun removeEmptyStrings(values: ContentValues) {
    fun removeEmptyStrings(values: ContentValues): ContentValues {
        val it = values.keySet().iterator()
        while (it.hasNext()) {
            val obj = values[it.next()]
            if (obj is String && obj.isEmpty())
                it.remove()
        }
        return values
    }