mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-17 04:10:45 +01:00
Reset event type if last used event type was deleted
This commit is contained in:
parent
330ba940c9
commit
085d16d908
@ -17,6 +17,7 @@ import com.simplemobiletools.calendar.pro.extensions.*
|
||||
import com.simplemobiletools.calendar.pro.helpers.*
|
||||
import com.simplemobiletools.calendar.pro.helpers.Formatter
|
||||
import com.simplemobiletools.calendar.pro.models.Event
|
||||
import com.simplemobiletools.calendar.pro.models.EventType
|
||||
import com.simplemobiletools.calendar.pro.models.Reminder
|
||||
import com.simplemobiletools.commons.dialogs.ConfirmationDialog
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
@ -57,9 +58,11 @@ class TaskActivity : SimpleActivity() {
|
||||
return@ensureBackgroundThread
|
||||
}
|
||||
|
||||
val storedEventTypes = eventTypesDB.getEventTypes().toMutableList() as ArrayList<EventType>
|
||||
val localEventType = storedEventTypes.firstOrNull { it.id == config.lastUsedLocalEventTypeId }
|
||||
runOnUiThread {
|
||||
if (!isDestroyed && !isFinishing) {
|
||||
gotTask(savedInstanceState, task)
|
||||
gotTask(savedInstanceState, localEventType, task)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,7 +129,11 @@ class TaskActivity : SimpleActivity() {
|
||||
updateTimeText()
|
||||
}
|
||||
|
||||
private fun gotTask(savedInstanceState: Bundle?, task: Event?) {
|
||||
private fun gotTask(savedInstanceState: Bundle?, localEventType: EventType?, task: Event?) {
|
||||
if (localEventType == null) {
|
||||
config.lastUsedLocalEventTypeId = REGULAR_EVENT_TYPE_ID
|
||||
}
|
||||
|
||||
mEventTypeId = if (config.defaultEventTypeId == -1L) config.lastUsedLocalEventTypeId else config.defaultEventTypeId
|
||||
|
||||
if (task != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user