delete event types created at caldav sync, if the calendar is unsynced

This commit is contained in:
tibbi 2017-08-22 13:38:36 +02:00
parent 937c98f758
commit a5d11ec1fd
2 changed files with 4 additions and 1 deletions

View File

@ -70,7 +70,7 @@ class SettingsActivity : SimpleActivity() {
if (config.primaryColor != mStoredPrimaryColor) {
dbHelper.getEventTypes {
if (it.filter { it.caldavCalendarId == 0 }.size == 1) {
val eventType = it[0]
val eventType = it.first { it.caldavCalendarId == 0 }
eventType.color = config.primaryColor
dbHelper.updateEventType(eventType)
}
@ -156,6 +156,8 @@ class SettingsActivity : SimpleActivity() {
oldCalendarIds.filter { !newCalendarIds.contains(it) }.forEach {
CalDAVEventsHandler(applicationContext).deleteCalDAVCalendarEvents(it.toLong())
val eventId = dbHelper.getEventTypeIdWithCalDAVCalendarId(it.toInt())
dbHelper.deleteEventTypes(arrayListOf(eventId), true) {}
}
}).start()
}

View File

@ -18,6 +18,7 @@ import com.simplemobiletools.commons.extensions.getLongValue
import com.simplemobiletools.commons.extensions.getStringValue
import org.joda.time.DateTime
import java.util.*
import kotlin.collections.ArrayList
class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(context, DB_NAME, null, DB_VERSION) {
private val MAIN_TABLE_NAME = "events"