fixing a couple crashes
This commit is contained in:
parent
4a739485b2
commit
fb2cf62783
3 changed files with 13 additions and 3 deletions
|
@ -30,6 +30,7 @@ import java.util.regex.Pattern
|
|||
|
||||
class EventActivity : SimpleActivity() {
|
||||
private val LAT_LON_PATTERN = "^[-+]?([1-8]?\\d(\\.\\d+)?|90(\\.0+)?)([,;])\\s*[-+]?(180(\\.0+)?|((1[0-7]\\d)|([1-9]?\\d))(\\.\\d+)?)\$"
|
||||
private val EVENT = "EVENT"
|
||||
private val START_TS = "START_TS"
|
||||
private val END_TS = "END_TS"
|
||||
private val REMINDER_1_MINUTES = "REMINDER_1_MINUTES"
|
||||
|
@ -183,6 +184,7 @@ class EventActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
outState.apply {
|
||||
putSerializable(EVENT, mEvent)
|
||||
putLong(START_TS, mEventStartDateTime.seconds())
|
||||
putLong(END_TS, mEventEndDateTime.seconds())
|
||||
|
||||
|
@ -207,6 +209,7 @@ class EventActivity : SimpleActivity() {
|
|||
}
|
||||
|
||||
savedInstanceState.apply {
|
||||
mEvent = getSerializable(EVENT) as Event
|
||||
mEventStartDateTime = Formatter.getDateTimeFromTS(getLong(START_TS))
|
||||
mEventEndDateTime = Formatter.getDateTimeFromTS(getLong(END_TS))
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.database.Cursor
|
|||
import android.provider.CalendarContract
|
||||
import android.provider.CalendarContract.Reminders
|
||||
import android.util.SparseIntArray
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.*
|
||||
import com.simplemobiletools.calendar.pro.models.CalDAVCalendar
|
||||
import com.simplemobiletools.calendar.pro.models.Event
|
||||
|
@ -318,11 +319,16 @@ class CalDAVHelper(val context: Context) {
|
|||
private fun setupCalDAVEventReminders(event: Event) {
|
||||
clearEventReminders(event)
|
||||
event.getReminders().forEach {
|
||||
ContentValues().apply {
|
||||
val contentValues = ContentValues().apply {
|
||||
put(Reminders.MINUTES, it)
|
||||
put(Reminders.EVENT_ID, event.getCalDAVEventId())
|
||||
put(Reminders.METHOD, Reminders.METHOD_ALERT)
|
||||
context.contentResolver.insert(Reminders.CONTENT_URI, this)
|
||||
}
|
||||
|
||||
try {
|
||||
context.contentResolver.insert(Reminders.CONTENT_URI, contentValues)
|
||||
} catch (e: Exception) {
|
||||
context.toast(R.string.unknown_error_occurred)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.simplemobiletools.calendar.pro.helpers
|
|||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import androidx.collection.LongSparseArray
|
||||
import com.simplemobiletools.calendar.pro.R
|
||||
import com.simplemobiletools.calendar.pro.extensions.*
|
||||
import com.simplemobiletools.calendar.pro.models.Event
|
||||
import com.simplemobiletools.calendar.pro.models.EventType
|
||||
|
@ -246,7 +247,7 @@ class EventsHelper(val context: Context) {
|
|||
|
||||
events.forEach {
|
||||
it.updateIsPastEvent()
|
||||
it.color = eventTypeColors.get(it.eventType)!!
|
||||
it.color = eventTypeColors.get(it.eventType) ?: context.resources.getColor(R.color.color_primary)
|
||||
}
|
||||
|
||||
callback(events)
|
||||
|
|
Loading…
Reference in a new issue